On PHP “Encryptions”
Alright, so I’ve gotten (relatively) a lot of attention for my post(s) (mainly this one) about “decrypting” PHP scripts that are engulfed in various combinations of gzinflate();, str_rot13();, and base64_decode();.
This post is mostly an attempt to enlighten those that come upon it to what these functions are and do, and probably more importantly, how to undo their secretive evil.
(more…)
Decrypt nested eval gzinflate str_rot13 base64_decode
So I went ahead and wrote a script to undo massively nested eval(gzinflate(str_rot13(base64_decode(‘STRING’)))); and eval(gzinflate(base64_decode(‘STRING’))); “encryptions” with a multitude of both of them inside it. The string from the original footer here had to go through 67 different iterations before it got to the real source code (talk about overkill).
If you have strings that aren’t nested, you can probably just do this:
$string = htmlentities($string, ENT_NOQUOTES);
echo $string;
If you have a string from that fits that description you can decrypt it here
Or if you just want to test it here’s the original string from the footer of this one of my old themes:
Annoying Coding Methods (solved)
So I finally figured out how to decrypt the insanity of the footer for this theme.
To see what I started out with see the first post –> Annyoing Coding Methods
Simply changing the eval() to echo just printed out a ?> because I found out the first thing in the code was a ?>, so it ended the PHP tag and simply printed out the ending ?> tag.
So… I decided to remove all PHP tags… like <?php <? and ?> with:
<?php
$remove = array(">","<");
$replace = array(">","<");
$string = 'FREAKISHLY LONG ENCRYPTED STRING HERE';
echo str_replace($remove,$replace,gzinflate(str_rot13(base64_decode($string))));
# echo str_replace($remove,$replace,gzinflate(base64_decode($string)));<br />
?>
So that worked liked I hoped it would, BUT it prints out nearly the exact same thing I had to begin with, just with another random string. So I keep replacing cryptic code in the $string variable over and over. The output varied from eval(gzinflate(str_rot13(base64_decode($string)))); to eval(gzinflate(base64_decode($string))); Hence the extra (commented) line in the above code. I probably repeated this method at least 50 times until I actually saw the real source code. (And yes, after doing that I realize that I could have just written a little code to loop through it, but I had no idea how many iterations it would take)
The string of data got smaller and smaller each time. The last string before the real code is only about a fifth of the length of the original:
I repeated the workflow one more time and was excited to see real code!
endif; ?>