ronin 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +39 -0
- data/Manifest.txt +46 -34
- data/README.txt +81 -20
- data/Rakefile +6 -4
- data/TODO.txt +1 -5
- data/bin/ronin +2 -2
- data/lib/ronin.rb +3 -3
- data/lib/ronin/arch.rb +5 -3
- data/lib/ronin/author.rb +2 -1
- data/lib/ronin/cache/cache.rb +78 -0
- data/lib/ronin/cache/extension.rb +6 -6
- data/lib/ronin/cache/extension_cache.rb +3 -21
- data/lib/ronin/{parameters/instance_param.rb → cache/maintainer.rb} +22 -17
- data/lib/ronin/cache/overlay.rb +74 -23
- data/lib/ronin/cache/overlay_cache.rb +3 -21
- data/lib/ronin/chars/char_set.rb +114 -31
- data/lib/ronin/chars/chars.rb +20 -10
- data/lib/ronin/{parameters/param.rb → code/emittable.rb} +29 -11
- data/lib/ronin/code/symbol_table.rb +13 -0
- data/lib/ronin/{parameters/class_param.rb → code/token.rb} +37 -10
- data/lib/ronin/config.rb +33 -0
- data/lib/ronin/context.rb +32 -29
- data/lib/ronin/database.rb +1 -2
- data/lib/ronin/extensions.rb +0 -1
- data/lib/ronin/extensions/string.rb +41 -0
- data/lib/ronin/extensions/uri/query_params.rb +8 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +10 -0
- data/lib/ronin/{program.rb → hexdump.rb} +2 -2
- data/lib/ronin/{parameters/exceptions/missing_param.rb → hexdump/extensions.rb} +2 -6
- data/lib/ronin/{extensions/kernel.rb → hexdump/extensions/file.rb} +8 -6
- data/lib/ronin/{persistence.rb → hexdump/extensions/kernel.rb} +7 -6
- data/lib/ronin/hexdump/hexdump.rb +76 -0
- data/lib/ronin/license.rb +5 -3
- data/lib/ronin/model.rb +4 -2
- data/lib/ronin/models.rb +8 -2
- data/lib/ronin/object_context.rb +89 -62
- data/lib/ronin/rpc/console.rb +6 -4
- data/lib/ronin/rpc/shell.rb +4 -4
- data/lib/ronin/sessions/http.rb +144 -0
- data/lib/ronin/sessions/session.rb +2 -1
- data/lib/ronin/sessions/telnet.rb +3 -1
- data/lib/ronin/sessions/udp.rb +1 -1
- data/lib/ronin/sessions/web.rb +7 -2
- data/lib/ronin/translators/translator.rb +75 -0
- data/lib/ronin/ui/command_line.rb +25 -0
- data/lib/ronin/ui/command_line/command.rb +165 -0
- data/lib/ronin/ui/command_line/command_line.rb +117 -0
- data/lib/ronin/{program → ui/command_line}/commands.rb +12 -9
- data/lib/ronin/ui/command_line/commands/add.rb +75 -0
- data/lib/ronin/{program/commands/help.rb → ui/command_line/commands/default.rb} +26 -17
- data/lib/ronin/ui/command_line/commands/extension.rb +85 -0
- data/lib/ronin/ui/command_line/commands/help.rb +70 -0
- data/lib/ronin/{program → ui/command_line}/commands/install.rb +26 -23
- data/lib/ronin/ui/command_line/commands/list.rb +93 -0
- data/lib/ronin/ui/command_line/commands/overlay.rb +187 -0
- data/lib/ronin/{program/commands/uninstall.rb → ui/command_line/commands/remove.rb} +25 -17
- data/lib/ronin/{program/commands/update.rb → ui/command_line/commands/uninstall.rb} +27 -17
- data/lib/ronin/{program/commands/remove.rb → ui/command_line/commands/update.rb} +24 -18
- data/lib/ronin/{program → ui/command_line}/exceptions.rb +1 -1
- data/lib/ronin/{program → ui/command_line}/exceptions/unknown_command.rb +4 -2
- data/lib/ronin/ui/command_line/options.rb +148 -0
- data/lib/ronin/{console.rb → ui/console.rb} +0 -0
- data/lib/ronin/ui/shell.rb +117 -0
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web.rb +1 -0
- data/lib/ronin/web/extensions.rb +1 -0
- data/lib/ronin/web/extensions/hpricot.rb +5 -0
- data/lib/ronin/web/extensions/hpricot/comment.rb +19 -0
- data/lib/ronin/web/extensions/hpricot/container.rb +46 -0
- data/lib/ronin/web/extensions/hpricot/doc.rb +21 -0
- data/lib/ronin/web/extensions/hpricot/elem.rb +25 -0
- data/lib/ronin/web/extensions/hpricot/tag.rb +19 -0
- data/lib/ronin/web/extensions/hpricot/text.rb +19 -0
- data/lib/ronin/web/web.rb +70 -4
- data/spec/arch_spec.rb +1 -1
- data/spec/author_spec.rb +1 -1
- data/spec/chars/char_set_spec.rb +177 -0
- data/spec/code/symbol_table_spec.rb +6 -0
- data/spec/extensions/string_spec.rb +12 -0
- data/spec/formatting/binary_spec.rb +9 -0
- data/spec/license_spec.rb +1 -1
- data/spec/object_context/object_context_spec.rb +29 -0
- data/spec/platform_spec.rb +1 -1
- data/spec/product_spec.rb +1 -1
- data/spec/ronin_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/spec/target_spec.rb +1 -1
- data/spec/translators/translator_spec.rb +63 -0
- data/spec/web/extensions/hpricot_spec.rb +62 -0
- data/static/extension.rb.erb +16 -0
- data/static/overlay.xsl +103 -0
- data/tasks/spec.rb +2 -0
- metadata +72 -42
- data/FAQ.txt +0 -103
- data/lib/ronin/environment.rb +0 -39
- data/lib/ronin/objects.rb +0 -27
- data/lib/ronin/parameters.rb +0 -27
- data/lib/ronin/parameters/exceptions.rb +0 -25
- data/lib/ronin/parameters/exceptions/param_not_found.rb +0 -29
- data/lib/ronin/parameters/parameters.rb +0 -286
- data/lib/ronin/program/command.rb +0 -203
- data/lib/ronin/program/commands/add.rb +0 -71
- data/lib/ronin/program/commands/list.rb +0 -79
- data/lib/ronin/program/options.rb +0 -201
- data/lib/ronin/program/program.rb +0 -168
- data/lib/ronin/rpc/interactive.rb +0 -55
- data/lib/ronin/rpc/interactive_console.rb +0 -58
- data/lib/ronin/rpc/interactive_shell.rb +0 -59
- data/lib/ronin/shell.rb +0 -81
- data/spec/parameters/parameters_spec.rb +0 -109
@@ -21,14 +21,16 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require '
|
24
|
+
require 'ronin/hexdump/hexdump'
|
25
|
+
|
26
|
+
class File
|
25
27
|
|
26
|
-
module Kernel
|
27
28
|
#
|
28
|
-
#
|
29
|
-
#
|
29
|
+
# Hexdumps the contents of the File at the specified _path_
|
30
|
+
# to the given _output_ stream.
|
30
31
|
#
|
31
|
-
def
|
32
|
-
|
32
|
+
def self.hexdump(path,output=STDOUT)
|
33
|
+
Ronin::Hexdump.dump(self.open(path),output)
|
33
34
|
end
|
35
|
+
|
34
36
|
end
|
@@ -21,12 +21,13 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
25
|
-
require 'ronin/database'
|
24
|
+
require 'ronin/hexdump/hexdump'
|
26
25
|
|
27
|
-
module
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
module Kernel
|
27
|
+
#
|
28
|
+
# Hexdumps the specified _object_ to the given _output_ stream.
|
29
|
+
#
|
30
|
+
def hexdump(object,output=STDOUT)
|
31
|
+
Ronin::Hexdump.dump(object,output)
|
31
32
|
end
|
32
33
|
end
|
@@ -0,0 +1,76 @@
|
|
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
|
+
module Ronin
|
25
|
+
module Hexdump
|
26
|
+
#
|
27
|
+
# Hexdumps the specified _object_ to the given _output_ stream.
|
28
|
+
#
|
29
|
+
def Hexdump.dump(object,output=STDOUT)
|
30
|
+
index = 0
|
31
|
+
offset = 0
|
32
|
+
hex_segment = nil
|
33
|
+
print_segment = nil
|
34
|
+
|
35
|
+
segment = lambda {
|
36
|
+
output.printf(
|
37
|
+
"%.8x %s |%s|\n",
|
38
|
+
index,
|
39
|
+
hex_segment.join(' ').ljust(47).insert(23,' '),
|
40
|
+
print_segment
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
object.each_byte do |b|
|
45
|
+
if offset == 0
|
46
|
+
hex_segment = []
|
47
|
+
print_segment = []
|
48
|
+
end
|
49
|
+
|
50
|
+
hex_segment << ("%.2x" % b)
|
51
|
+
|
52
|
+
print_segment[offset] = case b
|
53
|
+
when (0x20..0x7e)
|
54
|
+
b.chr
|
55
|
+
else
|
56
|
+
'.'
|
57
|
+
end
|
58
|
+
|
59
|
+
offset += 1
|
60
|
+
|
61
|
+
if (offset >= 16)
|
62
|
+
segment.call
|
63
|
+
|
64
|
+
offset = 0
|
65
|
+
index += 16
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
unless offset == 0
|
70
|
+
segment.call
|
71
|
+
end
|
72
|
+
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/ronin/license.rb
CHANGED
@@ -66,9 +66,11 @@ module Ronin
|
|
66
66
|
url = options[:url].to_s
|
67
67
|
|
68
68
|
meta_def(name.to_method_name) do
|
69
|
-
License.first_or_create(
|
70
|
-
|
71
|
-
|
69
|
+
License.first_or_create(
|
70
|
+
:name => name,
|
71
|
+
:description => description,
|
72
|
+
:url => url
|
73
|
+
)
|
72
74
|
end
|
73
75
|
|
74
76
|
return nil
|
data/lib/ronin/model.rb
CHANGED
@@ -21,8 +21,6 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/extensions/meta'
|
25
|
-
|
26
24
|
require 'dm-core'
|
27
25
|
require 'dm-types'
|
28
26
|
require 'dm-serializer'
|
@@ -41,10 +39,14 @@ module Ronin
|
|
41
39
|
include DataMapper::Resource
|
42
40
|
include DataMapper::AutoMigrations
|
43
41
|
|
42
|
+
#
|
43
|
+
# Returns the default repository name for the model.
|
44
|
+
#
|
44
45
|
def self.default_repository_name
|
45
46
|
Model::REPOSITORY_NAME
|
46
47
|
end
|
47
48
|
|
49
|
+
# The class type property
|
48
50
|
property :type, Discriminator
|
49
51
|
end
|
50
52
|
end
|
data/lib/ronin/models.rb
CHANGED
@@ -21,7 +21,13 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/
|
24
|
+
require 'ronin/database'
|
25
25
|
require 'ronin/model'
|
26
26
|
|
27
|
-
|
27
|
+
require 'reverse_require'
|
28
|
+
|
29
|
+
module Ronin
|
30
|
+
Database.setup do
|
31
|
+
require_all 'ronin/models'
|
32
|
+
end
|
33
|
+
end
|
data/lib/ronin/object_context.rb
CHANGED
@@ -25,8 +25,9 @@ require 'ronin/exceptions/unknown_object_context'
|
|
25
25
|
require 'ronin/exceptions/object_context_not_found'
|
26
26
|
require 'ronin/extensions/meta'
|
27
27
|
require 'ronin/context'
|
28
|
+
require 'ronin/model'
|
28
29
|
|
29
|
-
require '
|
30
|
+
require 'parameters'
|
30
31
|
|
31
32
|
module Ronin
|
32
33
|
module ObjectContext
|
@@ -34,19 +35,20 @@ module Ronin
|
|
34
35
|
|
35
36
|
def self.included(base)
|
36
37
|
base.class_eval do
|
37
|
-
include Model
|
38
38
|
include Context
|
39
|
+
include Parameters
|
40
|
+
include Model
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
# The Path to the object context
|
43
|
+
property :object_path, String, :key => true
|
42
44
|
|
43
|
-
|
45
|
+
# The modification timestamp of the object context
|
46
|
+
property :object_timestamp, EpochTime
|
44
47
|
|
45
|
-
|
46
|
-
|
48
|
+
metaclass_def(:objectify) do |name|
|
49
|
+
ObjectContext.object_contexts[name] = self
|
47
50
|
|
48
|
-
|
49
|
-
property :object_timestamp, EpochTime
|
51
|
+
contextify name
|
50
52
|
|
51
53
|
meta_def(:load_object) do |path,*args|
|
52
54
|
ObjectContext.load_object(context_name,path,*args)
|
@@ -71,50 +73,6 @@ module Ronin
|
|
71
73
|
all(*attribs).map { |obj| obj.object }
|
72
74
|
end
|
73
75
|
|
74
|
-
class_def(:object) do
|
75
|
-
self.class.load_object(self.object_path)
|
76
|
-
end
|
77
|
-
|
78
|
-
class_def(:missing?) do
|
79
|
-
if self.object_path
|
80
|
-
return !(File.file?(self.object_path))
|
81
|
-
end
|
82
|
-
|
83
|
-
return false
|
84
|
-
end
|
85
|
-
|
86
|
-
class_def(:stale?) do
|
87
|
-
if self.object_timestamp
|
88
|
-
return File.mtime(self.object_path) > self.object_timestamp
|
89
|
-
end
|
90
|
-
|
91
|
-
return false
|
92
|
-
end
|
93
|
-
|
94
|
-
class_def(:cache) do
|
95
|
-
if self.object_path
|
96
|
-
self.object_timestamp = File.mtime(self.object_path)
|
97
|
-
return save
|
98
|
-
end
|
99
|
-
|
100
|
-
return false
|
101
|
-
end
|
102
|
-
|
103
|
-
class_def(:mirror) do
|
104
|
-
if self.object_path
|
105
|
-
unless File.file?(self.object_path)
|
106
|
-
return destroy
|
107
|
-
else
|
108
|
-
if (!(dirty?) && stale?)
|
109
|
-
destroy
|
110
|
-
return object.cache
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
return false
|
116
|
-
end
|
117
|
-
|
118
76
|
# define Repo-level object loader method
|
119
77
|
Ronin.module_eval %{
|
120
78
|
def ronin_load_#{name}(path,*args,&block)
|
@@ -196,7 +154,11 @@ module Ronin
|
|
196
154
|
# Cache all objects loaded from the specified _path_.
|
197
155
|
#
|
198
156
|
def ObjectContext.cache_objects(path)
|
199
|
-
ObjectContext.load_objects(path).each
|
157
|
+
ObjectContext.load_objects(path).each do |obj|
|
158
|
+
obj.cache
|
159
|
+
end
|
160
|
+
|
161
|
+
return nil
|
200
162
|
end
|
201
163
|
|
202
164
|
#
|
@@ -207,10 +169,7 @@ module Ronin
|
|
207
169
|
directory = File.expand_path(directory)
|
208
170
|
paths = Dir[File.join(directory,'**','*.rb')]
|
209
171
|
|
210
|
-
paths.each
|
211
|
-
ObjectContext.load_objects(path).each { |obj| obj.cache }
|
212
|
-
end
|
213
|
-
|
172
|
+
paths.each { |path| ObjectContext.cache_objects(path) }
|
214
173
|
return nil
|
215
174
|
end
|
216
175
|
|
@@ -221,17 +180,18 @@ module Ronin
|
|
221
180
|
#
|
222
181
|
def ObjectContext.mirror_objects_in(directory)
|
223
182
|
directory = File.expand_path(directory)
|
224
|
-
|
183
|
+
new_paths = Dir[File.join(directory,'**','*.rb')]
|
225
184
|
|
226
185
|
ObjectContext.object_contexts.each_value do |base|
|
227
186
|
objects = base.all(:object_path.like => "#{directory}%")
|
228
|
-
|
187
|
+
new_paths -= objects.map { |obj| obj.object_path }
|
229
188
|
|
189
|
+
# mirror existing objects
|
230
190
|
objects.each { |obj| obj.mirror }
|
231
191
|
end
|
232
192
|
|
233
|
-
|
234
|
-
|
193
|
+
# cache the remaining new paths
|
194
|
+
new_paths.each { |path| ObjectContext.cache_objects(path) }
|
235
195
|
return nil
|
236
196
|
end
|
237
197
|
|
@@ -247,5 +207,72 @@ module Ronin
|
|
247
207
|
|
248
208
|
return nil
|
249
209
|
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# Returns a new object loaded from the file pointed to by the
|
213
|
+
# +object_path+ property.
|
214
|
+
#
|
215
|
+
def object
|
216
|
+
self.class.load_object(self.object_path)
|
217
|
+
end
|
218
|
+
|
219
|
+
#
|
220
|
+
# Returns +true+ if the file pointed to by the +object_path+
|
221
|
+
# property is missing, returns +false+ otherwise.
|
222
|
+
#
|
223
|
+
def missing?
|
224
|
+
if self.object_path
|
225
|
+
return !(File.file?(self.object_path))
|
226
|
+
end
|
227
|
+
|
228
|
+
return false
|
229
|
+
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# Returns +true+ if the +object_timestamp+ property is older than
|
233
|
+
# the modification time on the file pointed to by the +object_path+
|
234
|
+
# property, returns +false+ otherwise.
|
235
|
+
#
|
236
|
+
def stale?
|
237
|
+
if self.object_timestamp
|
238
|
+
return File.mtime(self.object_path) > self.object_timestamp
|
239
|
+
end
|
240
|
+
|
241
|
+
return false
|
242
|
+
end
|
243
|
+
|
244
|
+
#
|
245
|
+
# Sets the +object_timestamp+ property to the modification time of the
|
246
|
+
# file pointed to by the +object_path+ property and saves the object.
|
247
|
+
#
|
248
|
+
def cache
|
249
|
+
if self.object_path
|
250
|
+
self.object_timestamp = File.mtime(self.object_path)
|
251
|
+
return save
|
252
|
+
end
|
253
|
+
|
254
|
+
return false
|
255
|
+
end
|
256
|
+
|
257
|
+
#
|
258
|
+
# If the file pointed to by the +object_path+ property is missing, the
|
259
|
+
# object will be destroyed. If the object has not been changed and
|
260
|
+
# is stale?, a newly loaded object from the file pointed to by the
|
261
|
+
# +object_path+ property will be cached.
|
262
|
+
#
|
263
|
+
def mirror
|
264
|
+
if self.object_path
|
265
|
+
unless File.file?(self.object_path)
|
266
|
+
return destroy
|
267
|
+
else
|
268
|
+
if (!(dirty?) && stale?)
|
269
|
+
destroy
|
270
|
+
return object.cache
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
return false
|
276
|
+
end
|
250
277
|
end
|
251
278
|
end
|
data/lib/ronin/rpc/console.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require 'ronin/rpc/service'
|
25
|
-
require 'ronin/
|
25
|
+
require 'ronin/ui/shell'
|
26
26
|
|
27
27
|
module Ronin
|
28
28
|
module RPC
|
@@ -58,11 +58,13 @@ module Ronin
|
|
58
58
|
end
|
59
59
|
|
60
60
|
#
|
61
|
-
# Starts
|
62
|
-
#
|
61
|
+
# Starts a Shell that allows a user to execute PHP expressions and
|
62
|
+
# observe their results.
|
63
63
|
#
|
64
64
|
def interact
|
65
|
-
|
65
|
+
UI::Shell.start(:prompt => '>>') do |shell,line|
|
66
|
+
shell.puts "=> #{inspect(line)}"
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
70
|
protected
|
data/lib/ronin/rpc/shell.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require 'ronin/rpc/service'
|
25
|
-
require 'ronin/
|
25
|
+
require 'ronin/ui/shell'
|
26
26
|
|
27
27
|
module Ronin
|
28
28
|
module RPC
|
@@ -45,11 +45,11 @@ module Ronin
|
|
45
45
|
end
|
46
46
|
|
47
47
|
#
|
48
|
-
# Starts
|
49
|
-
#
|
48
|
+
# Starts a Shell that allows a user to execute commands and observe
|
49
|
+
# their output.
|
50
50
|
#
|
51
51
|
def interact
|
52
|
-
|
52
|
+
UI::Shell.start(:prompt => '$') { |shell,line| system(line) }
|
53
53
|
end
|
54
54
|
|
55
55
|
protected
|
@@ -0,0 +1,144 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin - A ruby development platform designed for information security
|
4
|
+
# and data 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/sessions/session'
|
25
|
+
require 'ronin/network/http'
|
26
|
+
require 'ronin/network/extensions/http'
|
27
|
+
|
28
|
+
module Ronin
|
29
|
+
module Sessions
|
30
|
+
module HTTP
|
31
|
+
include Session
|
32
|
+
|
33
|
+
setup_session do
|
34
|
+
parameter :http_user, :description => 'HTTP user'
|
35
|
+
parameter :http_password, :description => 'HTTP password'
|
36
|
+
|
37
|
+
parameter :http_proxy, :description => 'HTTP Proxy'
|
38
|
+
|
39
|
+
parameter :http_user_agent, :description => 'Web User-Agent'
|
40
|
+
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
#
|
45
|
+
# Resets the HTTP proxy settings.
|
46
|
+
#
|
47
|
+
def disable_http_proxy
|
48
|
+
@http_proxy = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Connects to the HTTP server using the given _options_. If a _block_
|
53
|
+
# is given it will be passed the newly created <tt>Net::HTTP</tt>
|
54
|
+
# object.
|
55
|
+
#
|
56
|
+
# _options_ may contain the following keys:
|
57
|
+
# <tt>:host</tt>:: The host the HTTP server is running on.
|
58
|
+
# <tt>:port</tt>:: The port the HTTP server is running on. Defaults to
|
59
|
+
# <tt>Net::HTTP.default_port</tt>.
|
60
|
+
# <tt>:url</tt>:: The full URL to request.
|
61
|
+
# <tt>:user</tt>:: The user to authenticate with when connecting to the
|
62
|
+
# HTTP server.
|
63
|
+
# <tt>:password</tt>:: The password to authenticate with when
|
64
|
+
# connecting to the HTTP server.
|
65
|
+
# <tt>:path</tt>:: The path to request from the HTTP server.
|
66
|
+
#
|
67
|
+
def http_session(options={},&block)
|
68
|
+
Net.http_session(http_merge_options(options),&block)
|
69
|
+
end
|
70
|
+
|
71
|
+
def http_copy(options={},&block)
|
72
|
+
Net.http_copy(http_merge_options(options),&block)
|
73
|
+
end
|
74
|
+
|
75
|
+
def http_delete(options={},&block)
|
76
|
+
Net.http_delete(http_merge_options(options),&block)
|
77
|
+
end
|
78
|
+
|
79
|
+
def http_get(options={},&block)
|
80
|
+
Net.http_get(http_merge_options(options),&block)
|
81
|
+
end
|
82
|
+
|
83
|
+
def http_get_body(options={},&block)
|
84
|
+
Net.http_get_body(http_merge_options(options),&block)
|
85
|
+
end
|
86
|
+
|
87
|
+
def http_head(options={},&block)
|
88
|
+
Net.http_head(http_merge_options(options),&block)
|
89
|
+
end
|
90
|
+
|
91
|
+
def http_lock(options={},&block)
|
92
|
+
Net.http_lock(http_merge_options(options),&block)
|
93
|
+
end
|
94
|
+
|
95
|
+
def http_mkcol(options={},&block)
|
96
|
+
Net.http_mkcol(http_merge_options(options),&block)
|
97
|
+
end
|
98
|
+
|
99
|
+
def http_move(options={},&block)
|
100
|
+
Net.http_move(http_merge_options(options),&block)
|
101
|
+
end
|
102
|
+
|
103
|
+
def http_options(options={},&block)
|
104
|
+
Net.http_options(http_merge_options(options),&block)
|
105
|
+
end
|
106
|
+
|
107
|
+
def http_post(options={},&block)
|
108
|
+
Net.http_post(http_merge_options(options),&block)
|
109
|
+
end
|
110
|
+
|
111
|
+
def http_post_body(options={},&block)
|
112
|
+
Net.http_post_body(http_merge_options(options),&block)
|
113
|
+
end
|
114
|
+
|
115
|
+
def http_prop_find(options={},&block)
|
116
|
+
Net.http_prop_find(http_merge_options(options),&block)
|
117
|
+
end
|
118
|
+
|
119
|
+
def http_prop_path(options={},&block)
|
120
|
+
Net.http_prop_path(http_merge_options(options),&block)
|
121
|
+
end
|
122
|
+
|
123
|
+
def http_trace(options={},&block)
|
124
|
+
Net.http_trace(http_merge_options(options),&block)
|
125
|
+
end
|
126
|
+
|
127
|
+
def http_unlock(options={},&block)
|
128
|
+
Net.http_unlock(http_merge_options(options),&block)
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
def http_merge_options(options={})
|
134
|
+
options[:user] ||= @http_user if @http_user
|
135
|
+
options[:password] ||= @http_password if @http_password
|
136
|
+
|
137
|
+
options[:proxy] ||= @http_proxy if @http_proxy
|
138
|
+
options[:user_agent] ||= @http_user_agent if @http_user_agent
|
139
|
+
|
140
|
+
return options
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|