Two methods to crack PHPbase64_decode

Source: Internet
Author: User
PHPbase64_decode + gzinflate compression encoding and decoding code PHP is increasingly used in the network, and the topic of encryption and decryption has never been stopped. The following is a brief introduction of base64_decode + gzinflate compression encoding and decoding code, that is, the eval (gzinflate (base64_decode ('encryption code'

PHP base64_decode + gzinflate compression encoding and decoding code

PHP is increasingly used in the network, and the topic of encryption and decryption has never been stopped. The following is a brief introduction of base64_decode + gzinflate compression encoding and decoding code, that is, the eval (gzinflate (base64_decode ('encryption code') that we see in the program); the form of encryption method.
Wangshan has such a method, but some characters are missing, which makes it unusable after encryption. if you are interested, try it and I have made a simple modification on the original basis, no error has been detected by myself.
Note: Do not use Chinese characters or names with spaces as file names during decryption.

Compression (encryption) Code:


Reference content
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, 'Powered by arzn QQ: 100 ');
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 ,' $ 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 a function
$ Filename = 'code. php ';
Encode_file_contents ($ filename );
Echo "OK, encryption complete! "
?>


Compression/decoding (decryption) Code:


Reference content

$ Code = 'Enter the decryption encoding here '; // base64 encoding
$ File = 'decoded. php'; // The decoded File.
$ Temp = base64_decode ($ Code );
$ Temp = gzinflate ($ Temp );
$ FP = fopen ($ File, "w ");
Fwrite ($ FP, $ temp );
Fclose ($ FP );
Echo "decrypted! ";
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.