php前端代码混淆,HTML代码混淆PHP版

//要存的html源码内容,支持换行,注意把单引号用\转移

$testStr = '

row 1, cell 1row 1, cell 2
row 2, cell 1row 2, cell 2

';

function randomStr($intLength)

{

$str = null;

$strPol = "abcdefghijklmnopqrstuvwxyz";

$max = strlen($strPol)-1;

for($i=0;$i

$str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数

}

return $str;

}

//定义随机字符串,作为变量名

function getCode($intLength)

{

$str = null;

$strPol = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

$max = strlen($strPol)-1;

for($i=0;$i

$str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数

}

return $str;

}

function vbsEscape11($str)

{

return htmlspecialchars($str, ENT_QUOTES);

}

function vbsEscape($str)

{

$sublen=strlen($str);

$retrunString="";

for ($i=0;$i

{

if(ord($str[$i])>=127)

{

$tmpString=bin2hex(iconv("gb2312","ucs-2",substr($str,$i,2)));

//$tmpString=substr($tmpString,2,2).substr($tmpString,0,2);window下可能要打开此项

$retrunString.="%u".$tmpString;

$i++;

} else

{

$retrunString.="%".dechex(ord($str[$i]));

}

}

return $retrunString;

}

function mainFun($htmlStr)

{

$ax01 = getCode(4).randomStr(12);// '替换字符1

$ax02 = getCode(4).randomStr(12);// '替换字符2

$ax03 = getCode(4).randomStr(12);// '替换字符3

$ax04 = getCode(4).randomStr(12);// '替换字符4

$ax05 = getCode(4).randomStr(12);// '替换字符5

$ax07 = getCode(4).randomStr(12);// '变量名1

$ax08 = getCode(4).randomStr(12);// '变量名2

$ax09 = getCode(4).randomStr(12);// '变量名3

$ht01=str_replace("\r\n","",$htmlStr);

$ht01=vbsEscape($ht01);

$ht01=str_replace("-",$ax01,$ht01);

$ht01=str_replace("/",$ax02,$ht01);

$ht01=str_replace(".",$ax03,$ht01);

$ht01=str_replace("%",$ax04,$ht01);

$ht01=str_replace("_",$ax05,$ht01);

$ht01=str_replace("_",$ax06,$ht01);

$ht01=str_replace("_",$ax07,$ht01);

$ht01=str_replace("_",$ax08,$ht01);

$ht01=str_replace("_",$ax09,$ht01);

echo

'

'.$ax07.'=\''.$ht01.'\';

'.$ax07.'='.$ax07.'.replace(/'.$ax01.'/g, \'-\').replace(/'.$ax02.'/g, \'/\').replace(/'.$ax03.'/g, \'.\').replace(/'.$ax04.'/g, \'%\').replace(/'.$ax05.'/g, \'_\');

var '.$ax08.'=unescape('.$ax07.');

document.write('.$ax08.')

';

}

mainFun($testStr);

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值