Don't ask to ask, just ask | |
PerlMonks |
Re: A Simple JAPHby ambrus (Abbot) |
on May 07, 2012 at 21:09 UTC ( [id://969335]=note: print w/replies, xml ) | Need Help?? |
This obfu is nice because it's hard to see at first what it will print. Allow me a few minor comments though. (I'll use spoiler tags to not spoil anything for readers who hasn't decoded the obfu yet.) Firstly, it seems strange to me to see three apparently unnecessary mentions of $_ in a code like this: one after hex, one after chr, and you can remove the $_=~ part from the match too. Is there any reason you have these in the text? Secondly, is there a good reason to spell out the valid characters in the regex as /[A-F0-9]{2}/gi instead of just /../g or /\w\w/g? I could understand using a range like [A-F0-9] if you had extra invalid letters (from [s-z]) in the string that do nothing, but your string has no such letters. Writing [A-F0-9] gives an explicit clue to the reader that you are expecting hexadecimal digits. Is that what you want? Thirdly, the join'', part also seems unnecessary: print will concatenate the characters anyway. Lastly, I prefer if an obfu like this prints a newline after the message. This is not an absolute requirement, but if the obfu is easy to change to do this, then it's better that way. In this case, I think you'd just have to change the end of the long string from "mhge" to "mhgeji". If you think that would make the first line too long, just break the string to two lines. You can do this either by using two string literals like or by leaving whitespace in the string that your regex will skip, such as
For example, after the changes I suggested above, plus some rearrangement to get the right edge of the text to line up again, I get this.
Let me list some specific good points of this obfu too. You're not using unpack"C*",pack"H*",$_ to decode the string of hexadecimals. That would be both longer than the map{hex}/\w./g you're using and easily recognizable for seasoned obfuscation readers. Secondly, you put the -84 constant together with the hex instead of in the $_+$y[-1], thus making its meaning more difficult to see. As your code is now, I first see the -84 term, and don't understand what it's doing until later when I see that the numbers are used as differences which is why you want negative numbers. Thirdly, you wrote the code as separate statements each doing one step of the computation. This seems actually seems to suit this obfu more than a traditional terse style where you'd write everything in one statement, such as as the separate statements put the related operations far away from each other, thus making the code less readable, but still short enough. (Ps. Modifying the above to use the y///r switch thus making the statement even more readable is homework for reader.)
In Section
Obfuscated Code
|
|