ronin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/History.txt +39 -0
  2. data/Manifest.txt +46 -34
  3. data/README.txt +81 -20
  4. data/Rakefile +6 -4
  5. data/TODO.txt +1 -5
  6. data/bin/ronin +2 -2
  7. data/lib/ronin.rb +3 -3
  8. data/lib/ronin/arch.rb +5 -3
  9. data/lib/ronin/author.rb +2 -1
  10. data/lib/ronin/cache/cache.rb +78 -0
  11. data/lib/ronin/cache/extension.rb +6 -6
  12. data/lib/ronin/cache/extension_cache.rb +3 -21
  13. data/lib/ronin/{parameters/instance_param.rb → cache/maintainer.rb} +22 -17
  14. data/lib/ronin/cache/overlay.rb +74 -23
  15. data/lib/ronin/cache/overlay_cache.rb +3 -21
  16. data/lib/ronin/chars/char_set.rb +114 -31
  17. data/lib/ronin/chars/chars.rb +20 -10
  18. data/lib/ronin/{parameters/param.rb → code/emittable.rb} +29 -11
  19. data/lib/ronin/code/symbol_table.rb +13 -0
  20. data/lib/ronin/{parameters/class_param.rb → code/token.rb} +37 -10
  21. data/lib/ronin/config.rb +33 -0
  22. data/lib/ronin/context.rb +32 -29
  23. data/lib/ronin/database.rb +1 -2
  24. data/lib/ronin/extensions.rb +0 -1
  25. data/lib/ronin/extensions/string.rb +41 -0
  26. data/lib/ronin/extensions/uri/query_params.rb +8 -0
  27. data/lib/ronin/formatting/extensions/binary/string.rb +10 -0
  28. data/lib/ronin/{program.rb → hexdump.rb} +2 -2
  29. data/lib/ronin/{parameters/exceptions/missing_param.rb → hexdump/extensions.rb} +2 -6
  30. data/lib/ronin/{extensions/kernel.rb → hexdump/extensions/file.rb} +8 -6
  31. data/lib/ronin/{persistence.rb → hexdump/extensions/kernel.rb} +7 -6
  32. data/lib/ronin/hexdump/hexdump.rb +76 -0
  33. data/lib/ronin/license.rb +5 -3
  34. data/lib/ronin/model.rb +4 -2
  35. data/lib/ronin/models.rb +8 -2
  36. data/lib/ronin/object_context.rb +89 -62
  37. data/lib/ronin/rpc/console.rb +6 -4
  38. data/lib/ronin/rpc/shell.rb +4 -4
  39. data/lib/ronin/sessions/http.rb +144 -0
  40. data/lib/ronin/sessions/session.rb +2 -1
  41. data/lib/ronin/sessions/telnet.rb +3 -1
  42. data/lib/ronin/sessions/udp.rb +1 -1
  43. data/lib/ronin/sessions/web.rb +7 -2
  44. data/lib/ronin/translators/translator.rb +75 -0
  45. data/lib/ronin/ui/command_line.rb +25 -0
  46. data/lib/ronin/ui/command_line/command.rb +165 -0
  47. data/lib/ronin/ui/command_line/command_line.rb +117 -0
  48. data/lib/ronin/{program → ui/command_line}/commands.rb +12 -9
  49. data/lib/ronin/ui/command_line/commands/add.rb +75 -0
  50. data/lib/ronin/{program/commands/help.rb → ui/command_line/commands/default.rb} +26 -17
  51. data/lib/ronin/ui/command_line/commands/extension.rb +85 -0
  52. data/lib/ronin/ui/command_line/commands/help.rb +70 -0
  53. data/lib/ronin/{program → ui/command_line}/commands/install.rb +26 -23
  54. data/lib/ronin/ui/command_line/commands/list.rb +93 -0
  55. data/lib/ronin/ui/command_line/commands/overlay.rb +187 -0
  56. data/lib/ronin/{program/commands/uninstall.rb → ui/command_line/commands/remove.rb} +25 -17
  57. data/lib/ronin/{program/commands/update.rb → ui/command_line/commands/uninstall.rb} +27 -17
  58. data/lib/ronin/{program/commands/remove.rb → ui/command_line/commands/update.rb} +24 -18
  59. data/lib/ronin/{program → ui/command_line}/exceptions.rb +1 -1
  60. data/lib/ronin/{program → ui/command_line}/exceptions/unknown_command.rb +4 -2
  61. data/lib/ronin/ui/command_line/options.rb +148 -0
  62. data/lib/ronin/{console.rb → ui/console.rb} +0 -0
  63. data/lib/ronin/ui/shell.rb +117 -0
  64. data/lib/ronin/version.rb +1 -1
  65. data/lib/ronin/web.rb +1 -0
  66. data/lib/ronin/web/extensions.rb +1 -0
  67. data/lib/ronin/web/extensions/hpricot.rb +5 -0
  68. data/lib/ronin/web/extensions/hpricot/comment.rb +19 -0
  69. data/lib/ronin/web/extensions/hpricot/container.rb +46 -0
  70. data/lib/ronin/web/extensions/hpricot/doc.rb +21 -0
  71. data/lib/ronin/web/extensions/hpricot/elem.rb +25 -0
  72. data/lib/ronin/web/extensions/hpricot/tag.rb +19 -0
  73. data/lib/ronin/web/extensions/hpricot/text.rb +19 -0
  74. data/lib/ronin/web/web.rb +70 -4
  75. data/spec/arch_spec.rb +1 -1
  76. data/spec/author_spec.rb +1 -1
  77. data/spec/chars/char_set_spec.rb +177 -0
  78. data/spec/code/symbol_table_spec.rb +6 -0
  79. data/spec/extensions/string_spec.rb +12 -0
  80. data/spec/formatting/binary_spec.rb +9 -0
  81. data/spec/license_spec.rb +1 -1
  82. data/spec/object_context/object_context_spec.rb +29 -0
  83. data/spec/platform_spec.rb +1 -1
  84. data/spec/product_spec.rb +1 -1
  85. data/spec/ronin_spec.rb +1 -1
  86. data/spec/spec_helper.rb +3 -2
  87. data/spec/target_spec.rb +1 -1
  88. data/spec/translators/translator_spec.rb +63 -0
  89. data/spec/web/extensions/hpricot_spec.rb +62 -0
  90. data/static/extension.rb.erb +16 -0
  91. data/static/overlay.xsl +103 -0
  92. data/tasks/spec.rb +2 -0
  93. metadata +72 -42
  94. data/FAQ.txt +0 -103
  95. data/lib/ronin/environment.rb +0 -39
  96. data/lib/ronin/objects.rb +0 -27
  97. data/lib/ronin/parameters.rb +0 -27
  98. data/lib/ronin/parameters/exceptions.rb +0 -25
  99. data/lib/ronin/parameters/exceptions/param_not_found.rb +0 -29
  100. data/lib/ronin/parameters/parameters.rb +0 -286
  101. data/lib/ronin/program/command.rb +0 -203
  102. data/lib/ronin/program/commands/add.rb +0 -71
  103. data/lib/ronin/program/commands/list.rb +0 -79
  104. data/lib/ronin/program/options.rb +0 -201
  105. data/lib/ronin/program/program.rb +0 -168
  106. data/lib/ronin/rpc/interactive.rb +0 -55
  107. data/lib/ronin/rpc/interactive_console.rb +0 -58
  108. data/lib/ronin/rpc/interactive_shell.rb +0 -59
  109. data/lib/ronin/shell.rb +0 -81
  110. data/spec/parameters/parameters_spec.rb +0 -109
