ronin 0.1.4 → 0.2.0
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/History.txt +50 -0
- data/Manifest.txt +31 -19
- data/README.txt +27 -19
- data/Rakefile +1 -1
- data/TODO.txt +1 -7
- data/lib/ronin.rb +1 -11
- data/lib/ronin/database/database.rb +1 -1
- data/lib/ronin/{cache/config.rb → environment.rb} +10 -8
- data/lib/ronin/formatting.rb +0 -1
- data/lib/ronin/formatting/extensions.rb +0 -1
- data/lib/ronin/formatting/extensions/binary/integer.rb +10 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +11 -0
- data/lib/ronin/formatting/extensions/http/string.rb +1 -1
- data/lib/ronin/network/extensions/http/net.rb +8 -0
- data/lib/ronin/objectify/objectify.rb +0 -47
- data/lib/ronin/os.rb +89 -0
- data/lib/ronin/platform.rb +4 -77
- data/lib/ronin/{cache → platform}/exceptions.rb +2 -2
- data/lib/ronin/{cache → platform}/exceptions/extension_not_found.rb +1 -1
- data/lib/ronin/{cache → platform}/exceptions/overlay_cached.rb +1 -1
- data/lib/ronin/{cache → platform}/exceptions/overlay_not_found.rb +1 -1
- data/lib/ronin/{cache → platform}/extension.rb +68 -177
- data/lib/ronin/{cache → platform}/extension_cache.rb +9 -7
- data/lib/ronin/{cache → platform}/maintainer.rb +1 -1
- data/lib/ronin/platform/object_cache.rb +94 -0
- data/lib/ronin/platform/overlay.rb +274 -0
- data/lib/ronin/platform/overlay_cache.rb +318 -0
- data/lib/ronin/platform/platform.rb +195 -0
- data/lib/ronin/{cache → platform}/ronin.rb +7 -6
- data/lib/ronin/target.rb +5 -5
- data/lib/ronin/ui.rb +4 -1
- data/lib/ronin/ui/command_line/command_line.rb +0 -1
- data/lib/ronin/ui/command_line/commands/add.rb +21 -6
- data/lib/ronin/ui/command_line/commands/default.rb +6 -1
- data/lib/ronin/ui/command_line/commands/extension.rb +3 -3
- data/lib/ronin/ui/command_line/commands/install.rb +16 -5
- data/lib/ronin/ui/command_line/commands/list.rb +31 -8
- data/lib/ronin/ui/command_line/commands/overlay.rb +10 -9
- data/lib/ronin/ui/command_line/commands/remove.rb +16 -5
- data/lib/ronin/ui/command_line/commands/uninstall.rb +16 -5
- data/lib/ronin/ui/command_line/commands/update.rb +16 -3
- data/lib/ronin/ui/console.rb +81 -77
- data/lib/ronin/ui/diagnostics.rb +73 -0
- data/lib/ronin/version.rb +1 -1
- data/spec/chars/chars_spec.rb +1 -3
- data/spec/formatting/binary/integer_spec.rb +48 -36
- data/spec/formatting/binary/string_spec.rb +66 -4
- data/spec/os_spec.rb +24 -0
- data/spec/platform/extension_cache_spec.rb +42 -0
- data/spec/platform/extension_spec.rb +62 -0
- data/spec/platform/helpers/overlays.rb +18 -0
- data/spec/platform/helpers/overlays.yaml.erb +10 -0
- data/spec/platform/helpers/overlays/hello/hello/extension.rb +7 -0
- data/spec/platform/helpers/overlays/hello/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test1/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test1/test/extension.rb +7 -0
- data/spec/platform/helpers/overlays/test2/ronin.xml +26 -0
- data/spec/platform/helpers/overlays/test2/test/extension.rb +7 -0
- data/spec/platform/overlay_cache_spec.rb +63 -0
- data/spec/platform/platform_spec.rb +14 -0
- data/spec/platform/ronin_spec.rb +22 -0
- data/spec/target_spec.rb +1 -1
- data/spec/ui/diagnostics_spec.rb +17 -0
- metadata +34 -22
- data/lib/ronin/cache.rb +0 -27
- data/lib/ronin/cache/cache.rb +0 -78
- data/lib/ronin/cache/overlay.rb +0 -470
- data/lib/ronin/cache/overlay_cache.rb +0 -216
- data/lib/ronin/formatting/extensions/html.rb +0 -24
- data/lib/ronin/formatting/extensions/html/string.rb +0 -75
- data/lib/ronin/formatting/html.rb +0 -24
- data/spec/formatting/html_spec.rb +0 -46
- data/spec/platform_spec.rb +0 -24
@@ -1,216 +0,0 @@
|
|
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 'ronin/cache/exceptions/overlay_cached'
|
25
|
-
require 'ronin/cache/exceptions/overlay_not_found'
|
26
|
-
require 'ronin/cache/overlay'
|
27
|
-
require 'ronin/cache/config'
|
28
|
-
|
29
|
-
require 'yaml'
|
30
|
-
|
31
|
-
module Ronin
|
32
|
-
module Cache
|
33
|
-
class OverlayCache < Hash
|
34
|
-
|
35
|
-
# Path of cache file
|
36
|
-
attr_reader :path
|
37
|
-
|
38
|
-
#
|
39
|
-
# Create a new Cache object with the specified _path_. The _path_
|
40
|
-
# defaults to <tt>Config::REPOSITORY_CACHE_PATH</tt>. If a _block_ is
|
41
|
-
# given, it will be passed the newly created Cache object.
|
42
|
-
#
|
43
|
-
def initialize(path=Config::REPOSITORY_CACHE_PATH,&block)
|
44
|
-
super()
|
45
|
-
|
46
|
-
@path = File.expand_path(path)
|
47
|
-
|
48
|
-
if File.file?(@path)
|
49
|
-
descriptions = YAML.load(File.read(@path))
|
50
|
-
|
51
|
-
if descriptions.kind_of?(Array)
|
52
|
-
descriptions.each do |overlay|
|
53
|
-
if overlay.kind_of?(Hash)
|
54
|
-
add(Overlay.new(overlay[:path],overlay[:media],overlay[:uri]))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
block.call(self) if block
|
61
|
-
end
|
62
|
-
|
63
|
-
alias names keys
|
64
|
-
alias overlays values
|
65
|
-
alias each_overlay each_value
|
66
|
-
|
67
|
-
#
|
68
|
-
# Returns the Ovlerays which match the specified _block_.
|
69
|
-
#
|
70
|
-
# cache.overlays_with do |repo|
|
71
|
-
# repo.author == 'the dude'
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
def overlays_with(&block)
|
75
|
-
values.select(&block)
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Returns +true+ if the cache contains the Overlay with the
|
80
|
-
# matching _name_, returns +false+ otherwise.
|
81
|
-
#
|
82
|
-
def has_overlay?(name)
|
83
|
-
has_key?(name.to_s)
|
84
|
-
end
|
85
|
-
|
86
|
-
#
|
87
|
-
# Returns the Overlay with the matching _name_.
|
88
|
-
#
|
89
|
-
def get_overlay(name)
|
90
|
-
name = name.to_s
|
91
|
-
|
92
|
-
unless has_overlay?(name)
|
93
|
-
raise(OverlayNotFound,"overlay #{name.dump} is not present in cache #{self.to_s.dump}",caller)
|
94
|
-
end
|
95
|
-
|
96
|
-
return self[name]
|
97
|
-
end
|
98
|
-
|
99
|
-
#
|
100
|
-
# Returns the paths of the Overlays contained in the cache.
|
101
|
-
#
|
102
|
-
def paths
|
103
|
-
overlays.map { |repo| repo.path }
|
104
|
-
end
|
105
|
-
|
106
|
-
#
|
107
|
-
# Adds the _repo_ to the cache. If a _block_ is given, it will
|
108
|
-
# be passed the cache after the _repo_ is added. The _repo_
|
109
|
-
# will be returned.
|
110
|
-
#
|
111
|
-
# cache.add(repo) # => Overlay
|
112
|
-
#
|
113
|
-
# cache.add(repo) do |cache|
|
114
|
-
# puts "Overlay #{repo} added"
|
115
|
-
# end
|
116
|
-
#
|
117
|
-
def add(repo,&block)
|
118
|
-
name = repo.name.to_s
|
119
|
-
|
120
|
-
if has_overlay?(name)
|
121
|
-
raise(OverlayCached,"overlay #{name.dump} already present in the cache #{self.to_s.dump}",caller)
|
122
|
-
end
|
123
|
-
|
124
|
-
self << repo
|
125
|
-
|
126
|
-
block.call(self) if block
|
127
|
-
return self
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# Removes the _repo_ from the cache. If a _block_ is given, it
|
132
|
-
# will be passed the cache. The cache will be returned, after the
|
133
|
-
# _repo_ is removed.
|
134
|
-
#
|
135
|
-
# cache.remove(repo) # => Cache
|
136
|
-
#
|
137
|
-
# cache.remove(repo) do |cache|
|
138
|
-
# puts "Overlay #{repo} removed"
|
139
|
-
# end
|
140
|
-
#
|
141
|
-
def remove(repo,&block)
|
142
|
-
name = repo.name.to_s
|
143
|
-
|
144
|
-
unless has_overlay?(name)
|
145
|
-
raise(OverlayNotFound,"overlay #{name.dump} is not present in the cache #{self.to_s.dump}",caller)
|
146
|
-
end
|
147
|
-
|
148
|
-
delete_if { |key,value| key == name }
|
149
|
-
|
150
|
-
block.call(self) if block
|
151
|
-
return self
|
152
|
-
end
|
153
|
-
|
154
|
-
#
|
155
|
-
# Updates all the cached Overlays. If a _block_ is given it will
|
156
|
-
# be passed the cache.
|
157
|
-
#
|
158
|
-
# update # => Cache
|
159
|
-
#
|
160
|
-
# update do |cache|
|
161
|
-
# puts "#{cache} is updated"
|
162
|
-
# end
|
163
|
-
#
|
164
|
-
def update(&block)
|
165
|
-
repos.each { |repo| repo.update }
|
166
|
-
|
167
|
-
block.call(self) if block
|
168
|
-
return self
|
169
|
-
end
|
170
|
-
|
171
|
-
#
|
172
|
-
# Saves the cache to the given _output_path_, where _output_path_
|
173
|
-
# defaults to +@path+. If a _block_ is given, it will be passed
|
174
|
-
# the cache before the cache has been saved.
|
175
|
-
#
|
176
|
-
def save(output_path=@path,&block)
|
177
|
-
parent_dir = File.dirname(output_path)
|
178
|
-
|
179
|
-
unless File.directory?(parent_dir)
|
180
|
-
FileUtils.mkdir_p(parent_dir)
|
181
|
-
end
|
182
|
-
|
183
|
-
block.call(self) if block
|
184
|
-
|
185
|
-
File.open(output_path,'w') do |output|
|
186
|
-
descriptions = overlays.map do |repo|
|
187
|
-
{
|
188
|
-
:media_type => repo.media_type,
|
189
|
-
:path => repo.path,
|
190
|
-
:uri => repo.uri
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
YAML.dump(descriptions,output)
|
195
|
-
end
|
196
|
-
|
197
|
-
return self
|
198
|
-
end
|
199
|
-
|
200
|
-
#
|
201
|
-
# Adds the specified _repo_ to the cache.
|
202
|
-
#
|
203
|
-
def <<(repo)
|
204
|
-
self[repo.name.to_s] = repo
|
205
|
-
end
|
206
|
-
|
207
|
-
#
|
208
|
-
# Returns the +path+ of the cache.
|
209
|
-
#
|
210
|
-
def to_s
|
211
|
-
@path.to_s
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
@@ -1,24 +0,0 @@
|
|
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 'ronin/formatting/extensions/html/string'
|
@@ -1,75 +0,0 @@
|
|
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 'ronin/formatting/extensions/text'
|
25
|
-
|
26
|
-
require 'scanf'
|
27
|
-
require 'cgi'
|
28
|
-
require 'hpricot'
|
29
|
-
|
30
|
-
class String
|
31
|
-
|
32
|
-
#
|
33
|
-
# Returns the HTML decimal decoded form of the string.
|
34
|
-
#
|
35
|
-
# "x > y".html_encode
|
36
|
-
# # => "x > y"
|
37
|
-
#
|
38
|
-
def html_encode
|
39
|
-
CGI.escapeHTML(self)
|
40
|
-
end
|
41
|
-
|
42
|
-
#
|
43
|
-
# Returns the HTML decimal decoded form of the string.
|
44
|
-
#
|
45
|
-
# "<rock on>".html_decode
|
46
|
-
# # => "<rock on>"
|
47
|
-
#
|
48
|
-
# "coffee".html_decode
|
49
|
-
# # => "coffee"
|
50
|
-
#
|
51
|
-
def html_decode
|
52
|
-
CGI.unescapeHTML(self)
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# Returns the HTML decimal encoded form of the string.
|
57
|
-
#
|
58
|
-
# "hello".format_html
|
59
|
-
# # => "hello"
|
60
|
-
#
|
61
|
-
def format_html(options={})
|
62
|
-
format_bytes(options) { |c| sprintf("&#%d;",c) }
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Returns the inner text of the String.
|
67
|
-
#
|
68
|
-
# "This page is <b>restricted</b>.".strip_html
|
69
|
-
# # => "This page is restricted."
|
70
|
-
#
|
71
|
-
def strip_html
|
72
|
-
Hpricot(self).inner_text
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
@@ -1,24 +0,0 @@
|
|
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 'ronin/formatting/extensions/html'
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'ronin/formatting/html'
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe String do
|
6
|
-
before(:all) do
|
7
|
-
@raw_text = "x > y && y != 0"
|
8
|
-
@html_encoded_text = "x > y && y != 0"
|
9
|
-
@html_formatted_text = "x > y && y != 0"
|
10
|
-
|
11
|
-
@raw_html = "<p>Hello <strong>dude</strong></p>"
|
12
|
-
@stripped_text = "Hello dude"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should provide String#html_encode" do
|
16
|
-
@raw_text.respond_to?('html_encode').should == true
|
17
|
-
end
|
18
|
-
|
19
|
-
it "String#html_encode should HTML encode itself" do
|
20
|
-
@raw_text.html_encode.should == @html_encoded_text
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should provide String#html_decode" do
|
24
|
-
@raw_text.respond_to?('html_decode').should == true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "String#html_decode should HTML decode itself" do
|
28
|
-
@html_encoded_text.html_decode.should == @raw_text
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should provide String#strip_html" do
|
32
|
-
@raw_text.respond_to?('strip_html').should == true
|
33
|
-
end
|
34
|
-
|
35
|
-
it "String#strip_html should strip any HTML from itself" do
|
36
|
-
@raw_html.strip_html.should == @stripped_text
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should provide String#format_html" do
|
40
|
-
@raw_text.respond_to?('format_html').should == true
|
41
|
-
end
|
42
|
-
|
43
|
-
it "String#format_html should format each byte of the String" do
|
44
|
-
@raw_text.format_html.should == @html_formatted_text
|
45
|
-
end
|
46
|
-
end
|
data/spec/platform_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'ronin/platform'
|
2
|
-
|
3
|
-
require 'helpers/database'
|
4
|
-
|
5
|
-
describe Platform do
|
6
|
-
it "should require os and version attributes" do
|
7
|
-
@platform = Platform.new
|
8
|
-
@platform.should_not be_valid
|
9
|
-
|
10
|
-
@platform.os = 'test'
|
11
|
-
@platform.should_not be_valid
|
12
|
-
|
13
|
-
@platform.version = '0.0.1'
|
14
|
-
@platform.should be_valid
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should provide methods for creating platforms for built-in OSes" do
|
18
|
-
Platform.linux.should_not be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should provide methods for creating platforms for built-in OSes with versions" do
|
22
|
-
Platform.linux_version('2.6.11').should be_valid
|
23
|
-
end
|
24
|
-
end
|