https://blog.shiniv.com/2016/09/decode-encode-cloudflare-address-obfuscation/
1.源代码就能发现类似如下的代码
<a class=”__cf_email__” data-cfemail=”30515253705152531e535f5d” href=”/cdn-cgi/l/email-protection”>
[email protected]
</a>
<script data-cfhash=”f9e31″ type=”text/javascript”>
/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName(‘script’),e=t.length;e–;)if(t[e].getAttribute(‘data-cfhash’))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute(‘data-cfemail’)){for(e=”,r=’0x’+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+=’%’+(‘0’+(‘0x’+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */
</script>
2.PHP 的方式将这个邮箱地址解密出来
function deCFEmail($encode){
$k = hexdec(substr($encode,0,2));
for($i=2, $m=”; $i < strlen($encode) – 1; $i += 2){
$m.=chr(hexdec(substr($encode, $i, 2))^$k);
}
return $m;
}
echo deCFEmail(“30515253705152531e535f5d”).”\n”;
3.加密的算法
function encodeEmail($email, $key=0) {
$chars = str_split($email);
$string = ”;
$key = $key ? $key : rand(10, 99);
foreach ($chars as $value) {
$string .= sprintf(“%02s”, dechex(ord($value)^$key));
}
return dechex($key).$string;
}