The file that has been compressed and encoded (encrypted) by base64+gzinflate is usually a PHP file with the header ) Code:
Copy code The code is as follows:
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 it is writable, it will be compressed and encoded
$contents = file_get_contents($filename);// Determine whether the file has been encoded
$pos = strpos($contents,'/*Protected by 草名 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 header and tail identifiers
$headerPos = strpos($contents,' php');
$footerPos = strrpos($contents,'?>');
$contents = substr($contents,$headerPos+5,$footerPos-$headerPos);
$encode = base64_encode(gzdeflate($ contents));//Start encoding
$encode = '";
return file_put_contents($filename,$encode);
}
}
return false;
}
//Call function
$filename='g:My Document Desktop test.php';
encode_file_contents($filename);
?>
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 If it can be written, it will be compressed and encoded
$contents = file_get_contents($filename);// Determine whether the file has been encoded
$pos = strpos($contents,'/*Protected by 草名 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 Header and trailer identifier
$headerPos = strpos($contents,'$footerPos = strrpos($contents,'?>');
$contents = substr($contents,$headerPos+ 5,$footerPos-$headerPos);
$encode = base64_encode(gzdeflate($contents));//Start encoding
$encode = '";
return file_put_contents($filename,$encode);
}
}
return false;
}
//Call function
$filename='g:My Document Desktop test.php';
encode_file_contents($filename);
? >
Copy code The code is as follows:
$Code = 'Fill in the encoding to be decrypted here'; // base64 encoding
$File = 'test.php'; //File saved after decoding
$Temp = base64_decode($Code);
$temp = gzinflate($Temp);
$FP = fopen($File,"w");
fwrite ($FP,$temp);
fclose($FP);
echo "Decryption successful! ";
?>