ronin 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +2 -0
- data/History.txt +43 -0
- data/Manifest.txt +27 -10
- data/README.txt +2 -1
- data/Rakefile +12 -11
- data/TODO.txt +8 -0
- data/bin/{ronin-ls → ronin-list} +2 -2
- data/bin/{ronin-rm → ronin-remove} +2 -2
- data/lib/ronin/cacheable.rb +25 -4
- data/lib/ronin/code/reference.rb +0 -9
- data/lib/ronin/code/symbol_table.rb +5 -5
- data/lib/ronin/code/token.rb +1 -1
- data/lib/ronin/database/database.rb +3 -1
- data/lib/ronin/extensions/kernel.rb +25 -3
- data/lib/ronin/formatting/extensions/binary/file.rb +60 -0
- data/lib/ronin/formatting/extensions/text.rb +1 -0
- data/lib/ronin/formatting/extensions/text/array.rb +67 -0
- data/lib/ronin/model.rb +1 -40
- data/lib/ronin/{has_license.rb → model/has_description.rb} +16 -18
- data/lib/ronin/model/has_license.rb +53 -0
- data/lib/ronin/model/has_name.rb +49 -0
- data/lib/ronin/model/has_version.rb +46 -0
- data/lib/ronin/model/model.rb +64 -0
- data/lib/ronin/network/extensions/http/net.rb +580 -99
- data/lib/ronin/network/http.rb +54 -6
- data/lib/ronin/os.rb +7 -7
- data/lib/ronin/platform/extension.rb +4 -6
- data/lib/ronin/platform/maintainer.rb +1 -1
- data/lib/ronin/platform/object_cache.rb +10 -2
- data/lib/ronin/platform/overlay_cache.rb +1 -1
- data/lib/ronin/platform/platform.rb +5 -3
- data/lib/ronin/platform/ronin.rb +3 -3
- data/lib/ronin/scanners.rb +25 -0
- data/lib/ronin/scanners/exceptions.rb +24 -0
- data/lib/ronin/scanners/exceptions/unknown_category.rb +29 -0
- data/lib/ronin/scanners/scanner.rb +239 -0
- data/lib/ronin/sessions/http.rb +548 -7
- data/lib/ronin/{translators.rb → templates.rb} +1 -1
- data/lib/ronin/templates/erb.rb +56 -0
- data/lib/ronin/ui/command_line/command_line.rb +10 -1
- data/lib/ronin/ui/command_line/commands/{ls.rb → list.rb} +1 -1
- data/lib/ronin/ui/command_line/commands/{rm.rb → remove.rb} +1 -1
- data/lib/ronin/ui/command_line/commands/uninstall.rb +2 -2
- data/lib/ronin/ui/console.rb +66 -17
- data/lib/ronin/ui/shell.rb +16 -36
- data/lib/ronin/version.rb +1 -1
- data/spec/cacheable_spec.rb +1 -1
- data/spec/code/classes/thing.rb +4 -0
- data/spec/code/reference_spec.rb +4 -0
- data/spec/code/symbol_table_spec.rb +5 -1
- data/spec/extensions/kernel_spec.rb +45 -5
- data/spec/extensions/string_spec.rb +4 -0
- data/spec/formatting/binary/integer_spec.rb +3 -3
- data/spec/formatting/binary/string_spec.rb +5 -5
- data/spec/formatting/digest/string_spec.rb +5 -9
- data/spec/formatting/http/string_spec.rb +5 -9
- data/spec/formatting/text/array_spec.rb +64 -0
- data/spec/formatting/text/string_spec.rb +3 -3
- data/spec/model/classes/licensed_model.rb +12 -0
- data/spec/{has_license_spec.rb → model/has_license_spec.rb} +5 -5
- data/spec/network/http_spec.rb +197 -0
- data/spec/os_spec.rb +2 -5
- data/spec/platform/maintainer_spec.rb +30 -0
- data/spec/platform/ronin_spec.rb +2 -2
- data/spec/scanners/classes/another_scanner.rb +16 -0
- data/spec/scanners/classes/example_scanner.rb +22 -0
- data/spec/scanners/scanner_spec.rb +148 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/templates/classes/uses_erb.rb +11 -0
- data/spec/templates/erb_spec.rb +20 -0
- data/static/ronin/platform/overlay.xsl +128 -49
- metadata +83 -30
- metadata.gz.sig +0 -0
- data/lib/ronin/translators/translator.rb +0 -75
- data/spec/classes/licensed_model.rb +0 -12
- data/spec/translators/translator_spec.rb +0 -61
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin - A Ruby platform designed for information security and data
|
4
|
+
# exploration tasks.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2006-2009 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 'erb'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Templates
|
28
|
+
module Erb
|
29
|
+
#
|
30
|
+
# Renders the specified inline ERB _template_ in the scope of the
|
31
|
+
# object, returning the resulting +String+.
|
32
|
+
#
|
33
|
+
# @user = 'lolcats'
|
34
|
+
#
|
35
|
+
# erb %{
|
36
|
+
# USER: <%= @user %>
|
37
|
+
# PASSWORD: <%= @user.reverse %>
|
38
|
+
# }
|
39
|
+
# # => "\nUSER: lolcats\nPASSWORD: staclol\n"
|
40
|
+
#
|
41
|
+
def erb(template)
|
42
|
+
ERB.new(template).result(binding)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Renders the ERB template at the specified _path_ in the scope of the
|
47
|
+
# object, returning the resulting +String+.
|
48
|
+
#
|
49
|
+
# erb_file 'path/to/template.erb'
|
50
|
+
#
|
51
|
+
def erb_file(path)
|
52
|
+
erb(File.read(path))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -67,12 +67,21 @@ module Ronin
|
|
67
67
|
# Returns the Command registered with the command-line utility
|
68
68
|
# with the specified _name_.
|
69
69
|
#
|
70
|
+
# CommandLine.get_command('gen_overlay')
|
71
|
+
# # => Ronin::UI::CommandLine::Commands::GenOverlay
|
72
|
+
#
|
70
73
|
def CommandLine.get_command(name)
|
71
74
|
name = name.to_s
|
72
75
|
|
76
|
+
#eventually someone is going to use a space or - which is going mess things up
|
77
|
+
#we will take care of this ahead of time here
|
78
|
+
name.gsub!(/[\s-]/, '_')
|
79
|
+
|
73
80
|
begin
|
74
81
|
require File.join(COMMANDS_DIR,name)
|
75
|
-
rescue LoadError
|
82
|
+
rescue Gem::LoadError => e
|
83
|
+
raise(e)
|
84
|
+
rescue ::LoadError
|
76
85
|
raise(UnknownCommand,"unable to load the command #{name.dump}",caller)
|
77
86
|
end
|
78
87
|
|
@@ -59,8 +59,8 @@ module Ronin
|
|
59
59
|
Platform.load_overlays(@cache) if @cache
|
60
60
|
|
61
61
|
args.each do |name|
|
62
|
-
Platform.uninstall(name) do
|
63
|
-
puts "Uninstalling Overlay #{
|
62
|
+
Platform.uninstall(name) do
|
63
|
+
puts "Uninstalling Overlay #{name.dump} ..."
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/lib/ronin/ui/console.rb
CHANGED
@@ -24,16 +24,27 @@
|
|
24
24
|
require 'ronin/config'
|
25
25
|
|
26
26
|
require 'irb'
|
27
|
-
require 'irb/completion'
|
28
27
|
|
29
28
|
module Ronin
|
30
29
|
module UI
|
31
30
|
module Console
|
31
|
+
# Default prompt style.
|
32
|
+
PROMPT = :SIMPLE
|
33
|
+
|
34
|
+
# Default indentation mode.
|
35
|
+
INDENT = true
|
36
|
+
|
37
|
+
# Default backtrace depth.
|
38
|
+
BACKTRACE_DEPTH = 5
|
39
|
+
|
40
|
+
# Default completion mode.
|
41
|
+
COMPLETION = true
|
42
|
+
|
32
43
|
#
|
33
|
-
# Returns the default Console prompt style
|
44
|
+
# Returns the default Console prompt style, defaults to +PROMPT+.
|
34
45
|
#
|
35
46
|
def Console.prompt
|
36
|
-
@@ronin_console_prompt ||=
|
47
|
+
@@ronin_console_prompt ||= PROMPT
|
37
48
|
end
|
38
49
|
|
39
50
|
#
|
@@ -44,17 +55,54 @@ module Ronin
|
|
44
55
|
end
|
45
56
|
|
46
57
|
#
|
47
|
-
# Returns the default Console indent setting
|
58
|
+
# Returns the default Console indent setting, defaults to +INDENT+.
|
48
59
|
#
|
49
60
|
def Console.indent
|
50
|
-
@@ronin_console_indent ||=
|
61
|
+
@@ronin_console_indent ||= INDENT
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Sets the default Console indent setting to the specified _mode_.
|
66
|
+
#
|
67
|
+
# Console.indent = false
|
68
|
+
# # => false
|
69
|
+
#
|
70
|
+
def Console.indent=(mode)
|
71
|
+
@@ronin_console_indent = mode
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Returns the default Console back trace limit, defaults to
|
76
|
+
# +BACKTRACE_DEPTH+.
|
77
|
+
#
|
78
|
+
def Console.backtrace_depth
|
79
|
+
@@ronin_console_backtrace_depth ||= BACKTRACE_DEPTH
|
51
80
|
end
|
52
81
|
|
53
82
|
#
|
54
|
-
# Sets the default Console
|
83
|
+
# Sets the default Console back trace depth to the specified _depth_.
|
55
84
|
#
|
56
|
-
def Console.
|
57
|
-
@@
|
85
|
+
def Console.backtrace_depth=(depth)
|
86
|
+
@@ronin_console_backtrace_depth = depth
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Returns the default Console tab-completion mode, defaults to
|
91
|
+
# +COMPLETION+.
|
92
|
+
#
|
93
|
+
def Console.completion
|
94
|
+
@@ronin_console_completion ||= COMPLETION
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Sets the default Console tab-completion mode to the specified
|
99
|
+
# _mode_.
|
100
|
+
#
|
101
|
+
# Console.completion = false
|
102
|
+
# # => false
|
103
|
+
#
|
104
|
+
def Console.completion=(mode)
|
105
|
+
@@ronin_console_completion = mode
|
58
106
|
end
|
59
107
|
|
60
108
|
#
|
@@ -79,17 +127,22 @@ module Ronin
|
|
79
127
|
def Console.start(script=nil,&block)
|
80
128
|
IRB.setup(script)
|
81
129
|
|
130
|
+
# configure IRB
|
82
131
|
IRB.conf[:IRB_NAME] = 'ronin'
|
83
132
|
IRB.conf[:PROMPT_MODE] = Console.prompt
|
84
133
|
IRB.conf[:AUTO_INDENT] = Console.indent
|
134
|
+
IRB.conf[:BACK_TRACE_LIMIT] = Console.backtrace_depth
|
85
135
|
|
86
136
|
irb = IRB::Irb.new(nil,script)
|
87
137
|
|
88
|
-
# configure the
|
138
|
+
# configure the IRB context
|
89
139
|
irb.context.main.instance_eval do
|
90
140
|
require 'ronin/environment'
|
91
141
|
require 'ronin/platform'
|
92
142
|
|
143
|
+
require 'irb/completion' if Ronin::UI::Console.completion
|
144
|
+
|
145
|
+
# require any of the auto-load paths
|
93
146
|
Ronin::UI::Console.auto_load.each do |path|
|
94
147
|
require path
|
95
148
|
end
|
@@ -97,22 +150,18 @@ module Ronin
|
|
97
150
|
include Ronin
|
98
151
|
end
|
99
152
|
|
153
|
+
# run any setup-blocks
|
100
154
|
Console.setup_blocks.each do |setup_block|
|
101
155
|
irb.context.main.instance_eval(&setup_block)
|
102
156
|
end
|
103
157
|
|
104
|
-
#
|
158
|
+
# run the supplied configuration block is given
|
105
159
|
irb.context.main.instance_eval(&block) if block
|
106
160
|
|
107
161
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
108
162
|
|
109
|
-
trap('SIGINT')
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
catch(:IRB_EXIT) do
|
114
|
-
irb.eval_input
|
115
|
-
end
|
163
|
+
trap('SIGINT') { irb.signal_handle }
|
164
|
+
catch(:IRB_EXIT) { irb.eval_input }
|
116
165
|
|
117
166
|
putc "\n"
|
118
167
|
return nil
|
data/lib/ronin/ui/shell.rb
CHANGED
@@ -22,45 +22,30 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
module Ronin
|
25
|
-
|
25
|
+
module Shell
|
26
26
|
|
27
27
|
# Default shell prompt
|
28
28
|
DEFAULT_PROMPT = '>'
|
29
29
|
|
30
|
-
# Shell name to use
|
31
|
-
attr_accessor :name
|
32
|
-
|
33
|
-
# Shell prompt
|
34
|
-
attr_accessor :prompt
|
35
|
-
|
36
|
-
#
|
37
|
-
# Creates a new Shell object with the given _options_.
|
38
|
-
#
|
39
|
-
# _options_ may contain the following keys:
|
40
|
-
# <tt>:name</tt>:: The name of the shell.
|
41
|
-
# <tt>:prompt</tt>::The prompt to use for the shell.
|
42
|
-
#
|
43
|
-
def initialize(options={})
|
44
|
-
@name = options[:name]
|
45
|
-
@prompt = (options[:prompt] || DEFAULT_PROMPT)
|
46
|
-
end
|
47
|
-
|
48
30
|
#
|
49
31
|
# Creates and starts a new Shell object with the specified _options_.
|
50
32
|
# If a _block_ is given, it will be passed every command.
|
51
33
|
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
34
|
+
# _options_ may contain the following keys:
|
35
|
+
# <tt>:name</tt>:: Name of the shell.
|
36
|
+
# <tt>:prompt</tt>:: Prompt to use for the shell, defaults to
|
37
|
+
# +DEFAULT_PROMPT+.
|
56
38
|
#
|
57
|
-
#
|
39
|
+
# Shell.start(:prompt => '$') { |shell,line| system(line) }
|
58
40
|
#
|
59
|
-
def start(
|
41
|
+
def Shell.start(options={},&block)
|
42
|
+
name = (options[:name] || '')
|
43
|
+
prompt = (options[:prompt] || DEFAULT_PROMPT)
|
44
|
+
|
60
45
|
history_rollback = 0
|
61
46
|
|
62
47
|
loop do
|
63
|
-
line = Readline.readline("#{
|
48
|
+
line = Readline.readline("#{name}#{prompt} ")
|
64
49
|
|
65
50
|
if line =~ /^\s*exit\s*$/
|
66
51
|
break
|
@@ -76,40 +61,35 @@ module Ronin
|
|
76
61
|
end
|
77
62
|
end
|
78
63
|
|
79
|
-
history_rollback.times
|
80
|
-
Readline::HISTORY.pop
|
81
|
-
end
|
82
|
-
|
64
|
+
history_rollback.times { Readline::HISTORY.pop }
|
83
65
|
return nil
|
84
66
|
end
|
85
67
|
|
86
68
|
#
|
87
69
|
# Equivalent to <tt>STDOUT.putc(char)</tt>.
|
88
70
|
#
|
89
|
-
def putc(char)
|
71
|
+
def Shell.putc(char)
|
90
72
|
STDOUT.putc(char)
|
91
73
|
end
|
92
74
|
|
93
75
|
#
|
94
76
|
# Equivalent to <tt>STDOUT.print(string)</tt>.
|
95
77
|
#
|
96
|
-
def print(string)
|
78
|
+
def Shell.print(string)
|
97
79
|
STDOUT.print(string)
|
98
80
|
end
|
99
81
|
|
100
82
|
#
|
101
83
|
# Equivalent to <tt>STDOUT.puts(string)</tt>.
|
102
84
|
#
|
103
|
-
def puts(string)
|
85
|
+
def Shell.puts(string)
|
104
86
|
STDOUT.puts(string)
|
105
87
|
end
|
106
88
|
|
107
|
-
alias << puts
|
108
|
-
|
109
89
|
#
|
110
90
|
# Equivalent to <tt>STDOUT.printf(string,*objects)</tt>.
|
111
91
|
#
|
112
|
-
def printf(string,*objects)
|
92
|
+
def Shell.printf(string,*objects)
|
113
93
|
STDOUT.printf(string,*objects)
|
114
94
|
end
|
115
95
|
|
data/lib/ronin/version.rb
CHANGED
data/spec/cacheable_spec.rb
CHANGED
data/spec/code/classes/thing.rb
CHANGED
data/spec/code/reference_spec.rb
CHANGED
@@ -56,4 +56,8 @@ describe Code::Reference do
|
|
56
56
|
it "should raise a NoMethodError when trying to call a protected or private method" do
|
57
57
|
lambda { @ref.not_exposed }.should raise_error(NoMethodError)
|
58
58
|
end
|
59
|
+
|
60
|
+
it "should inspect the referenced object when inspect is called" do
|
61
|
+
@ref.inspect.should == '#<Thing: stuff>'
|
62
|
+
end
|
59
63
|
end
|
@@ -3,7 +3,7 @@ require 'ronin/code/symbol_table'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Code::SymbolTable do
|
6
|
-
before(:
|
6
|
+
before(:each) do
|
7
7
|
@one = [:a, :b, :c]
|
8
8
|
@two = {:one => 1, :two => 2}
|
9
9
|
|
@@ -38,4 +38,8 @@ describe Code::SymbolTable do
|
|
38
38
|
@table[:three].should == 3
|
39
39
|
@table[:four].should == 4
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should display the values of the symbols when inspected" do
|
43
|
+
@table.inspect.should == '{:one=>[:a, :b, :c], :two=>{:one=>1, :two=>2}}'
|
44
|
+
end
|
41
45
|
end
|
@@ -3,17 +3,57 @@ require 'ronin/extensions/kernel'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Kernel do
|
6
|
-
it "should provide Kernel#
|
7
|
-
Kernel.respond_to?('
|
6
|
+
it "should provide Kernel#attempt" do
|
7
|
+
Kernel.respond_to?('attempt').should == true
|
8
8
|
end
|
9
9
|
|
10
|
-
describe "
|
10
|
+
describe "attempt" do
|
11
11
|
it "should return the result of the block if nothing is raised" do
|
12
|
-
|
12
|
+
attempt { 2 + 2 }.should == 4
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should return nil if an exception is raised" do
|
16
|
-
|
16
|
+
attempt { 2 + 'a' }.should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should rescue RuntimeError exceptions" do
|
20
|
+
lambda {
|
21
|
+
attempt { raise(RuntimeError,"something happened",caller) }
|
22
|
+
}.should_not raise_error(RuntimeError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should rescue StandardError exceptions" do
|
26
|
+
lambda {
|
27
|
+
attempt { raise(StandardError,"not allowed to do that",caller) }
|
28
|
+
}.should_not raise_error(StandardError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "catch_all" do
|
33
|
+
it "should run a block" do
|
34
|
+
var = 1
|
35
|
+
|
36
|
+
catch_all { var += 1 }
|
37
|
+
|
38
|
+
var.should == 2
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should catch SyntaxError exceptions" do
|
42
|
+
lambda {
|
43
|
+
catch_all(false) { raise(SyntaxError,"horrible code",caller) }
|
44
|
+
}.should_not raise_error(SyntaxError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should catch RuntimeError exceptions" do
|
48
|
+
lambda {
|
49
|
+
catch_all(false) { raise(RuntimeError,"something happened",caller) }
|
50
|
+
}.should_not raise_error(RuntimeError)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should catch StandardError exceptions" do
|
54
|
+
lambda {
|
55
|
+
catch_all(false) { raise(StandardError,"not allowed to do that",caller) }
|
56
|
+
}.should_not raise_error(StandardError)
|
17
57
|
end
|
18
58
|
end
|
19
59
|
end
|