in reply to eval from heck

This japh made me curious, so well.. i just couldn't resist breaking it apart..

!!! SPOILER !!!

Breaking the Japh up, we get:

$J=qw,34+40;117;79+36;(116);32;,; $s=sub{eval(shift())};#This is my eval @u=('a'..'z'); $J.=qw:97;110;111;(116-0);104;101;114;(16*2);:;#from hell $s=sub{eval(shift())}; $J.=qw:;112;101;114;108;32:;#JAPH. It isn't very $t=sub{ my@e=@u; my$u=16; $t_=sub{"$e[$u+2]$e[$u]$e[++$u]$e[++$u+1] $_[0]"}; &$s(&$t_(shift())) }; $e=sub{ $t_=sub{"$u[&$t(4)]$u[7]$u[17] $_[0]"};#ha- &$s(&$t_(shift())); }; $J.=qw:;104;97;99;107;101;114:; $f=sub{ $t_=sub {"$u[15]$u[17]$u[8]$u[13]$u[19]($_[0])"}; &$s(&$t_(shift())); };#to figu- $_=$g+=$s; $g=sub{ $t_=sub{"$u[5]$u[14]$u[17](@_)"}; &$s(&$t_(eval@_)); }; print (&$e(&$s($_)))for(split(/;/,$J)); print "\n";#-re out at all;-)

-------------------------------------------

Now let's put everything where it belongs:

$s=sub{eval(shift())}; this was defined twice. The arguments passed to $s end up in @_ from which the first argument is taken off by the shift()-function in eval(shift()) which results in evaluating the first argument passed to $s.

$J is assigned to 4 times, last 3 are concatenations. In between the assignments $J doesn't chang, so now in 1 assignment:

$J="34+40;117;79+36;(116);32;97;110;111;(116-0);104;101;114;(16*2);112;101;114;108;32;104;97;99;107;101;114";

When we simplify $t=sub { } we get

  1. $t=sub { s q r t $t_=sub{"$e[18]$e[$16]$e[17]$e[19] $_[0]"}; + &$s(&$t_(shift())) }
  2. $t=sub { $t_="sqrt $_[0]"; &$s( $t_ ) }
  3. $t=sub { sqrt $_[0]; } # &$s merely evaluates the string

Doing the same to $e=sub { } we get:

  1. &$t(4) is the same as sqrt(4).
    $e=sub{ c h r $t_=sub{"$u[&$t(4)]$u[7]$u[17] $_[0]"};#ha- &$s(&$t_(shift())); };
  2. $e=sub { chr($_[0] ) };

The function $f is never called, nor is the function $g.
$_=$g+=$s; is meaningless, as the $_ isn't being used until after it's been reassigned something else.

Now we are down to the last 2 lines print (&$e(&$s($_)))for(split(/;/,$J)); is equivalent to:

for ( split(/;/,$J) ) { print ($&e(&$s($_)); }

As the function $e got simplified to chr( $_[0] ) and the $s function does an evaluate on its string, we can write the print line as print chr(eval($_));

The elements in $J sometimes need to be parsed for chr to understand them. As eval and subroutines return the result of the last expression evaluated to the caller, the eval can be removed by simplifying $J to @J. ( I simplified the string, but also changed it to an array to remove the split in the for loop).

The Japh then comes down to:

@J =( 74,117,115,116,32,97,110,111,116,104,101,114,32,112,101,114,108, +32,104,97,99,107,101,114); for ( @J ) { print chr( $_ ); } print "\n";

For those reading the spoiler: I would appreciate feedback to it.

Replies are listed 'Best First'.
Re: Re: eval from heck
by krisahoch (Deacon) on Aug 10, 2003 at 20:30 UTC

    deliria,

    Well done! The second definition of $s was merely to throw a person off. Good job on the deobfuscation. You will get a ++ when I get more votes tomorrow.

    Kristofer Hoch

    Si vos can lego is, vos es super erudio