Skip to content

Instantly share code, notes, and snippets.

@mando
Created November 12, 2010 04:05
Show Gist options
  • Save mando/673711 to your computer and use it in GitHub Desktop.
Save mando/673711 to your computer and use it in GitHub Desktop.
def obfuscate (str, passes)
while passes > 0
lines = str.split()
percent = Random.new.rand(15..20)
line_count = int(percent / lines.length)
lines_end = lines.length - line_count
line_num = Random.new.rand(1..lines_end)
lbegin = line_num
uend = line_num + line_count
until line_num = lines_end
newlines.push(lines[line_num])
++line_num
end
startlabel = "open_" + passes
endlabel = "close_" + passes
lines.push(endlabel + ":")
newlines.each do |entry|
lines.push(entry)
end
lines.push("jmp " + startlabel)
lines[lbegin] = "jmp " + endlabel;
++lbegin
lines[lbegin] = startlabel + ":"
++lbegin
lines.slice(lbegin..uend)
--passes
lines.each do |e|
nstr = e + "\n"
end
obfuscate(nstr, passes)
end
return nstr
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment