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.
Files changed (76) hide show
  1. data.tar.gz.sig +2 -0
  2. data/History.txt +43 -0
  3. data/Manifest.txt +27 -10
  4. data/README.txt +2 -1
  5. data/Rakefile +12 -11
  6. data/TODO.txt +8 -0
  7. data/bin/{ronin-ls → ronin-list} +2 -2
  8. data/bin/{ronin-rm → ronin-remove} +2 -2
  9. data/lib/ronin/cacheable.rb +25 -4
  10. data/lib/ronin/code/reference.rb +0 -9
  11. data/lib/ronin/code/symbol_table.rb +5 -5
  12. data/lib/ronin/code/token.rb +1 -1
  13. data/lib/ronin/database/database.rb +3 -1
  14. data/lib/ronin/extensions/kernel.rb +25 -3
  15. data/lib/ronin/formatting/extensions/binary/file.rb +60 -0
  16. data/lib/ronin/formatting/extensions/text.rb +1 -0
  17. data/lib/ronin/formatting/extensions/text/array.rb +67 -0
  18. data/lib/ronin/model.rb +1 -40
  19. data/lib/ronin/{has_license.rb → model/has_description.rb} +16 -18
  20. data/lib/ronin/model/has_license.rb +53 -0
  21. data/lib/ronin/model/has_name.rb +49 -0
  22. data/lib/ronin/model/has_version.rb +46 -0
  23. data/lib/ronin/model/model.rb +64 -0
  24. data/lib/ronin/network/extensions/http/net.rb +580 -99
  25. data/lib/ronin/network/http.rb +54 -6
  26. data/lib/ronin/os.rb +7 -7
  27. data/lib/ronin/platform/extension.rb +4 -6
  28. data/lib/ronin/platform/maintainer.rb +1 -1
  29. data/lib/ronin/platform/object_cache.rb +10 -2
  30. data/lib/ronin/platform/overlay_cache.rb +1 -1
  31. data/lib/ronin/platform/platform.rb +5 -3
  32. data/lib/ronin/platform/ronin.rb +3 -3
  33. data/lib/ronin/scanners.rb +25 -0
  34. data/lib/ronin/scanners/exceptions.rb +24 -0
  35. data/lib/ronin/scanners/exceptions/unknown_category.rb +29 -0
  36. data/lib/ronin/scanners/scanner.rb +239 -0
  37. data/lib/ronin/sessions/http.rb +548 -7
  38. data/lib/ronin/{translators.rb → templates.rb} +1 -1
  39. data/lib/ronin/templates/erb.rb +56 -0
  40. data/lib/ronin/ui/command_line/command_line.rb +10 -1
  41. data/lib/ronin/ui/command_line/commands/{ls.rb → list.rb} +1 -1
  42. data/lib/ronin/ui/command_line/commands/{rm.rb → remove.rb} +1 -1
  43. data/lib/ronin/ui/command_line/commands/uninstall.rb +2 -2
  44. data/lib/ronin/ui/console.rb +66 -17
  45. data/lib/ronin/ui/shell.rb +16 -36
  46. data/lib/ronin/version.rb +1 -1
  47. data/spec/cacheable_spec.rb +1 -1
  48. data/spec/code/classes/thing.rb +4 -0
  49. data/spec/code/reference_spec.rb +4 -0
  50. data/spec/code/symbol_table_spec.rb +5 -1
  51. data/spec/extensions/kernel_spec.rb +45 -5
  52. data/spec/extensions/string_spec.rb +4 -0
  53. data/spec/formatting/binary/integer_spec.rb +3 -3
  54. data/spec/formatting/binary/string_spec.rb +5 -5
  55. data/spec/formatting/digest/string_spec.rb +5 -9
  56. data/spec/formatting/http/string_spec.rb +5 -9
  57. data/spec/formatting/text/array_spec.rb +64 -0
  58. data/spec/formatting/text/string_spec.rb +3 -3
  59. data/spec/model/classes/licensed_model.rb +12 -0
  60. data/spec/{has_license_spec.rb → model/has_license_spec.rb} +5 -5
  61. data/spec/network/http_spec.rb +197 -0
  62. data/spec/os_spec.rb +2 -5
  63. data/spec/platform/maintainer_spec.rb +30 -0
  64. data/spec/platform/ronin_spec.rb +2 -2
  65. data/spec/scanners/classes/another_scanner.rb +16 -0
  66. data/spec/scanners/classes/example_scanner.rb +22 -0
  67. data/spec/scanners/scanner_spec.rb +148 -0
  68. data/spec/spec_helper.rb +1 -1
  69. data/spec/templates/classes/uses_erb.rb +11 -0
  70. data/spec/templates/erb_spec.rb +20 -0
  71. data/static/ronin/platform/overlay.xsl +128 -49
  72. metadata +83 -30
  73. metadata.gz.sig +0 -0
  74. data/lib/ronin/translators/translator.rb +0 -75
  75. data/spec/classes/licensed_model.rb +0 -12
  76. data/spec/translators/translator_spec.rb +0 -61
@@ -96,4 +96,8 @@ describe String do
96
96
  it "should dump strings containing non-printable characters" do
97
97
  "hello\x90\x05\xef".dump.should == '"hello\x90\x05\xef"'
98
98
  end
99
+
100
+ it "should dump the string when calling the inspect method" do
101
+ "hello\x90\x05\xef".inspect.should == '"hello\x90\x05\xef"'
102
+ end
99
103
  end
@@ -4,15 +4,15 @@ require 'spec_helper'
4
4
 
5
5
  describe Integer do
6
6
  it "should provide Integer#bytes" do
7
- Integer.instance_method('bytes').should_not be_nil
7
+ Integer.method_defined?(:bytes).should == true
8
8
  end
9
9
 
10
10
  it "should provide Integer#pack" do
11
- Integer.instance_method('pack').should_not be_nil
11
+ Integer.method_defined?(:pack).should == true
12
12
  end
13
13
 
14
14
  it "should provide Integer#hex_escape" do
15
- Integer.instance_method('hex_escape').should_not be_nil
15
+ Integer.method_defined?(:hex_escape).should == true
16
16
  end
17
17
 
18
18
  describe "bytes" do
@@ -5,23 +5,23 @@ require 'formatting/binary/helpers/hexdumps'
5
5
 
6
6
  describe String do
7
7
  it "should provide String#depack" do
8
- String.instance_method('depack').should_not be_nil
8
+ String.method_defined?(:depack).should == true
9
9
  end
10
10
 
11
11
  it "should provide String#hex_escape" do
12
- String.instance_method('hex_escape').should_not be_nil
12
+ String.method_defined?(:hex_escape).should == true
13
13
  end
14
14
 
15
15
  it "should provide String#hex_unescape" do
16
- String.instance_method('hex_unescape').should_not be_nil
16
+ String.method_defined?(:hex_unescape).should == true
17
17
  end
18
18
 
19
19
  it "should provide String#xor" do
20
- String.instance_method('xor').should_not be_nil
20
+ String.method_defined?(:xor).should == true
21
21
  end
22
22
 
23
23
  it "should provide String#unhexdump" do
24
- String.instance_method('unhexdump').should_not be_nil
24
+ String.method_defined?(:unhexdump).should == true
25
25
  end
26
26
 
27
27
  describe "depack" do
@@ -3,28 +3,24 @@ require 'ronin/formatting/digest'
3
3
  require 'spec_helper'
4
4
 
5
5
  describe String do
6
- before(:all) do
7
- @string = "test"
8
- end
9
-
10
6
  it "should provide String#md5" do
11
- @string.respond_to?('md5').should == true
7
+ String.method_defined?(:md5).should == true
12
8
  end
13
9
 
14
10
  it "should provide String#sha1" do
15
- @string.respond_to?('sha1').should == true
11
+ String.method_defined?(:sha1).should == true
16
12
  end
17
13
 
18
14
  it "should provide String#sha2" do
19
- @string.respond_to?('sha2').should == true
15
+ String.method_defined?(:sha2).should == true
20
16
  end
21
17
 
22
18
  it "should provide String#sha256" do
23
- @string.respond_to?('sha256').should == true
19
+ String.method_defined?(:sha256).should == true
24
20
  end
25
21
 
26
22
  it "should provide String#sha512" do
