Skip to content

Instantly share code, notes, and snippets.

@davestevens
Created April 15, 2011 16:04
Show Gist options
  • Save davestevens/921949 to your computer and use it in GitHub Desktop.
Save davestevens/921949 to your computer and use it in GitHub Desktop.
Quick way to mangle variable names in a Perl script
#!/usr/bin/perl
# run with;
# perl perlObf.pl inputFile.pl > outpuFile.pl
use Digest::MD5 qw(md5_hex);
while( <> ) {
while(/([\$\%\@]#?)([A-Za-z]\w+)/gm) {
if($2 ne 'ARGV') {
$current = '\\'.$1.$2; $new = $1.'_'.md5_hex($2);
s/$current/$new/;
}
}
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment