|
B::Deobfuscate - Deobfuscate source code |
B::Deobfuscate - Deobfuscate source code
perl -MO=Deobfuscate,-csynthetic.yml,-y synthetic.pl
B::Deobfuscate is a backend module for the Perl compiler that generates perl source code, based on the internal compiled structure that perl itself creates after parsing a program. It adds symbol renaming functions to the the B::Deparse manpage module. An obfuscated program is already parsed and interpreted correctly by the the B::Deparse manpage program. Unfortunately, if the obfuscation involved variable renaming then the resulting program also has obfuscated symbols.
This module takes the last step and fixes names like $z5223ed336 to be a word from a dictionary. While the name still isn't meaningful it is at least easier to distinguish and read. Here are two examples - one from the B::Deparse manpage and one from B::Deobfuscate.
Initial input
if(@z6a703c020a){(my($z5a5fa8125d,$zcc158ad3e0)=File::Temp::tempfile(
'UNLINK',1));print($z5a5fa8125d "=over 8\n\n");(print($z5a5fa8125d
@z6a703c020a)or die(((("Can't print $zcc158ad3e0: $!"))); print($z5a5fa8125d
"=back\n");(close(*$z5a5fa8125d)or die(((("Can't close ".*$za5fa8125d.": $!")
));(@z8374cc586e=$zcc158ad3e0);($z9e5935eea4=1);}
After the B::Deparse manpage:
if (@z6a703c020a) {
(my($z5a5fa8125d, $zcc158ad3e0) = File::Temp::tempfile('UNLINK', 1));
print($z5a5fa8125d "=over 8\n\n");
(print($z5a5fa8125d @z6a703c020a)
or die((((q[Can't print ] . $zcc158ad3e0) . ': ') . $!)));
print($z5a5fa8125d "=back\n");
(close(*$z5a5fa8125d)
or die((((q[Can't close ] . *$za5fa8125d) . ': ' . $!)));
(@z8374cc586e = $zcc158ad3e0);
($z9e5935eea4 = 1);
}
After B::Deobfuscate:
if (@parenthesises) {
(my($scrupulousity, $postprocesser) = File::Temp::tempfile('UNLINK', 1));
print($scrupulousity "=over 8\n\n");
(print($scrupulousity @parenthesises)
or die((((q[Can't print ] . $postprocesser) . ': ') . $!)));
print($scrupulousity "=back\n");
(close(*$scrupulousity)
or die((((q[Can't close ] . *$postprocesser) . ': ') . $!)));
(@interruptable = $postprocesser);
($propagandaist = 1);
}
You'll note that the only real difference is that instead of variable names like $z9e5935eea4 you get $propagandist.
As with all compiler backend options, these must follow directly after the '-MO=Deobfuscate', separated by a comma but not any white space. All options defined in B::Deparse are supported here - see the B::Deparse documentation page to see what options are provided and how to use them.
-d/usr/share/dict/stop
-D... parameter.
B::Deobfuscate 0.14 and above is distributed with the additional dictionary B::Deobfuscate::Dict::Flowers.
-a/\A[[:lower:][:digit:]_]+\z/
The intention here is that you could write some software to read this the YAML manpage document, present the information to the user, accept some alterations to the configuration and re-run the deobfuscator with the new input.
The B::Deobfuscation symbol renamer can be controlled with by a configuration file. Use of this feature requires the the YAML manpage module be installed.
dictionary: '/usr/share/dict/propernames' global_regex: '(?:)' globals: kSDsfDS: Slartibartfast HGFdsfds: Triantaphyllos lexicals: '$SdfSd': '$No' '$GsdDd': '$Ed' '$Ksdfs': '$Ji'
dictionary: /usr/share/dict/stop
global_regex: '\A[[:lower:][:digit:]_]\z'
If you wish to prevent B::Deobfuscate from renaming a symbol then specify the new value as '~' (which in YAML terms is undef).
globals: catfile: ~ opt_n: ~ opt_t: ~ opt_u: ~ z1234567890: Postprocesser z2345678901: Constructable z3456789012: Photosynthesises z4567890123: Undiscriminate z5678901234: Parenthesises z6789012345: Animadvertion
lexicals: '$k1234567890': '$ivs' '$k2345678901': '$ehs' '$k3456789012': '$ans' '$k4567890123': '$ons' '$k5678901234': '$ofs' '$k6789012345': '$gos' '$k7890123456': '$dus' '$k8901234567': '$iis' '$k9012345678': '$ats' '$k0123456780': '$ets'
Joshua ben Jore <jjore@cpan.org>
the B::Deparse manpage http://www.perlmonks.org/index.pl http://www.perlmonks.org/index.pl the YAML manpage
|
B::Deobfuscate - Deobfuscate source code |