Obfuscated Ruby Code...

Started by
3 comments, last by GnuVince 18 years, 9 months ago
Is it true that ruby can be obfuscated? o_O Also, is it possible to pack image files, and sound files, and other files all into 1 file, but still be able to run the code? Thanks.
Advertisement
For your second question, you can do that with resources in EXEs (under Windows) and possibly with Makeself (under Unix), although I have yet to test my theory.

As for your first question, I suspect Ruby's syntax is too clean to allow advanced obfuscation like you can get with C and Perl...

Cheers!
- fyhuang [ site ]
The most obfuscated I could get with it is the following:

index.puts("[blist"+(`ls #$wikidir/pages`.grep(/^#{letter}/).\ map{|s|s.chomp.gsub(/\.\d+$/,'')}.uniq+File.read("#$wikidir/gend").\ grep(/^#{letter}/).map{|s|s.gsub(/:.*/,'')}).sort.\ map{|el| "[item #{el}]"}.join+']')

I have an 8 line comment to explain to myself what it does.
Probably not nearly as obfuscated, as fyhuang said, as C or perl could get.

edit: wrote code instead of source
edit 2: it ate my backslashes
edit 3: removed the source tag to try to get it to stop eating the backslash newlines
edit 4: double the backslashes. If this doesn't work, at least I tried.
Yes. Ruby isn't nearly as evil as C or Perl when it comes to obfuscation.

Chris 'coldacid' Charabaruk – Programmer, game designer, writer | twitter

I posted this entry to the IORCC (International Obfsucated Ruby Code Contest):

        d=[30644250780,9003106878,    30636278846,66641217692,4501790980, 671_24_603036,131_61973916,66_606629_920,   30642677916,30643069058];a,s=[],$*[0]      s.each_byte{|b|a<<("%036b"%d[b.         chr.to_i]).scan(/\d{6}/)}          a.transpose.each{ |a|            a.join.each_byte{             |i|print i==49?               ($*[1]||"#")                 :32.chr}                   puts                    }


Obfuscated enough for you? :)

Edit: The board software removed three important back slashes.

This topic is closed to new replies.

Advertisement