Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Obfuscators will run for cover now...

by turnstep (Parson)
on May 02, 2001 at 21:42 UTC ( #77435=note: print w/ replies, xml ) Need Help??


in reply to Obfuscators will run for cover now...

Very interesting. Of course, it will break obfuscated scripts that require a certain whitespace alignment, but it does a pretty good job. Here's how it did on one of my shorter ones. First, the original:

open(0,$0);$/=$;;<0>=~m{(ET / /).*(C[^\*]+)}s;$b=$1;($G=$g=$2) =~s/.*(en).*/s$1d(t,/s;$_=join');',S($g),S($g),"$G\"G$b\n\n\", 0","\$/=<t>";substr($_,26,1,'"'.pack("cx2c5x8",2,80,209,85,3, 25).'"');sub S{split(//,shift);$_[3]=chr(ord($_[3])-($*?6:9)); $_[5]=chr(ord($_[5])-($*?11:-6));$_[7]='(t,';if(!$*++){$_[8]= join(',',split(/5?/,(ord($_[10])+104)));$_[2]='c';$_[6]=""; $_[0]='s'}$#_=8;lc join('',@_);}$_=eval;s/.*\r\n//s; s#(<[^>]+>)*(\w{0,2})#"$1<FONT COLOR=".(int rand 999999)."> $2</FONT>"#eg;print;#Content-type

And now, the perltidy version:

open( 0, $0 ); $/ = $;; <0> =~ m{(ET / /).*(C[^\*]+)}s; $b = $1; ( $G = $g = $2 ) =~ s/.*(en).*/s$1d(t,/s; $_ = join ');', S($g), S($g), "$G\"G$b\n\n\", 0", "\$/=<t>"; substr( $_, 26, 1, '"' . pack( "cx2c5x8", 2, 80, 209, 85, 3, 25 ) . '" +' ); sub S { split ( //, shift ); $_[3] = chr( ord( $_[3] ) - ( $* ? 6 : 9 ) ); $_[5] = chr( ord( $_[5] ) - ( $* ? 11 : -6 ) ); $_[7] = '(t,'; if ( !$*++ ) { $_[8] = join ( ',', split ( /5?/, ( ord( $_[10] ) + 104 ) ) ); $_[2] = 'c'; $_[6] = ""; $_[0] = 's'; } $#_ = 8; lc join ( '', @_ ); } $_ = eval; s/.*\r\n//s; s#(<[^>]+>)*(\w{0,2})#"$1<FONT COLOR=".(int rand 999999)."> $2</FONT>"#eg; print; #Content-type

Not bad. I like it. Always meant to write some sort of de-obfuscator myself. This is a good start, the next obvious step would be to have it replace those oft-used global vars with something simpler like $x,$y, etc..


Comment on Re: Obfuscators will run for cover now...
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://77435]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-09-19 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (140 votes), past polls