Base64 + gzinflate compressed (encrypted) files are usually <? Eval (gzinflate (base64_decode (a PHP file in the header. The following provides the relevant encoding and decoding (encryption and decryption) code.
Compression (encryption) code: Copy codeThe Code is as follows: <? Php
Function encode_file_contents ($ filename ){
$ Type = strtolower (substr (strrchr ($ filename, '.'), 1 ));
If ('php' = $ type & is_file ($ filename) & is_writable ($ filename) {// compress the Code if the php file is writable.
$ Contents = file_get_contents ($ filename); // checks whether 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 white spaces to reduce File Size
$ Contents = php_strip_whitespace ($ filename );
// Remove the 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 = '<? Php '. "/* Protected by grass name http://www.crazyi.cn Cryptation */\ n eval (gzinflate (base64_decode (". $ encode. "); \ n/* Reverse engineering is illegal and strictly prohibited-(C) Grass name Cryptation 2008 */\ n?> ";
Return file_put_contents ($ filename, $ encode );
}
}
Return false;
}
// Call a function
$ Filename = 'G: \ My Documents \ 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) {// compress the Code if the php file is writable.
$ Contents = file_get_contents ($ filename); // checks whether 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 white spaces to reduce File Size
$ Contents = php_strip_whitespace ($ filename );
// Remove the 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 = '<? Php '. "/* Protected by grass name http://www.crazyi.cn Cryptation */\ n eval (gzinflate (base64_decode (". $ encode. "); \ n/* Reverse engineering is illegal and strictly prohibited-(C) Grass name Cryptation 2008 */\ n?> ";
Return file_put_contents ($ filename, $ encode );
}
}
Return false;
}
// Call a function
$ Filename = 'G: \ My Documents \ Desktop \ test. php ';
Encode_file_contents ($ filename );
?>
Compression/decoding (decryption) code: Copy codeThe Code is as follows: <? Php
$ Code = 'Enter the decryption encoding here '; // base64 encoding
$ File = 'test. php'; // decoded File
$ Temp = base64_decode ($ Code );
$ Temp = gzinflate ($ Temp );
$ FP = fopen ($ File, "w ");
Fwrite ($ FP, $ temp );
Fclose ($ FP );
Echo "decrypted! ";
?>