02 |
function encode_file_contents($filename)
{ |
03 |
$type=strtolower(substr(strrchr($filename,'.'),1)); |
04 |
if('php'==$type && is_file($filename)
&& is_writable($filename)){ |
05 |
$contents = file_get_contents($filename); |
06 |
$contents =
php_strip_whitespace($filename); |
08 |
$headerPos = strpos($contents,'<?php'); |
09 |
$footerPos = strrpos($contents,'?>'); |
10 |
$contents = substr($contents,$headerPos+5,$footerPos-$headerPos); |
11 |
$encode = base64_encode(gzdeflate($contents)); |
12 |
$encode = '<?php'."\n
eval(gzinflate(base64_decode("."'".$encode."'".")));\n\n?>"; |
13 |
return file_put_contents($filename,$encode); |
20 |
encode_file_contents($filename); |
PHP的源码加密方式2:
02 |
function RandAbc($length=""){ |
03 |
$str="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
04 |
return str_shuffle($str); |
09 |
$vstr=file_get_contents($filename); |
10 |
$v1=base64_encode($vstr); |
11 |
$c=strtr($v1,$T_k1,$T_k2); |
19 |
$s='$'.$q6.'=urldecode("%6E1%7A%62%2F%6D%615%5C%76%740%6928%2D%70%78%75%71%79%2A6%6C%72%6B%64%679%5F%65%68%63%73%77%6F4%2B%6637%6A");$'.$q1.'=$'.$q6.'{3}.$'.$q6.'{6}.$'.$q6.'{33}.$'.$q6.'{30};$'.$q3.'=$'.$q6.'{33}.$'.$q6.'{10}.$'.$q6.'{24}.$'.$q6.'{10}.$'.$q6.'{24};$'.$q4.'=$'.$q3.'{0}.$'.$q6.'{18}.$'.$q6.'{3}.$'.$q3.'{0}.$'.$q3.'{1}.$'.$q6.'{24};$'.$q5.'=$'.$q6.'{7}.$'.$q6.'{13};$'.$q1.'.=$'.$q6.'{22}.$'.$q6.'{36}.$'.$q6.'{29}.$'.$q6.'{26}.$'.$q6.'{30}.$'.$q6.'{32}.$'.$q6.'{35}.$'.$q6.'{26}.$'.$q6.'{30};eval($'.$q1.'("'.base64_encode('$'.$q2.'="'.$c.'";eval(\'?>\'.$'.$q1.'($'.$q3.'($'.$q4.'($'.$q2.',$'.$q5.'*2),$'.$q4.'($'.$q2.',$'.$q5.',$'.$q5.'),$'.$q4.'($'.$q2.',0,$'.$q5.'))));').'"));'; |
26 |
$fpp1 = fopen('dam.php','w'); |
27 |
fwrite($fpp1,$s) or die('写文件错误'); |
其实,PHP加密源码方式有很多,譬如,免费的微盾PHP加密,还有 phpjm . net 搞的在线加密,只是phpjm更复杂点而已。