27
- @string.respond_to?('sha512').should == true
23
+ String.method_defined?(:sha512).should == true
28
24
  end
29
25
 
30
26
  describe "md5" do
@@ -3,28 +3,24 @@ require 'ronin/formatting/http'
3
3
  require 'spec_helper'
4
4
 
5
5
  describe String do
6
- before(:all) do
7
- @string = "mod % 3"
8
- end
9
-
10
6
  it "should provide String#uri_encode" do
11
- @string.respond_to?('uri_encode').should == true
7
+ String.method_defined?(:uri_encode).should == true
12
8
  end
13
9
 
14
10
  it "should provide String#uri_decode" do
15
- @string.respond_to?('uri_decode').should == true
11
+ String.method_defined?(:uri_decode).should == true
16
12
  end
17
13
 
18
14
  it "should provide String#uri_escape" do
19
- @string.respond_to?('uri_escape').should == true
15
+ String.method_defined?(:uri_escape).should == true
20
16
  end
21
17
 
22
18
  it "should provide String#uri_unescape" do
23
- @string.respond_to?('uri_unescape').should == true
19
+ String.method_defined?(:uri_unescape).should == true
24
20
  end
25
21
 
26
22
  it "should provide String#format_http" do
27
- @string.respond_to?('format_http').should == true
23
+ String.method_defined?(:format_http).should == true
28
24
  end
29
25
 
30
26
  describe "uri_encode" do
@@ -0,0 +1,64 @@
1
+ require 'ronin/formatting/text'
2
+
3
+ describe Array do
4
+ before(:all) do
5
+ @byte_array = [0x41, 0x41, 0x20]
6
+ @char_array = ['A', 'A', ' ']
7
+ @mixed_array = ['AA', 0x20]
8
+ @string = 'AA '
9
+ end
10
+
11
+ it "should provide Array#bytes" do
12
+ Array.method_defined?(:bytes).should == true
13
+ end
14
+
15
+ it "should provide Array#chars" do
16
+ Array.method_defined?(:chars).should == true
17
+ end
18
+
19
+ it "should provide Array#char_string" do
20
+ Array.method_defined?(:char_string).should == true
21
+ end
22
+
23
+ describe "bytes" do
24
+ it "should convert an Array of bytes to an Array of bytes" do
25
+ @byte_array.bytes.should == @byte_array
26
+ end
27
+
28
+ it "should convert an Array of chars to an Array of bytes" do
29
+ @char_array.bytes.should == @byte_array
30
+ end
31
+
32
+ it "should safely handle mixed byte/char/string Arrays" do
33
+ @mixed_array.bytes.should == @byte_array
34
+ end
35
+ end
36
+
37
+ describe "chars" do
38
+ it "should convert an Array of bytes to an Array of chars" do
39
+ @byte_array.chars.should == @char_array
40
+ end
41
+
42
+ it "should safely convert an Array of chars to an Array of chars" do
43
+ @char_array.chars.should == @char_array
44
+ end
45
+
46
+ it "should safely handle mixed byte/char/string Arrays" do
47
+ @mixed_array.chars.should == @char_array
48
+ end
49
+ end
50
+
51
+ describe "char_string" do
52
+ it "should convert an Array of bytes to a String" do
53
+ @byte_array.char_string.should == @string
54
+ end
55
+
56
+ it "should convert an Array of chars to a String" do
57
+ @char_array.char_string.should == @string
58
+ end
59
+
60
+ it "should safely handle mixed byte/char/string Arrays" do
61
+ @mixed_array.char_string.should == @string
62
+ end
63
+ end
64
+ end
@@ -8,15 +8,15 @@ describe String do
8
8
  end
9
9
 
10
10
  it "should provide String#format_chars" do
11
- @string.respond_to?('format_chars').should == true
11
+ String.method_defined?(:format_chars).should == true
12
12
  end
13
13
 
14
14
  it "should provide String#format_bytes" do
15
- @string.respond_to?('format_bytes').should == true
15
+ String.method_defined?(:format_bytes).should == true
16
16
  end
17
17
 
18
18
  it "should provide String#random_case" do
19
- @string.respond_to?('random_case').should == true
19
+ String.method_defined?(:random_case).should == true
20
20
  end
