beanutils.populate PHP base64+gzinflate compression encoding and decoding code

WBOY
Release: 2016-07-29 08:39:02
Original
1121 people have browsed it

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,'$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);
? >

Compression decoding (decryption) code:

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! ";
?>

The above introduces the beanutils.populate PHP base64+gzinflate compression encoding and decoding code, including the content of beanutils.populate. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!