hoodwink.d enhanced


Cleaned in a Gross Way #

by why in inspect

Florian Groß is disassembling and analyzing the obfuscated Ruby contest winners! No one can object to this.

His shovelings through James Edward Grey II’s Ruby Quiz Loader is great. He spots:

 while $_ =~ /([^\n]{81,})/:
   z = $1.dup;
   f = $1.dup;
   f[f.rindex(" ", 80), 1] = "\n";
   f.sub!(/\n[ \t]+/, "\n");
   sub!(/#{Regexp.escape(z)}/, f)

This is fairly nice code for rewrapping lines longer than 80 characters.

The while uses a regexp to iterate over all pieces of text that contain no newlines for more than 80 characters. (By the way, Jamis could have used ~regexp here as that will apply the regexp to $_ as well.) Note the colon at the end of the while — this is legal Ruby and confused the highlighter and made reformating the code quite hard…

 "re#{q[5...8].downcase}re '111112101110-117114105'.scan(/-|\\d{3}/).
 inject(''){|m,v|v.length>1?m+v.to_i.chr: m+v}");

First of all, this piece of code depends on the order that methods will be returned by Object#methods and I think that that order is not guaranteed to be stable — as far as I know it might basically change depending on lots of factors. That aside, this will currently be equival to send(“eval”, ...).


I especially enjoyed this one. What an exciting way of exiting!

Well done on the syntax highlighting and progressive refactorings, flgr. (Seen on Anarchaia.)

said on 10 May 2005 at 09:12

Thank you for the kind mention. I wonder if Ryan Leavengood will publish his work so that the deobfuscation can be completed.

said on 10 May 2005 at 11:04

Hey _why, I think you meant ‘James’, instead of ‘Jamis’.

Yea, definitely cool stuff. Just shows how much you can learn from an obfuscated contest. Take that Ruby purists!

said on 10 May 2005 at 13:45

My last name is spelled wrong as well. :(

Seriously, thanks for the mention. It was fun and Florian did a great job with the analysis.

Comments are closed for this entry.