Home >> Snippet List >> Snippet

Base 64 Decode
I recently ran across a freeware web application written in PHP that utilized the following method to encrypt its source code You can decode the encoded script with this PHP snippet
PHP Snippet
// sample is encoded like this:
// eval(gzinflate(base64_decode('encoded text'))); 
ECHO "\nDECODE nested eval(gzinflate()) by DEBO Jurgen <jurgen@person.be>\n\n";
ECHO "1. Reading coded.txt\n";
$fp1 = FOPEN ("coded.txt", "r");
$contents = FREAD ($fp1, FILESIZE ("coded.txt"));
ECHO "2. Decoding\n";
WHILE (PREG_MATCH("/eval\(gzinflate/",$contents)) {
$contents=PREG_REPLACE("/< \?|\?>/", "", $contents);
EVAL(PREG_REPLACE("/eval/", "\$contents=", $contents));
ECHO "3. Writing decoded.txt\n";
$fp2 = FOPEN("decoded.txt","w");
FWRITE($fp2, TRIM($contents));
1.) Save the code you wish to decode in coded.txt
2.) Save the above PHP snippet in file like decrypt.php
3.) Create an empty text file called decoded.txt and it CHMOD it to 0666.
4.) Run decrypt.php and open up decoded.txt to view the source code.