Category: >> PHP Code >> Base 64 Decode Bookmark and Share

<< lastnext >>

Snippet Name: Base 64 Decode

Description: 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.

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: February 28th, 2009

// sample is encoded like this:
// eval(gzinflate(base64_decode('encoded text'))); 
echo "\nDECODE nested eval(gzinflate()) by DEBO Jurgen <>\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.
Add a comment 
JoeNov 27th, 2010 12:46pm
Very tricky!
© | users online: 5