ronin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.txt +13 -0
  2. data/Manifest.txt +19 -17
  3. data/README.txt +9 -9
  4. data/Rakefile +1 -1
  5. data/bin/ronin +2 -2
  6. data/lib/ronin/author.rb +1 -1
  7. data/lib/ronin/cache/extension.rb +4 -12
  8. data/lib/ronin/cache/extension_cache.rb +1 -3
  9. data/lib/ronin/cache/overlay.rb +3 -3
  10. data/lib/ronin/cache/overlay_cache.rb +21 -15
  11. data/lib/ronin/chars/char_set.rb +6 -12
  12. data/lib/ronin/code/reference.rb +142 -0
  13. data/lib/ronin/code/symbol_table.rb +90 -0
  14. data/lib/ronin/context.rb +1 -1
  15. data/lib/ronin/database.rb +12 -3
  16. data/lib/ronin/extensions/string.rb +49 -0
  17. data/lib/ronin/formatting/extensions/text/string.rb +10 -5
  18. data/lib/ronin/object_context.rb +3 -9
  19. data/lib/ronin/pending_context.rb +8 -0
  20. data/lib/ronin/platform.rb +2 -2
  21. data/lib/ronin/product.rb +2 -2
  22. data/lib/ronin/program/command.rb +203 -0
  23. data/lib/ronin/program/commands/add.rb +71 -0
  24. data/lib/ronin/{runner/program → program}/commands/help.rb +14 -16
  25. data/lib/ronin/program/commands/install.rb +64 -0
  26. data/lib/ronin/program/commands/list.rb +79 -0
  27. data/lib/ronin/{runner/program/commands/update.rb → program/commands/remove.rb} +18 -18
  28. data/lib/ronin/{runner/program/commands/remove.rb → program/commands/uninstall.rb} +17 -19
  29. data/lib/ronin/{runner/program/commands/uninstall.rb → program/commands/update.rb} +17 -21
  30. data/lib/ronin/{runner/program → program}/commands.rb +9 -9
  31. data/lib/ronin/{runner/program → program}/exceptions/unknown_command.rb +2 -4
  32. data/lib/ronin/{runner.rb → program/exceptions.rb} +1 -1
  33. data/lib/ronin/{runner/program → program}/options.rb +4 -8
  34. data/lib/ronin/program/program.rb +168 -0
  35. data/lib/ronin/{runner/program/exceptions.rb → program.rb} +2 -1
  36. data/lib/ronin/rpc/client.rb +1 -1
  37. data/lib/ronin/version.rb +1 -1
  38. data/spec/code/reference_spec.rb +72 -0
  39. data/spec/code/symbol_table_spec.rb +35 -0
  40. data/spec/extensions/string_spec.rb +88 -4
  41. data/spec/formatting/text_spec.rb +2 -2
  42. data/spec/helpers.rb +0 -0
  43. metadata +25 -23
  44. data/lib/ronin/runner/program/command.rb +0 -204
  45. data/lib/ronin/runner/program/commands/add.rb +0 -73
  46. data/lib/ronin/runner/program/commands/install.rb +0 -65
  47. data/lib/ronin/runner/program/commands/list.rb +0 -81
  48. data/lib/ronin/runner/program/program.rb +0 -175
  49. data/lib/ronin/runner/program/runner.rb +0 -35
  50. data/lib/ronin/runner/program.rb +0 -26
