Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Obfuscators will run for cover now... by turnstep
in thread Obfuscators will run for cover now... by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2020-11-28 11:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?