Sha256: d47cc49eee206dbbc690b9f68ecd18e6dc395ee49c94206a867f80355d9d6d15

Contents?: true

Size: 937 Bytes

Versions: 9

Compression:

Stored size: 937 Bytes

Contents

# A code obfuscator for Ruby.  It works by getting a dump of the node
# tree, then wrapping it with a lightweight loader.
#
# NOTE: This code is for demonstration purposes only!  It has not been
# extensively tested, and I cannot guarantee that it works in all cases
# (I don't even know what the corner cases are).  If you wish to use
# this in a commercial product, please verify that the code is correctly
# loaded.
#
# Usage:
#
#   $ cat test.rb
#   def foo
#     1+1
#   end
#   
#   puts foo()
#
#   $ ruby -rinternal/obfusc test.rb > test2.rb
#   $ ruby test2.rb
#   2

require 'internal/node/obfusc'

begin_nodes = []
set_trace_func proc {
  n = $ruby_eval_tree
  if defined?($ruby_eval_tree_begin) and $ruby_eval_tree_begin then
    n.pretty_print($stderr)
    begin_nodes << $ruby_eval_tree_begin
  end
  if n then
    # TODO: Do I need to include ruby_dyna_vars?
    str = n.obfusc(begin_nodes)
    puts str
    exit
  end
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-internal-0.8.5 lib/internal/obfusc.rb
ruby-internal-0.8.4 lib/internal/obfusc.rb
ruby-internal-0.8.3 lib/internal/obfusc.rb
ruby-internal-0.8.2 lib/internal/obfusc.rb
ruby-internal-0.8.1 lib/internal/obfusc.rb
ruby-internal-0.8.0 lib/internal/obfusc.rb
ruby-internal-0.7.3 lib/internal/obfusc.rb
ruby-internal-0.7.2 lib/internal/obfusc.rb
ruby-internal-0.7.1 lib/internal/obfusc.rb