ruby-internal 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ruby-internal-node-dump +38 -0
- data/bin/ruby-internal-obfuscate +20 -0
- data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.9.0/internal/node/nodeinfo.c +3 -0
- data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +3 -0
- data/ext/internal/node/nodeinfo.c.rpp +3 -0
- data/lib/internal/node/obfusc.rb +25 -0
- data/lib/internal/obfusc.rb +3 -21
- data/pre-setup.rb +1 -0
- data/sample/dump_class.rb +9 -0
- data/sample/irbrc +4 -0
- metadata +10 -4
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
require 'internal/node/pp'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
dash_e = []
|
8
|
+
|
9
|
+
args = ARGV
|
10
|
+
|
11
|
+
opts = OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: #{$0} [switches] [--] [programfile] [arguments]"
|
13
|
+
opts.summary_width = 15
|
14
|
+
opts.summary_indent = ' '
|
15
|
+
|
16
|
+
opts.on(
|
17
|
+
"-e line",
|
18
|
+
"one line of script. Several -e's allowed. Omit [programfile]") do |line|
|
19
|
+
dash_e << line
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.order!(args) do |arg|
|
23
|
+
args.unshift arg
|
24
|
+
opts.terminate
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if dash_e.size > 0 then
|
29
|
+
str = dash_e.join("\n")
|
30
|
+
else
|
31
|
+
filename = ARGV[0]
|
32
|
+
str = File.read(filename)
|
33
|
+
end
|
34
|
+
|
35
|
+
node = Node.compile_string(str)
|
36
|
+
|
37
|
+
pp node
|
38
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'internal/node/obfusc'
|
4
|
+
|
5
|
+
filename = ARGV[0]
|
6
|
+
|
7
|
+
if not filename then
|
8
|
+
puts "Usage: #{$0} <filename>"
|
9
|
+
exit 1
|
10
|
+
fi
|
11
|
+
|
12
|
+
str = File.read(filename)
|
13
|
+
|
14
|
+
node = Node.compile_string(str)
|
15
|
+
|
16
|
+
# TODO: Should the whole program be obfuscated or just this module?
|
17
|
+
str = node.obfusc()
|
18
|
+
|
19
|
+
puts str
|
20
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'internal/node'
|
2
|
+
|
3
|
+
class Node
|
4
|
+
def obfusc(begin_nodes=[])
|
5
|
+
n = self
|
6
|
+
|
7
|
+
# The outputted code must do the following:
|
8
|
+
# 1. Evaluate each of the begin nodes (BEGIN {...}).
|
9
|
+
# 2. Evaluate the main node.
|
10
|
+
return <<-END
|
11
|
+
require 'internal/node'
|
12
|
+
if RUBY_VERSION != "#{RUBY_VERSION}" then
|
13
|
+
$stderr.puts "Wrong Ruby version; please use #{RUBY_VERSION}"
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
begin_nodes = Marshal.load(#{Marshal.dump(begin_nodes).inspect})
|
17
|
+
n = Marshal.load(#{Marshal.dump(n).inspect})
|
18
|
+
begin_nodes.each do |node|
|
19
|
+
node.eval(self)
|
20
|
+
end
|
21
|
+
n.eval(self)
|
22
|
+
END
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
data/lib/internal/obfusc.rb
CHANGED
@@ -20,26 +20,7 @@
|
|
20
20
|
# $ ruby test2.rb
|
21
21
|
# 2
|
22
22
|
|
23
|
-
require 'internal/node'
|
24
|
-
|
25
|
-
def obfusc(begin_nodes, n)
|
26
|
-
# The outputted code must do the following:
|
27
|
-
# 1. Evaluate each of the begin nodes (BEGIN {...}).
|
28
|
-
# 2. Evaluate the main node.
|
29
|
-
puts <<-END
|
30
|
-
require 'internal/node'
|
31
|
-
if RUBY_VERSION != "#{RUBY_VERSION}" then
|
32
|
-
$stderr.puts "Wrong Ruby version; please use #{RUBY_VERSION}"
|
33
|
-
exit 1
|
34
|
-
end
|
35
|
-
begin_nodes = Marshal.load(#{Marshal.dump(begin_nodes).inspect})
|
36
|
-
n = Marshal.load(#{Marshal.dump(n).inspect})
|
37
|
-
begin_nodes.each do |node|
|
38
|
-
node.eval(self)
|
39
|
-
end
|
40
|
-
n.eval(self)
|
41
|
-
END
|
42
|
-
end
|
23
|
+
require 'internal/node/obfusc'
|
43
24
|
|
44
25
|
begin_nodes = []
|
45
26
|
set_trace_func proc {
|
@@ -50,7 +31,8 @@ set_trace_func proc {
|
|
50
31
|
end
|
51
32
|
if n then
|
52
33
|
# TODO: Do I need to include ruby_dyna_vars?
|
53
|
-
obfusc(begin_nodes
|
34
|
+
str = n.obfusc(begin_nodes)
|
35
|
+
puts str
|
54
36
|
exit
|
55
37
|
end
|
56
38
|
}
|
data/pre-setup.rb
CHANGED
data/sample/irbrc
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-internal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Brannan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-06 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -18,8 +18,9 @@ description: |
|
|
18
18
|
internal data structures.
|
19
19
|
|
20
20
|
email: curlypaul924@gmail.com
|
21
|
-
executables:
|
22
|
-
|
21
|
+
executables:
|
22
|
+
- ruby-internal-node-dump
|
23
|
+
- ruby-internal-obfuscate
|
23
24
|
extensions:
|
24
25
|
- Rakefile
|
25
26
|
extra_rdoc_files:
|
@@ -43,6 +44,7 @@ files:
|
|
43
44
|
- lib/internal/node/as_expression.rb
|
44
45
|
- lib/internal/node/as_code.rb
|
45
46
|
- lib/internal/node/pp.rb
|
47
|
+
- lib/internal/node/obfusc.rb
|
46
48
|
- lib/internal/node/to_a.rb
|
47
49
|
- lib/internal/binding.rb
|
48
50
|
- lib/internal/method.rb
|
@@ -384,6 +386,10 @@ files:
|
|
384
386
|
- TODO
|
385
387
|
- metaconfig
|
386
388
|
- Rakefile
|
389
|
+
- bin/ruby-internal-node-dump
|
390
|
+
- bin/ruby-internal-obfuscate
|
391
|
+
- sample/dump_class.rb
|
392
|
+
- sample/irbrc
|
387
393
|
has_rdoc: true
|
388
394
|
homepage: http://rubystuff.org/nodewrap/
|
389
395
|
licenses: []
|