Base64+gzinflate compressed encoded (encrypted) files are usually Eval (Gzinflate (Base64_decode) (a file for the header. The coding and decoding code are given in this paper.
Compressed encoding (encryption) code:
<?php
function Encode_file_contents ($filename) {
$type =strtolower (STRRCHR ($filename, '. '), 1);
if (' php ' = = $type && is_file ($filename) && is_writable ($filename)) {//If it is a PHP file and is writable, compress the code
$contents = file_get_contents ($filename);//Determine if the file has been encoded
$pos = Strpos ($contents, '/*protected by grass name http://www.crazyi.cn cryptation*/');
if (false = = $pos | | $pos >100) {//Remove PHP file comments and whitespace, reduce file size
$contents = Php_strip_whitespace ($filename);
Remove PHP head and tail logo
$headerPos = Strpos ($contents, ' <?php ');
$footerPos = Strrpos ($contents, '?> ');
$contents = substr ($contents, $headerPos +5, $footerPos-$headerPos);
$encode = Base64_encode (Gzdeflate ($contents));//Start encoding
$encode = ' <?php './*protected by grass name http://www.crazyi.cn cryptation*/\n eval (gzinflate (". $encode.")); \/*reverse Engineering is illegal and Strictly prohibited-(C) grass name cryptation 2008*/\n?> ";
Return file_put_contents ($filename, $encode);
}
}
return false;
}
Call function
$filename = ' G:\ my document \ Desktop \test.php ';
Encode_file_contents ($filename);
?>
<?php
function Encode_file_contents ($filename) {
$type =strtolower (STRRCHR ($filename, '. '), 1);
if (' php ' = = $type && is_file ($filename) && is_writable ($filename)) {//If it is a PHP file and is writable, compress the code
$contents = file_get_contents ($filename);//Determine if the file has been encoded
$pos = Strpos ($contents, '/*protected by grass name http://www.crazyi.cn cryptation*/');
if (false = = $pos | | $pos >100) {//Remove PHP file comments and whitespace, reduce file size
$contents = Php_strip_whitespace ($filename);
Remove PHP head and tail logo
$headerPos = Strpos ($contents, ' <?php ');
$footerPos = Strrpos ($contents, '?> ');
$contents = substr ($contents, $headerPos +5, $footerPos-$headerPos);
$encode = Base64_encode (Gzdeflate ($contents));//Start encoding
$encode = ' <?php './*protected by grass name http://www.crazyi.cn cryptation*/\n eval (gzinflate (". $encode.")); \/*reverse Engineering is illegal and Strictly prohibited-(C) grass name cryptation 2008*/\n?> ";
Return file_put_contents ($filename, $encode);
}
}
return false;
}
Call function
$filename = ' G:\ my document \ Desktop \test.php ';
Encode_file_contents ($filename);
?>
Compressed decoding (decryption) code:
CODE:
<?php
$Code = '这里填写要解密的编码'; // base64编码
$File = 'test.php';//解码后保存的文件
$Temp = base64_decode($Code);
$temp = gzinflate($Temp);
$FP = fopen($File,"w");
fwrite($FP,$temp);
fclose($FP);
echo "解密成功!";
?>