21
21
 
22
22
  describe "format_chars" do
@@ -0,0 +1,12 @@
1
+ require 'ronin/model/has_license'
2
+
3
+ class LicensedModel
4
+
5
+ include Ronin::Model
6
+ include Ronin::Model::HasLicense
7
+
8
+ property :id, Serial
9
+
10
+ property :content, String
11
+
12
+ end
@@ -1,9 +1,9 @@
1
- require 'ronin/has_license'
1
+ require 'ronin/model/has_license'
2
2
 
3
3
  require 'spec_helper'
4
- require 'classes/licensed_model'
4
+ require 'model/classes/licensed_model'
5
5
 
6
- describe HasLicense do
6
+ describe Model::HasLicense do
7
7
  before(:all) do
8
8
  LicensedModel.auto_migrate!
9
9
  end
@@ -11,7 +11,7 @@ describe HasLicense do
11
11
  it "should have a license" do
12
12
  model = LicensedModel.new(:content => 'bla')
13
13
  model.license = License.gpl_2
14
- model.save!
14
+ model.save
15
15
 
16
16
  model.license.should == License.gpl_2
17
17
  end
@@ -19,7 +19,7 @@ describe HasLicense do
19
19
  it "should provide helper methods for querying licensed models" do
20
20
  model = LicensedModel.new(:content => 'stuff here')
21
21
  model.license = License.gpl_2
22
- model.save!
22
+ model.save
23
23
  model.reload
24
24
 