@@ -1,168 +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/program/command'
25
- require 'ronin/program/options'
26
- require 'ronin/program/exceptions/unknown_command'
27
- require 'ronin/console'
28
- require 'ronin/version'
29
-
30
- module Ronin
31
- module Program
32
- #
33
- # Returns the commands registered with the Program.
34
- #
35
- def Program.commands
36
- @@ronin_commands ||= []
37
- end
38
-
39
- #
40
- # Returns the Hash of the Command names and their Command objects
41
- # registered with the Program.
42
- #
43
- def Program.commands_by_name
44
- @@ronin_commands_by_name ||= {}
45
- end
46
-
47
- #
48
- # Returns +true+ if the a Command with the specified _name_ was
49
- # registered with the Program.
50
- #
51
- def Program.has_command?(name)
52
- Program.commands_by_name.has_key?(name.to_s)
53
- end
54
-
55
- #
56
- # Returns the Command registered with the Program with the specified
57
- # _name_.
58
- #
59
- def Program.get_command(name)
60
- name = name.to_s
61
-
62
- unless Program.has_command?(name)
63
- raise(UnknownCommand,"unknown command #{name.dump}",caller)
64
- end
65
-
66
- return Program.commands_by_name[name]
67
- end
68
-
69
- #
70
- # Prints the specified error _message_.
71
- #
72
- def Program.error(message)
73
- STDERR.puts "ronin: #{message}"
74
- return false
75
- end
76
-
77
- #
78
- # Exits successfully from the Program. If a _block_ is given, it will
79
- # be called before the Program is exited.
80
- #
81
- def Program.success(&block)
82
- block.call(self) if block
83
- exit
84
- end
85
-
86
- #
87
- # Prints the given error _messages_ and exits unseccessfully from the
88
- # Program. If a _block_ is given, it will be called before any
89
- # error _messages_ are printed.
90
- #
91
- def Program.fail(*messages,&block)
92
- block.call(self) if block
93
- messages.each { |mesg| Program.error(mesg) }
94
-
95
- exit -1
96
- end
97
-
98
- #
99
- # If a _topic_ is given, the help message for that _topic_ will be
100
- # printed, otherwise a list of available commands will be printed.
101
- #
102
- def Program.help(topic=nil)
103
- if topic
104
- begin
105
- get_command(topic).help
106
- rescue UnknownCommand => exp
107
- Program.fail(exp)
108
- end
109
- else
110
- puts 'Available commands:'
111
-
112
- Program.commands.sort_by { |cmd| cmd.command_names[0] }.each { |cmd|
113
- puts " #{cmd.command_names.join(', ')}"
114
- }
115
- end
116
- end
117
-
118
- #
119
- # The default command to run with the given _argv_ Array when no
120
- # sub-command is given.
121
- #
122
- def Program.default_command(*argv)
123
- opts = Options.new('ronin','<command> [options]') { |opts|
124
- opts.options do |opts|
125
- opts.on('-r','--require LIB','require the specified library or path') do |lib|
126
- Console.auto_load << lib.to_s
127
- end
128
-
129
- opts.on('-V','--version','print version information and exit') do
130
- Program.success do
131
- puts "Ronin #{Ronin::VERSION}"
132
- end
133
- end
134
- end
135
-
136
- opts.summary('Ronin is a Ruby development platform designed for information security','and data exploration tasks.')
137
- }
138
-
139
- return opts.parse(argv) { |opts,args| Console.start }
140
- end
141
-
142
- #
143
- # Runs the Program with the given _argv_ Array. If the first argument
144
- # is a sub-command name, the Program will attempt to find and execute
145
- # the Command with the same name.
146
- #
147
- def Program.run(*argv)
148
- begin
149
- if (argv.empty? || argv[0][0..0]=='-')
150
- Program.default_command(*argv)
151
- else
152
- cmd = argv.first
153
- argv = argv[1..-1]
154
-
155
- if Program.has_command?(cmd)
156
- Program.commands_by_name[cmd].run(*argv)
157
- else
158
- Program.fail("unknown command #{cmd.dump}")
159
- end
160
- end
161
- rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
162
- Program.fail(e)
163
- end
164
-
165
- return true
166
- end
167
- end
168
- end
@@ -1,55 +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/shell'
25
-
26
- module Ronin
27
- module RPC
28
- class Interactive < Ronin::Shell
29
-
30
- # The service to interactive with
31
- attr_reader :service
32
-
33
- #
34
- # Creates a new Interactive object using the specified _service_ and
35
- # the given _options_. If a _block_ is given it will be passed the
36
- # newly created Interactive object.
37
- #
38
- def initialize(service,options={},&block)
39
- @service = service
40
-
41
- super(options,&block)
42
- end
43
-
44
- #
45
- # Starts a newly created Interactive object with the specified
46
- # _service_ with the given _options_. If a _block_ is given, it will
47
- # be passed the newly created Interactive object, before it is started.
48
- #
49
- def Interactive.start(service,options={},&block)
50
- Interactive.new(service,options,&block).start
51
- end
52
-
53
- end
54
- end
55
- end
@@ -1,58 +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/rpc/interactive'
25
- require 'ronin/rpc/console'
26
-
27
- module Ronin
28
- module RPC
29
- class InteractiveConsole < Interactive
30
-
31
- #
32
- # Creates a new InteractiveConsole object with the specified _console_
33
- # service. If a _block_ is given it will be
34
- #
35
- def initialize(console,&block)
36
- super(console,:prompt => '>>',&block)
37
- end
38
-
39
- #
40
- # Starts a newly created InteractiveConsole object with the specified
41
- # _service_. If a _block_ is given, it will be passed the newly
42
- # created InteractiveShell object, before it is started.
43
- #
44
- def self.start(console,&block)
45
- self.new(console,&block).start
46
- end
47
-
48
- #
49
- # Evaluates the specified _code_ through the Console service and
50
- # prints the natively formated return-value.
51
- #
52
- def process_command(code)
53
- puts "=> #{@service.inspect(code)}"
54
- end
55
-
56
- end
57
- end
58
- end
@@ -1,59 +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/rpc/interactive'
25
- require 'ronin/shell'
26
-
27
- module Ronin
28
- module RPC
29
- class InteractiveShell < Interactive
30
-
31
- #
32
- # Creates a new InteractiveShell object with the specified _shell_
33
- # service. If a _block_ is given it will be passed the newly created
34
- # InteractiveShell object.
35
- #
36
- def initialize(shell,&block)
37
- super(shell,:prompt => '$',&block)
38
- end
39
-
40
- #
41
- # Starts a newly created InteractiveShell object using the specified
42
- # _shell_ service. If a _block_ is given, it will be passed the newly
43
- # created InteractiveShell before it is started.
44
- #
45
- def self.start(shell,&block)
46
- self.new(shell,&block).start
47
- end
48
-
49
- #
50
- # Executes the specified _command_ through the Shell service
51
- # and prints the output of the command.
52
- #
53
- def process_command(command)
54
- @service.system(command)
55
- end
56
-
57
- end
58
- end
59
- end
@@ -1,81 +0,0 @@
1
- module Ronin
2
- class Shell
3
-
4
- # Default shell prompt
5
- DEFAULT_PROMPT = '>'
6
-
7
- # Shell name to use
8
- attr_accessor :name
9
-
10
- # Shell prompt
11
- attr_accessor :prompt
12
-
13
- #
14
- # Creates a new Shell object with the given _options_. If a _block_ is
15
- # given it will be passed the newly created Shell object.
16
- #
17
- # _options_ may contain the following keys:
18
- # <tt>:name</tt>:: The name of the shell.
19
- # <tt>:prompt</tt>::The prompt to use for the shell.
20
- #
21
- def initialize(options={},&block)
22
- @name = options[:name]
23
- @prompt = (options[:prompt] || DEFAULT_PROMPT)
24
-
25
- block.call(self) if block
26
- end
27
-
28
- #
29
- # Creates and starts a new Shell object with the specified _options_.
30
- # If a _block_ is given, it will be passed the newly created Shell
31
- # object before it is started.
32
- #
33
- def self.start(options={},&block)
34
- self.new(options,&block).start
35
- end
36
-
37
- #
38
- # Starts the shell.
39
- #
40
- def start
41
- history_rollback = 0
42
-
43
- loop do
44
- line = Readline.readline("#{@name}#{@prompt} ")
45
-
46
- if line =~ /^\s*exit\s*$/
47
- exit_shell
48
- break
49
- else
50
- Readline::HISTORY << line
51
- history_rollback += 1
52
-
53
- begin
54
- process_command(line)
55
- rescue => e
56
- puts "#{e.class.name}: #{e.message}"
57
- end
58
- end
59
- end
60
-
61
- history_rollback.times do
62
- Readline::HISTORY.pop
63
- end
64
-
65
- return nil
66
- end
67
-
68
- #
69
- # Default method that processes commands.
70
- #
71
- def process_command(command)
72
- end
73
-
74
- #
75
- # Default method that will be called when the shell is exited.
76
- #
77
- def exit_shell
78
- end
79
-
80
- end
81
- end
@@ -1,109 +0,0 @@
1
- require 'ronin/parameters'
2
-
3
- require 'spec_helper'
4
-
5
- describe Parameters do
6
- before(:all) do
7
- class TestParameters
8
- include Parameters
9
-
10
- parameter :var, :description => 'Test parameter'
11
-
12
- parameter :var_with_default,
13
- :default => 'thing',
14
- :description => 'This parameter has a default value'
15
-
16
- end
17
-
18
- class InheritedParameters < TestParameters
19
-
20
- parameter :child_var, :description => 'Child parameter'
21
-
22
- end
23
- end
24
-
25
- describe "in a Class" do
26
- it "should provide parameters" do
27
- TestParameters.params.should_not be_empty
28
- end
29
-
30
- it "can have default values for parameters" do
31
- TestParameters.param_value(:var_with_default).should == 'thing'
32
- end
33
-
34
- it "should provide class methods for paremters" do
35
- TestParameters.var = 1
36
- TestParameters.var.should == 1
37
- end
38
-
39
- it "should inherite the super-classes parameters" do
40
- InheritedParameters.has_param?(:var).should == true
41
- InheritedParameters.has_param?(:child_var).should == true
42
- end
43
-
44
- it "should provide direct access to the parameter objects" do
45
- @param = TestParameters.get_param(:var)
46
-
47
- @param.should_not be_nil
48
- @param.name.should == :var
49
- end
50
-
51
- it "raise a ParamNotFound exception when directly accessing non-existent parameter objects" do
52
- lambda { TestParameters.get_param(:unknown) }.should raise_error(Parameters::ParamNotFound)
53
- end
54
-
55
- it "should provide descriptions for parameters" do
56
- TestParameters.describe_param(:var).should_not be_empty
57
- end
58
- end
59
-
60
- describe "in an Object" do
61
- before(:all) do
62
- @test = TestParameters.new
63
- @test_inherited = InheritedParameters.new
64
- end
65
-
66
- it "can have default values for parameters" do
67
- @test.param_value(:var_with_default).should == 'thing'
68
- end
69
-
70
- it "should provide instance methods for parameters" do
71
- @test.var = 2
72
- @test.var.should == 2
73
- end
74
-
75
- it "should set instance variables for paramters" do
76
- @test.instance_variable_get('@var_with_default').should == 'thing'
77
-
78
- @test.var = 3
79
- @test.instance_variable_get('@var').should == 3
80
- end
81
-
82
- it "should contain the parameters from all ancestors" do
83
- @test_inherited.has_param?(:var).should == true
84
- @test_inherited.has_param?(:child_var).should == true
85
- end
86
-
87
- it "should provide direct access to the parameter objects" do
88
- @param = @test.get_param(:var)
89
-
90
- @param.should_not be_nil
91
- @param.name.should == :var
92
- end
93
-
94
- it "should raise a ParamNotFound exception when directly accessing non-existent parameter objects" do
95
- lambda { @test.get_param(:unknown) }.should raise_error(Parameters::ParamNotFound)
96
- end
97
-
98
- it "should allow for setting parameters en-mass" do
99
- @test.set_params(:var => 3, :var_with_default => 7)
100
-
101
- @test.param_value(:var).should == 3
102
- @test.param_value(:var_with_default).should == 7
103
- end
104
-
105
- it "should provide descriptions for parameters" do
106
- @test.describe_param(:var).should_not be_empty
107
- end
108
- end
109
- end