Base64+gzinflate compressed encoded (encrypted) files are usually Eval (gzinflate (Base64_decode), a php file for headers. Here we give the encoding and decoding (encryption and decryption) code.
compression encoding (encryption) code:
Copy Code code as follows:
<?php
function Encode_file_contents ($filename) {
$type =strtolower (substr 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);
//Removal of 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. ")); \ N/*reverse engineering is illegal and Strictly prohibited-(C) grass name cryptation 2008*/";
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 (substr 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);
//Removal of 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. ")); \ N/*reverse engineering is illegal and Strictly prohibited-(C) grass name cryptation 2008*/";
return file_put_contents ($filename, $encode);
}
}
return false;
}
//Call function
$filename = ' G:\ my document \ Desktop \test.php ';
encode_file_contents ($filename);
?>
Compression decoding (decryption) code:
Copy Code code as follows:
<?php
$Code = ' Fill in the code to be decrypted here '; Base64 Code
$File = ' test.php ';//After decoding the saved file
$Temp = Base64_decode ($Code);
$temp = Gzinflate ($Temp);
$FP = fopen ($File, "w");
Fwrite ($FP, $temp);
Fclose ($FP);
echo "Decryption successful! ";
?>