By Peter Cooper / May 26, 2006
For the fun of it, I developed a quick Ruby obfuscation tool a few weeks ago. It’s not a proper obfuscater that changes variable names and such, but it’ll keep your code from being immediately understood. Here’s the library, px.rb:
class PX; def self.method_missing(m, *args); m = m.to_s; eval $c.join if m == ‘-@’; m.scan(/(\w)(\w)/).each { |t| ($c ||= []) << (((t[0][0] – 97) * 26) + (t[1][0] – 97)).chr }; end; end
And here’s a demonstration program, using the px.rb decoder, that displays some text on the screen:
require ‘px’ PX.bxbwbuemebefdxelbgdwehakeienemelbgbndjdxeedvehefdxbgemehbgdudtdwbgdeenduerbg PX.ehdudyeneldvdtemebehegbhbnakdxegdwak -PX
Pretty incomprehensible, right? Here’s a program that will help you create your own encoded / obfuscated Ruby scripts called pxcode.rb:
require ‘px’ PX.eienemelbgbiekdxejenebekdxbgbneieqbnbiakdueebgcjbgdndpakebbgcjbgbwakbkelemdw PX.ebegbudxdtdveabgetbgeueeebegdxeuakeeebegdxbuelendubhbobvdqdoelbrbvbsbgbnbnbp PX.akeeebegdxbudxdtdveadrdueremdxbgetbgeudueuakdubgcjbgdubuemehdrebakebbgbrcjbg PX.bxbgebdybgdueednebdpbgbmbmbgdueednebdpbueedxegdzemeabgckbgcdcbakdueednebdpbg PX.eueucjbgbnbnakdueednebdpbgbrcjbgbodubgbvbgbyccbgbrbgcfcdbpbudveaekbgbrbgbodu PX.bgblbgbyccbgbrbgcfcdbpbudveaekakevakevakdueebudxdtdveabgetbgeueeeuakeienemel PX.bgbidcdkbubjeteeevbiakevakeienemelbgbibtdcdkbi -PX
To use it, you’ll run.. Read More