25
25
  LicensedModel.all(
@@ -0,0 +1,197 @@
1
+ require 'ronin/network/http'
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Network::HTTP do
6
+ describe "HTTP.expand_options" do
7
+ it "should added a default port and path" do
8
+ options = {:host => 'example.com'}
9
+ expanded_options = Network::HTTP.expand_options(options)
10
+
11
+ expanded_options[:port].should == 80
12
+ expanded_options[:path].should == '/'
13
+ end
14
+
15
+ it "should add the default proxy settings" do
16
+ options = {:host => 'example.com'}
17
+ expanded_options = Network::HTTP.expand_options(options)
18
+
19
+ expanded_options[:proxy].should == Network::HTTP.proxy
20
+ end
21
+
22
+ it "should expand the :url option" do
23
+ options = {:url => 'http://joe:secret@example.com:8080/bla?var'}
24
+ expanded_options = Network::HTTP.expand_options(options)
25
+
26
+ expanded_options[:url].should be_nil
27
+ expanded_options[:host].should == 'example.com'
28
+ expanded_options[:port].should == 8080
29
+ expanded_options[:user].should == 'joe'
30
+ expanded_options[:password].should == 'secret'
31
+ expanded_options[:path].should == '/bla?var'
32
+ end
33
+
34
+ it "should add a default :path option for :url options" do
35
+ options = {:url => 'http://example.com'}
36
+ expanded_options = Network::HTTP.expand_options(options)
37
+
38
+ expanded_options[:path].should == '/'
39
+ end
40
+ end
41
+
42
+ describe "HTTP.headers" do
43
+ it "should convert Symbol options to HTTP Headers" do
44
+ options = {:user_agent => 'bla', :location => 'test'}
45
+
46
+ Network::HTTP.headers(options).should == {
47
+ 'User-Agent' => 'bla',
48
+ 'Location' => 'test'
49
+ }
50
+ end
51
+
52
+ it "should convert String options to HTTP Headers" do
53
+ options = {'user_agent' => 'bla', 'x-powered-by' => 'PHP'}
54
+
55
+ Network::HTTP.headers(options).should == {
56
+ 'User-Agent' => 'bla',
57
+ 'X-Powered-By' => 'PHP'
58
+ }
59
+ end
60
+
61
+ it "should convert all values to Strings" do
62
+ mtime = Time.now.to_i
63
+ options = {:modified_by => mtime, :x_accept => :gzip}
64
+
65
+ Network::HTTP.headers(options).should == {
66
+ 'Modified-By' => mtime.to_s,
67
+ 'X-Accept' => 'gzip'
68
+ }
69
+ end
70
+ end
71
+
72
+ describe "HTTP.request" do
73
+ it "should handle Symbol names" do
74
+ Network::HTTP.request(
75
+ :method => :get, :path => '/'
76
+ ).class.should == Net::HTTP::Get
77
+ end
78
+
79
+ it "should handle String names" do
80
+ Network::HTTP.request(
81
+ :method => 'GET', :path => '/'
82
+ ).class.should == Net::HTTP::Get
83
+ end
84
+
85
+ it "should raise an UnknownRequest exception for invalid names" do
86
+ lambda {
87
+ Network::HTTP.request(:method => :bla)
88
+ }.should raise_error(Network::HTTP::UnknownRequest)
89
+ end
90
+
91
+ it "should use a default path" do
92
+ lambda {
93
+ Network::HTTP.request(:method => :get)
94
+ }.should_not raise_error(ArgumentError)
95
+ end
96
+
97
+ it "should accept the :user option for Basic-Auth" do
98
+ req = Network::HTTP.request(:method => :get, :user => 'joe')
99
+
100
+ req['authorization'].should == "Basic am9lOg=="
101
+ end
102
+
103
+ it "should accept the :user and :password options for Basic-Auth" do
104
+ req = Network::HTTP.request(
105
+ :method => :get,
106
+ :user => 'joe',
107
+ :password => 'secret'
108
+ )
109
+
110
+ req['authorization'].should == "Basic am9lOnNlY3JldA=="
111
+ end
112
+
113
+ it "should create HTTP Copy requests" do
114
+ req = Network::HTTP.request(:method => :copy)
115
+
116
+ req.class.should == Net::HTTP::Copy
117
+ end
118
+
119
+ it "should create HTTP Delete requests" do
120
+ req = Network::HTTP.request(:method => :delete)
121
+
122
+ req.class.should == Net::HTTP::Delete
123
+ end
124
+
125
+ it "should create HTTP Get requests" do
126
+ req = Network::HTTP.request(:method => :get)
127
+
128
+ req.class.should == Net::HTTP::Get
129
+ end
130
+
131
+ it "should create HTTP Head requests" do
132
+ req = Network::HTTP.request(:method => :head)
133
+
134
+ req.class.should == Net::HTTP::Head
135
+ end
136
+
137
+ it "should create HTTP Lock requests" do
138
+ req = Network::HTTP.request(:method => :lock)
139
+
140
+ req.class.should == Net::HTTP::Lock
141
+ end
142
+
143
+ it "should create HTTP Mkcol requests" do
144
+ req = Network::HTTP.request(:method => :mkcol)
145
+
146
+ req.class.should == Net::HTTP::Mkcol
147
+ end
148
+
149
+ it "should create HTTP Move requests" do
150
+ req = Network::HTTP.request(:method => :move)
151
+
152
+ req.class.should == Net::HTTP::Move
153
+ end
154
+
155
+ it "should create HTTP Options requests" do
156
+ req = Network::HTTP.request(:method => :options)
157
+
158
+ req.class.should == Net::HTTP::Options
159
+ end
160
+
161
+ it "should create HTTP Post requests" do
162
+ req = Network::HTTP.request(:method => :post)
163
+
164
+ req.class.should == Net::HTTP::Post
165
+ end
166
+
167
+ it "should create HTTP Propfind requests" do
168
+ req = Network::HTTP.request(:method => :propfind)
169
+
170
+ req.class.should == Net::HTTP::Propfind
171
+ end
172
+
173
+ it "should create HTTP Proppatch requests" do
174
+ req = Network::HTTP.request(:method => :proppatch)
175
+
176
+ req.class.should == Net::HTTP::Proppatch
177
+ end
178
+
179
+ it "should create HTTP Trace requests" do
180
+ req = Network::HTTP.request(:method => :trace)
181
+
182
+ req.class.should == Net::HTTP::Trace
183
+ end
184
+
185
+ it "should create HTTP Unlock requests" do
186
+ req = Network::HTTP.request(:method => :unlock)
187
+
188
+ req.class.should == Net::HTTP::Unlock
189
+ end
190
+
191
+ it "should raise an ArgumentError when :method is not specified" do
192
+ lambda {
193
+ Network::HTTP.request()
194
+ }.should raise_error(ArgumentError)
195
+ end
196
+ end
197
+ end