in reply to Huffman once again
Anyway, jynx was kind enogh to msg me with some much needed hints. Well, a conversation started on our scratchpads. With jynx's permission I'll now repost it, with each turn in a new reply. But we'll start with jynx's initial response.
Notice also i took out the 'use integer' statement and the initialization of variables since they're unnecessary. Since Perl will complain about uninitialized values i also took off the -w. For testing purposes it's useful to keep such things in, but removing unnecessary things also removes extra clues for the reader :-)#!/usr/bin/perl @t=("12","34","56","7 ","89",":h","er",";k","<t","=a","lc","ju","sn"," +op"); @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $n=$i++%8?$n:ord shift@m; $x=ord substr$t[$p],($n&128)>>7,1; $p=($x&240)==48?$x&15:0; !$p&&print chr$x; $n<<=1; }until($i==91);
Next we can take out variables that are only used once and remove instances where conditions overlap. In particular to this obfu, if $p is zero, we print. But on the previous line we just set it to zero. We can combine the two statements and use print's return value effectively here. The following is an iterative process of combining overlapping statements and reducing variables:
It's now just a block of code with little whitespace that readers must attempt to swallow all at once. It still uses too many parentheses unfortunately, but Perl would have problems parsing correctly without them.# 1 # collapse printing into the $p assignment @t=("12","34","56","7 ","89",":h","er",";k","<t","=a","lc","ju","sn"," +op"); @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $n=$i++%8?$n:ord shift@m; $x=ord substr$t[$p],($n&128)>>7,1; $p=($x&240)==48?$x&15:-1+print chr$x; $n<<=1; }until($i==91); # 2 # Collapse the $x assignment into the $p assignment @t=("12","34","56","7 ","89",":h","er",";k","<t","=a","lc","ju","sn"," +op"); @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $n=$i++%8?$n:ord shift@m; $p=(($x=ord substr$t[$p],($n&128)>>7,1)&240)==48?$x&15:-1+print chr$ +x; $n<<=1; }until($i==91); #3 # Collapse the $n assignment into the $x assignment @t=("12","34","56","7 ","89",":h","er",";k","<t","=a","lc","ju","sn"," +op"); @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $p=(($x=ord substr$t[$p],(($n=$i++%8?$n:ord shift@m) &128)>>7,1)&240)==48?$x&15:-1+print chr$x;$n<<=1; }until($i==91); #4 # Remove @t and replace it with a constant list @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $p=(($x=ord substr("12","34","56","7 ","89",":h","er",";k","<t","=a" +,"lc","ju","sn","op") [$p],(($n=$i++%8?$n:ord shift@m) &128)>>7,1)&240)==48?$x&15:-1+print chr$x;$n<<=1; }until($i==91); #5 # condense the previous @t, removing quotes to save space @m=split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0"; do{ $p=(($x=ord substr+(split/,/,'12,34,56,7 ,89,:h,er,;k,<t,=a,lc,ju,sn +,op') [$p],(($n=$i++%8?$n:ord shift@m)&128)>>7,1)&240)==48? $x&15:-1+print chr$x;$n<<=1; }until($i==91); #6 # Remove @m, replacing it with a constant list # This requires a smaller variable for the 'shift' effect... do{ $p=(($x=ord substr+(split/,/,'12,34,56,7 ,89,:h,er,;k,<t,=a,lc,ju,sn +,op') [$p],(($n=$i++%8?$n:ord ((split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0")[$.++ +]) )&128)>>7,1)&240)==48?$x&15:-1+print chr$x;$n<<=1; }until($i==91); #7 # Change all the variables to 'strict compliant' ones... # Remove extra semi-colons and parentheses... do{$a=(($_=ord substr+(split/,/,'12,34,56,7 ,89,:h,er,;k,<t,=a,lc,ju,s +n,op')[ $a],(($b=$;++%8?$b:ord ((split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x06\xbc\x8e\xe0")[$.++]) +) &128)>>7,1)&240)==48?$_&15:-1+print chr;$b<<=1}until$;==91 #8 (final version) # Split up the previous @m for allignment issues do{$a=(($_=ord substr+(split/,/,'12,34,56,7 ,89,:h,er,;k,<t,=a,lc,ju,s +n,op')[ $a],(($b=$;++%8?$b:ord((split/ */,"\x00\x50\xA5\xd2\xc5\xbb\x96\xef\x0 +6\xbc". "\x8e\xe0")[$.++]))&128)>>7,1)&240)==48?$_&15:-1+print chr;$b<<=1}unti +l$;==91
Anyway, that's the process i went through after running your japh. While i'm not the best at obfu, hopefully this will help a little...
nuf evah,
jynx
1NOTE: i usually format to 60 places for monastery reasons, but sometimes, particularly in cases of obfus, i format to 80 characters, which is standard terminal width. Because of this i must appologize for the random red +'s everywhere (i've set my page preferences to wider than 60 chars to accomodate this 80 char fetish :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Huffman once again
by fsn (Friar) on Jul 17, 2002 at 20:06 UTC | |
by fsn (Friar) on Jul 17, 2002 at 20:16 UTC |