|go ahead... be a heretic|
New Huffman Obfusby demerphq (Chancellor)
|on Sep 16, 2001 at 05:11 UTC||Need Help??|
Inspired by BooK's quite excellent obfuscated Huffman Encoder (434 chars on a w32 box), and many hours of my time playing with the algorithm I decided I would make an attempt at my own, and try to shave a characters off of the solution. After quite a bit of effort (this obfus stuff is hard.. ++ to those of you who make it look so easy) getting bitten by binmode, discovering which global variables could be used in exotic ways I wish to present my solutions: (All of the solutions expect input and ouput over STDIN and STDOUT)
My first solution is the equivelent to BooK's original encoder, ie it only encodes the message, without a header containing the information necessary to decode the message. It is 316 characters long (on a w32 box).
My next solution is the same thing but this time with the header information. I call it obfu_enhuff.pl, it is 337 bytes long.
The next is the corresponding decoder, as might be guessed I call it obfu_dehuff.pl, and it is 259 bytes long. The output of the encoder can be piped into this script and the result will be the original file. such as by
perl obfu_enhuff.pl <obfu_enhuff.pl | perl obfu_dehuff.pl
(usage on *nix machines might be little more graceful..)
And for my last trick, I humbly present the combination of the two. This version I call obfu_huff.pl and is 622 bytes long. Like the others it uses STDIN and STDOUT but also takes an argument to determine if it decodes or encodes (no arguments at all).
perl obfu_huff.pl <obfu_huff.pl | perl obfu_huff.pl -d
Many thanks to the Obfu crew and especially BooK for the inspiration and the walk through of his implementation, especially in regard to the use of funky global variables.
BTW, the code is set up for 80 columns, which means if you dont want it split you need to see your wrap code length to be 81 (go figure) in the User Settings to see all of them properly.
Oh and apologies to any who think this is a waste of time as its already been done, for me it was a _great_ exercise (I think that there are imprtant lessons to be learned by doing an obfu), and I'm damn proud of it. (never even looked at BooK's Huffman Decoder!)