Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: clean output from Deobfucation

by eyepopslikeamosquito (Bishop)
on Sep 21, 2010 at 08:08 UTC ( #861025=note: print w/replies, xml ) Need Help??


in reply to clean output from Deobfucation

To give a specific example, this Acme::EyeDrops'ed program prints 99 bottles of beer:

''=~( '(?{' .('`' |'%') .('[' ^ +'-') .('`' |'!') .('`' |',') .'"'. ' +\\$' .'==' .('[' ^'+') .('`' |'/') . +('[' ^'+') .'||' .(';' &'=') .(';' & +'=') .';-' .'-'. '\\$' .'=;' .('[' ^ +'(') .('[' ^'.') .('`' |'"') .('!' ^ +'+') .'_\\{' .'(\\$' .';=('. '\\$=|' ."\|".( '` +'^'.' ).(('`')| '/').').' .'\\"'.+( '{'^'['). ('`'|'"') .(' +`'|'/' ).('['^'/') .('['^'/'). ('`'|',').( '`'|('%')). '\\".\\"'.( '['^ +('(')). '\\"'.('['^ '#').'!!--' .'\\$=.\\"' .('{'^'['). ('`'|'/').( '`'| +"\&").( '{'^"\[").( '`'|"\"").( '`'|"\%").( '`'|"\%").( '['^(')')). '\\" +).\\"'. ('{'^'[').( '`'|"\/").( '`'|"\.").( '{'^"\[").( '['^"\/").( '`'| +"\(").( '`'|"\%").( '{'^"\[").( '['^"\,").( '`'|"\!").( '`'|"\,").( '`'| +(',')). '\\"\\}'.+( '['^"\+").( '['^"\)").( '`'|"\)").( '`'|"\.").( '['^ +('/')). '+_,\\",'.( '{'^('[')). ('\\$;!').( '!'^"\+").( '{'^"\/").( '`'| +"\!").( '`'|"\+").( '`'|"\%").( '{'^"\[").( '`'|"\/").( '`'|"\.").( '`'| +"\%").( '{'^"\[").( '`'|"\$").( '`'|"\/").( '['^"\,").( '`'|('.')). ','. +(('{')^ '[').("\["^ '+').("\`"| '!').("\["^ '(').("\["^ '(').("\{"^ '[') +.("\`"| ')').("\["^ '/').("\{"^ '[').("\`"| '!').("\["^ ')').("\`"| '/') +.("\["^ '.').("\`"| '.').("\`"| '$')."\,".( '!'^('+')). '\\",_,\\"' .'!' +.("\!"^ '+').("\!"^ '+').'\\"'. ('['^',').( '`'|"\(").( '`'|"\)").( '`'| +"\,").( '`'|('%')). '++\\$="})' );$:=('.')^ '~';$~='@'| '(';$^=')'^ '['; +$/='`';
Running the above code through perl -MO=Deparse produces:
'' =~ /(?{eval"\$==pop||99;--\$=;sub\n_\{(\$;=(\$=||No).\" bottle\".\" +s\"x!!--\$=.\" of beer\").\" on the wall\"\}print+_,\", \$;!\nTake on +e down, pass it around,\n\",_,\"!\n\n\"while++\$="})/; $: = 'P'; $~ = 'h'; $^ = 'r'; $/ = '`';
The last four lines above ($: = 'P';...) match your posted code and are just harmless "filler" code, setting a variety of Perl special variables to random values after the eval has already been executed. This filler code is meant to be a "no-op"; its only (cosmetic) purpose is to fully fill all the beer bottles with code. If you don't want the filler code to be inserted, you can set the Acme::EyeDrops FillerVar attribute to '' (see the documentation of FillerVar in the Acme::EyeDrops documentation for the gory details).

If you squint, you'll notice that -MO=Deparse has deparsed the original:

$:=('.')^ '~';
to:
$: = 'P';
which is helpful and all that you'll get from Deparse.

Update: You could manually do what Corion suggested by editing the Deparse output, just changing eval to print like so:

'' =~ /(?{print"\$==pop||99;--\$=;sub\n_\{(\$;=(\$=||No).\" bottle\".\ +"s\"x!!--\$=.\" of beer\").\" on the wall\"\}print+_,\", \$;!\nTake o +ne down, pass it around,\n\",_,\"!\n\n\"while++\$="})/; $: = 'P'; $~ = 'h'; $^ = 'r'; $/ = '`';
Running this produces the original source, without the annoying escapes:
$==pop||99;--$=;sub _{($;=($=||No)." bottle"."s"x!!--$=." of beer")." on the wall"}print+_ +,", $;! Take one down, pass it around, ",_,"! "while++$=

Replies are listed 'Best First'.
Re^2: clean output from Deobfucation
by Anonymous Monk on Sep 21, 2010 at 09:12 UTC

    thats very good idea to change eval -> print
    But there are two of them evals.( for safekeeping the regexs that may get corrupt in EyeDrop tranform)

    I removed one and changed one to print and again :) we get exact line by line code that exactly the same as source ..

    !!! Million Thanks !!!

      I know it has been a year since last post, but this article just saved my life. Thank you wise monks!!!!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2021-06-19 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (92 votes). Check out past polls.

    Notices?