|We don't bite newbies here... much|
Re: With apologies to J.R.R (explained)by sevensven (Pilgrim)
|on Nov 06, 2001 at 05:52 UTC||Need Help??|
Roger on that obfu working. And it is a "precioussssss" obfu, if I may say so. Thanks for the fun and for making me remeber "my precioussss", maverick.
I dont know if it's good PM etiquete to discuss the functioning of an obfu, but that's the fun of it, so here it goes a first look into it Warning, spoiler ahead:
The main code is inside the first interpolation q. That code goes into the @d array, wich is reordered in the for at the bottom
This reorders all that code in @d, swapping every third line with the one that has the same index if you started counting from the end of the @d
So, doing the swap we get the code that will be run, wich I formated for your viewing pleasure :
It now looks much better, but the thing is, now it's realy getting harder.
Maverick used the sub d, with an array called d passed by reference and that gets changed in there, adding a new level to this obfuing (am I coining a term here ? ;^).The recursive call to sub d inside almost made me croak ;-)
OK, the main idea is that the binary string in $m (later splited into an array with each of its characters in @d) will be used in sub d to choose wich of the sub-arrays and elements of $h will be used.
Zeros make the array get shifted, ones means that that particular sub array will be used. The shifting occurs in the recursive call to d.
Each time a element of the array is reached (i.e. a character), as it's not a reference to an array, it will get printed (in upper case depending on a flag set by the _ in the control stream (er, $m), with some more caracters provided by %h.
This was a very nice use of recursion, passing arrays by ref, acessing arrays inside arrays of an array passed by reference, interpolation, eval, etc.
Until today, I wondered why people did obfuscation. It seamed just a way to use the worst of perl, the most arcane syntax and realy, just a bad thing to throw at people who are trying to grasp the elementary stuff in perl.
Well, i can now see *two* good motives for doing it,
Thanks again to maverick and to all obfuers in general :-)