@@ -1,204 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/program'
25
- require 'ronin/extensions/meta'
26
-
27
- module Ronin
28
- module Runner
29
- module Program
30
- class Command
31
-
32
- #
33
- # Creates a new Command object. If a _block_ is given,
34
- # it will be passed newly created Command object.
35
- #
36
- def initialize(&block)
37
- @options = nil
38
-
39
- block.call(self) if block
40
- end
41
-
42
- #
43
- # Returns the name of the command.
44
- #
45
- def Command.command_name
46
- ''
47
- end
48
-
49
- #
50
- # Returns the short names of the command.
51
- #
52
- def Command.command_short_names
53
- []
54
- end
55
-
56
- #
57
- # Returns all the names of the command.
58
- #
59
- def self.command_names
60
- [self.command_name] + self.command_short_names
61
- end
62
-
63
- #
64
- # Creates a new command object and runs it with the
65
- # given _args_.
66
- #
67
- def self.run(*args)
68
- self.new.run(*args)
69
- end
70
-
71
- #
72
- # Prints the help information for the command.
73
- #
74
- def self.help
75
- self.new.help
76
- end
77
-
78
- #
79
- # Returns the name of the command.
80
- #
81
- def command_name
82
- self.class.command_name
83
- end
84
-
85
- #
86
- # Returns the short names of the command.
87
- #
88
- def command_short_names
89
- self.class.command_short_names
90
- end
91
-
92
- #
93
- # Returns all the names of the command.
94
- #
95
- def command_names
96
- self.class.command_names
97
- end
98
-
99
- #
100
- # Runs the command with the given _args_. If a _block_ is
101
- # given, it will be called after the specified _args_ have
102
- # been parsed and the command has run.
103
- #
104
- def run(*args,&block)
105
- arguments(*(options.parse(args)))
106
-
107
- @options = nil
108
-
109
- block.call if block
110
- return self
111
- end
112
-
113
- #
114
- # Prints the help information for the command.
115
- #
116
- def help
117
- options.help
118
- return self
119
- end
120
-
121
- #
122
- # Returns the String form of the command.
123
- #
124
- def to_s
125
- names.join(', ')
126
- end
127
-
128
- protected
129
-
130
- #
131
- # Registers the command with the specified _name_ and the given
132
- # _short_names_.
133
- #
134
- def self.command(name,*short_names)
135
- name = name.to_s
136
- short_names = short_names.map { |short_name| short_name.to_s }
137
-
138
- meta_def(:command_name) { name }
139
- meta_def(:command_short_names) { short_names }
140
-
141
- # register the command
142
- Program.commands << self unless Program.commands.include?(self)
143
-
144
- # register the command by name
145
- Program.commands_by_name[name] = self
146
-
147
- # register the command by it's short_names
148
- short_names.each do |short_name|
149
- Program.commands_by_name[short_name] = self
150
- end
151
-
152
- return self
153
- end
154
-
155
- #
156
- # Defines the options of the command with the specified _usage_ and
157
- # _block_.
158
- #
159
- def self.options(usage=nil,&block)
160
- class_def(:options) do
161
- @options ||= Options.command(:ronin,self.command_name,usage,&block)
162
- end
163
-
164
- return self
165
- end
166
-
167
- #
168
- # Returns the options of the command.
169
- #
170
- def options
171
- @options ||= Options.command(:ronin,command_name)
172
- end
173
-
174
- #
175
- # See Program.error.
176
- #
177
- def error(message)
178
- Program.error(message)
179
- end
180
-
181
- #
182
- # See Program.success.
183
- #
184
- def success(&block)
185
- Program.success(&block)
186
- end
187
-
188
- #
189
- # See Program.fail.
190
- #
191
- def fail(*messages,&block)
192
- Program.fail(*messages,&block)
193
- end
194
-
195
- #
196
- # Processes the additional arguments specified by _args_.
197
- #
198
- def arguments(*args)
199
- end
200
-
201
- end
202
- end
203
- end
204
- end
@@ -1,73 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2007 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/command'
25
- require 'ronin/cache/overlay'
26
-
27
- module Ronin
28
- module Runner
29
- module Program
30
- class AddCommand < Command
31
-
32
- command :add
33
-
34
- options('PATH [options]') do |opts|
35
- opts.settings.media = nil
36
- opts.settings.uri = nil
37
-
38
- opts.options do
39
- opts.on('-m','--media MEDIA','Spedify the media-type of the repository') do |media|
40
- opts.settings.media = media
41
- end
42
-
43
- opts.on('-U','--uri URI','Specify the source URI of the repository') do |uri|
44
- opts.settings.uri = uri
45
- end
46
- end
47
-
48
- opts.arguments do
49
- opts.arg('PATH','Add the repository located at the specified PATH')
50
- end
51
-
52
- opts.summary('Add a local repository located at the specified PATH to the repository cache')
53
-
54
- end
55
-
56
- def arguments(*args)
57
- unless args.length==1
58
- fail('add: only one repository path maybe specified')
59
- end
60
-
61
- path = args.first
62
-
63
- Cache::Overlay.save_cache do
64
- Cache::Overlay.add(path,options.settings.media,options.settings.uri) do |repo|
65
- puts "Overlay #{repo} added."
66
- end
67
- end
68
- end
69
-
70
- end
71
- end
72
- end
73
- end
@@ -1,65 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2007 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/command'
25
- require 'ronin/cache/overlay'
26
-
27
- module Ronin
28
- module Runner
29
- module Program
30
- class InstallCommand < Command
31
-
32
- command :install
33
-
34
- options('URI [options]') do |opts|
35
- opts.settings.media = nil
36
- opts.settings.uri = nil
37
-
38
- opts.options do
39
- opts.on('-m','--media [MEDIA]','Spedify the media-type of the repository') do |media|
40
- options.settings.media = media
41
- end
42
- end
43
-
44
- opts.arguments do
45
- opts.arg('URI','The URI of the repository to install')
46
- end
47
-
48
- opts.summary('Installs the repository located at the specified URI')
49
- end
50
-
51
- def arguments(args)
52
- unless args.length==1
53
- fail('install: only one repository URI maybe specified')
54
- end
55
-
56
- Cache::Overlay.save_cache do
57
- Cache::Overlay.install(:uri => args.first, :media => options.settings.media) do |repo|
58
- puts "Overlay #{repo} has been installed."
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,81 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2007 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/command'
25
- require 'ronin/cache/overlay'
26
-
27
- module Ronin
28
- module Runner
29
- module Program
30
- class ListCommand < Command
31
-
32
- command :list, :ls
33
-
34
- options('[NAME ...] [options]') do |opts|
35
- opts.options
36
-
37
- opts.arguments do
38
- opts.arg('NAME','Overlay to display')
39
- end
40
-
41
- opts.summary('Display all or the specified repositories within the repository cache')
42
- end
43
-
44
- def arguments(*args)
45
- if args.empty?
46
- # list all repositories by name
47
- Cache::Overlay.each do |repo|
48
- puts " #{repo}"
49
- end
50
- else
51
- # list specified repositories
52
- args.each do |name|
53
- repo = Cache::Overlay.get(name)
54
-
55
- puts "[ #{repo} ]\n\n"
56
-
57
- puts " path: #{repo.path}" if options.settings.verbose
58
- puts " media: #{repo.media}"
59
- puts " uri: #{repo.uri}" if repo.uri
60
-
61
- if repo.description
62
- puts " description:\n\n #{repo.description}"
63
- end
64
-
65
- puts "\n"
66
-
67
- if options.settings.verbose
68
- puts " extensions:\n\n"
69
-
70
- repo.each_extension do |ext|
71
- puts " #{ext}"
72
- end
73
- end
74
- end
75
- end
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
@@ -1,175 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/command'
25
- require 'ronin/runner/program/options'
26
- require 'ronin/runner/program/exceptions/unknown_command'
27
- require 'ronin/console'
28
- require 'ronin/version'
29
-
30
- module Ronin
31
- module Runner
32
- module Program
33
- #
34
- # Returns the commands registered with the Program.
35
- #
36
- def Program.commands
37
- @@commands ||= []
38
- end
39
-
40
- #
41
- # Returns the Hash of the Command names and their Command objects
42
- # registered with the Program.
43
- #
44
- def Program.commands_by_name
45
- @@commands_by_name ||= {}
46
- end
47
-
48
- #
49
- # Returns +true+ if the a Command with the specified _name_ was
50
- # registered with the Program.
51
- #
52
- def Program.has_command?(name)
53
- Program.commands_by_name.has_key?(name.to_s)
54
- end
55
-
56
- #
57
- # Returns the Command registered with the Program with the specified
58
- # _name_.
59
- #
60
- def Program.get_command(name)
61
- name = name.to_s
62
-
63
- unless Program.has_command?(name)
64
- raise(UnknownCommand,"unknown command #{name.dump}",caller)
65
- end
66
-
67
- return Program.commands_by_name[name]
68
- end
69
-
70
- #
71
- # Prints the specified error _message_.
72
- #
73
- def Program.error(message)
74
- STDERR.puts "ronin: #{message}"
75
- return false
76
- end
77
-
78
- #
79
- # Exits successfully from the Program. If a _block_ is given, it will
80
- # be called before the Program is exited.
81
- #
82
- def Program.success(&block)
83
- block.call(self) if block
84
- exit
85
- end
86
-
87
- #
88
- # Prints the given error _messages_ and exits unseccessfully from the
89
- # Program. If a _block_ is given, it will be called before any
90
- # error _messages_ are printed.
91
- #
92
- def Program.fail(*messages,&block)
93
- block.call(self) if block
94
-
95
- messages.each do |mesg|
96
- Program.error(mesg)
97
- end
98
-
99
- exit -1
100
- end
101
-
102
- #
103
- # If a _topic_ is given, the help message for that _topic_ will be
104
- # printed, otherwise a list of available commands will be printed.
105
- #
106
- def Program.help(topic=nil)
107
- if topic
108
- begin
109
- get_command(topic).help
110
- rescue UnknownCommand => exp
111
- Program.fail(exp)
112
- end
113
- else
114
- puts 'Available commands:'
115
-
116
- Program.commands.sort_by { |cmd|
117
- cmd.command_names.first
118
- }.each { |cmd|
119
- puts " #{cmd.command_names.join(', ')}"
120
- }
121
- end
122
- end
123
-
124
- #
125
- # The default command to run with the given _argv_ Array when no
126
- # sub-command is given.
127
- #
128
- def Program.default_command(*argv)
129
- Options.new('ronin','<command> [options]') { |opts|
130
- opts.options do |opts|
131
- opts.on('-r','--require LIB','require the specified library or path') do |lib|
132
- Console.auto_load << lib.to_s
133
- end
134
-
135
- opts.on('-V','--version','print version information and exit') do
136
- Program.success do
137
- puts "Ronin #{Ronin::VERSION}"
138
- end
139
- end
140
- end
141
-
142
- opts.summary('Ronin is a Ruby development platform designed for information security','and data exploration tasks.')
143
- }.parse(argv) { |opts,args|
144
- Console.start
145
- }
146
- end
147
-
148
- #
149
- # Runs the Program with the given _argv_ Array. If the first argument
150
- # is a sub-command name, the Program will attempt to find and execute
151
- # the Command with the same name.
152
- #
153
- def Program.run(*argv)
154
- begin
155
- if (argv.empty? || argv[0][0..0]=='-')
156
- Program.default_command(*argv)
157
- else
158
- cmd = argv.first
159
- argv = argv[1..-1]
160
-
161
- if Program.has_command?(cmd)
162
- Program.commands_by_name[cmd].run(*argv)
163
- else
164
- Program.fail("unknown command #{cmd.dump}")
165
- end
166
- end
167
- rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
168
- Program.fail(e)
169
- end
170
-
171
- return true
172
- end
173
- end
174
- end
175
- end
@@ -1,35 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/program'
25
-
26
- module Ronin
27
- module Runner
28
- #
29
- # See Program.run.
30
- #
31
- def Runner.program(argv)
32
- Program.run(*argv)
33
- end
34
- end
35
- end
@@ -1,26 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com)
7
- #
8
- # This program is free software; you can redistribute it and/or modify
9
- # it under the terms of the GNU General Public License as published by
10
- # the Free Software Foundation; either version 2 of the License, or
11
- # (at your option) any later version.
12
- #
13
- # This program is distributed in the hope that it will be useful,
14
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- # GNU General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU General Public License
19
- # along with this program; if not, write to the Free Software
20
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
- #
23
-
24
- require 'ronin/runner/program/program'
25
- require 'ronin/runner/program/commands'
26
- require 'ronin/runner/program/runner'