ronin-support 0.3.0 → 0.4.0.rc1
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/ChangeLog.md +77 -7
- data/README.md +19 -3
- data/gemspec.yml +2 -2
- data/lib/ronin/extensions/regexp.rb +50 -2
- data/lib/ronin/extensions/string.rb +1 -0
- data/lib/ronin/formatting.rb +1 -0
- data/lib/ronin/formatting/extensions.rb +1 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +56 -5
- data/lib/ronin/formatting/extensions/html/string.rb +6 -7
- data/lib/ronin/formatting/extensions/sql/string.rb +34 -0
- data/lib/ronin/formatting/extensions/text/string.rb +0 -180
- data/lib/ronin/fuzzing.rb +21 -0
- data/lib/ronin/fuzzing/extensions.rb +20 -0
- data/lib/ronin/fuzzing/extensions/string.rb +380 -0
- data/lib/ronin/fuzzing/fuzzing.rb +191 -0
- data/lib/ronin/network/esmtp.rb +94 -1
- data/lib/ronin/network/extensions/esmtp/net.rb +2 -82
- data/lib/ronin/network/extensions/http/net.rb +1 -736
- data/lib/ronin/network/extensions/imap/net.rb +1 -103
- data/lib/ronin/network/extensions/pop3/net.rb +1 -71
- data/lib/ronin/network/extensions/smtp/net.rb +2 -157
- data/lib/ronin/network/extensions/ssl/net.rb +1 -132
- data/lib/ronin/network/extensions/tcp/net.rb +2 -296
- data/lib/ronin/network/extensions/telnet/net.rb +1 -135
- data/lib/ronin/network/extensions/udp/net.rb +2 -214
- data/lib/ronin/network/http/http.rb +750 -5
- data/lib/ronin/network/imap.rb +105 -2
- data/lib/ronin/network/mixins.rb +1 -1
- data/lib/ronin/network/mixins/esmtp.rb +49 -52
- data/lib/ronin/network/mixins/http.rb +49 -53
- data/lib/ronin/network/mixins/imap.rb +47 -44
- data/lib/ronin/network/mixins/mixin.rb +58 -0
- data/lib/ronin/network/mixins/pop3.rb +44 -38
- data/lib/ronin/network/mixins/smtp.rb +49 -51
- data/lib/ronin/network/mixins/tcp.rb +56 -69
- data/lib/ronin/network/mixins/telnet.rb +57 -50
- data/lib/ronin/network/mixins/udp.rb +48 -52
- data/lib/ronin/network/network.rb +1 -0
- data/lib/ronin/network/pop3.rb +72 -2
- data/lib/ronin/network/smtp/email.rb +1 -0
- data/lib/ronin/network/smtp/smtp.rb +159 -3
- data/lib/ronin/network/ssl.rb +131 -2
- data/lib/ronin/network/tcp.rb +306 -1
- data/lib/ronin/network/telnet.rb +136 -2
- data/lib/ronin/network/udp.rb +229 -1
- data/lib/ronin/support.rb +2 -3
- data/lib/ronin/support/support.rb +38 -0
- data/lib/ronin/support/version.rb +1 -1
- data/lib/ronin/templates/erb.rb +2 -1
- data/lib/ronin/ui/output/helpers.rb +35 -1
- data/lib/ronin/ui/shell.rb +12 -2
- data/lib/ronin/wordlist.rb +157 -0
- data/spec/extensions/regexp_spec.rb +38 -0
- data/spec/formatting/html/string_spec.rb +1 -1
- data/spec/formatting/sql/string_spec.rb +23 -3
- data/spec/formatting/text/string_spec.rb +0 -110
- data/spec/fuzzing/string_spec.rb +158 -0
- data/spec/wordlist_spec.rb +65 -0
- metadata +35 -27
data/lib/ronin/network/esmtp.rb
CHANGED
@@ -17,4 +17,97 @@
|
|
17
17
|
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ronin/network/
|
20
|
+
require 'ronin/network/smtp'
|
21
|
+
|
22
|
+
module Ronin
|
23
|
+
module Network
|
24
|
+
#
|
25
|
+
# Provides helper methods for communicating with ESMTP services.
|
26
|
+
#
|
27
|
+
module ESMTP
|
28
|
+
include SMTP
|
29
|
+
|
30
|
+
#
|
31
|
+
# @see SMTP.message
|
32
|
+
#
|
33
|
+
# @api public
|
34
|
+
#
|
35
|
+
def esmtp_message(options={},&block)
|
36
|
+
smtp_message(options,&block)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Creates a connection to the ESMTP server.
|
41
|
+
#
|
42
|
+
# @param [String] host
|
43
|
+
# The host to connect to.
|
44
|
+
#
|
45
|
+
# @param [Hash] options
|
46
|
+
# Additional options.
|
47
|
+
#
|
48
|
+
# @option options [Integer] :port (SMTP.default_port)
|
49
|
+
# The port to connect to.
|
50
|
+
#
|
51
|
+
# @option options [String] :helo
|
52
|
+
# The HELO domain.
|
53
|
+
#
|
54
|
+
# @option options [Symbol] :auth
|
55
|
+
# The type of authentication to use. Can be either `:login`, `:plain`,
|
56
|
+
# or `:cram_md5`.
|
57
|
+
#
|
58
|
+
# @option options [String] :user
|
59
|
+
# The user-name to authenticate with.
|
60
|
+
#
|
61
|
+
# @option options [String] :password
|
62
|
+
# The password to authenticate with.
|
63
|
+
#
|
64
|
+
# @yield [session]
|
65
|
+
# If a block is given, it will be passed an ESMTP enabled session
|
66
|
+
# object.
|
67
|
+
#
|
68
|
+
# @yieldparam [Net::SMTP] session
|
69
|
+
# The ESMTP session.
|
70
|
+
#
|
71
|
+
# @return [Net::SMTP]
|
72
|
+
# The ESMTP enabled session.
|
73
|
+
#
|
74
|
+
# @api public
|
75
|
+
#
|
76
|
+
def esmtp_connect(host,options={})
|
77
|
+
session = smtp_connect(host,options)
|
78
|
+
session.esmtp = true
|
79
|
+
|
80
|
+
yield session if block_given?
|
81
|
+
return session
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Starts an ESMTP session with the ESMTP enabled server.
|
86
|
+
#
|
87
|
+
# @param [String] host
|
88
|
+
# The host to connect to.
|
89
|
+
#
|
90
|
+
# @param [Hash] options
|
91
|
+
# Additional options.
|
92
|
+
#
|
93
|
+
# @yield [session]
|
94
|
+
# If a block is given, it will be passed an ESMTP enabled session
|
95
|
+
# object. After the block has returned, the session will be closed.
|
96
|
+
#
|
97
|
+
# @yieldparam [Net::SMTP] session
|
98
|
+
# The ESMTP session.
|
99
|
+
#
|
100
|
+
# @see Net.esmtp_connect
|
101
|
+
#
|
102
|
+
# @api public
|
103
|
+
#
|
104
|
+
def esmtp_session(host,options={})
|
105
|
+
smtp_session(host,options) do |session|
|
106
|
+
session.esmtp = true
|
107
|
+
|
108
|
+
yield session if block_given?
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -17,88 +17,8 @@
|
|
17
17
|
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ronin/network/
|
20
|
+
require 'ronin/network/esmtp'
|
21
21
|
|
22
22
|
module Net
|
23
|
-
|
24
|
-
# @see Ronin::Network::SMTP.message
|
25
|
-
#
|
26
|
-
# @api public
|
27
|
-
#
|
28
|
-
def Net.esmtp_message(options={},&block)
|
29
|
-
Net.smtp_message(options,&block)
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Creates a connection to the ESMTP server.
|
34
|
-
#
|
35
|
-
# @param [String] host
|
36
|
-
# The host to connect to.
|
37
|
-
#
|
38
|
-
# @param [Hash] options
|
39
|
-
# Additional options.
|
40
|
-
#
|
41
|
-
# @option options [Integer] :port (Ronin::Network::SMTP.default_port)
|
42
|
-
# The port to connect to.
|
43
|
-
#
|
44
|
-
# @option options [String] :helo
|
45
|
-
# The HELO domain.
|
46
|
-
#
|
47
|
-
# @option options [Symbol] :auth
|
48
|
-
# The type of authentication to use. Can be either `:login`, `:plain`,
|
49
|
-
# or `:cram_md5`.
|
50
|
-
#
|
51
|
-
# @option options [String] :user
|
52
|
-
# The user-name to authenticate with.
|
53
|
-
#
|
54
|
-
# @option options [String] :password
|
55
|
-
# The password to authenticate with.
|
56
|
-
#
|
57
|
-
# @yield [session]
|
58
|
-
# If a block is given, it will be passed an ESMTP enabled session
|
59
|
-
# object.
|
60
|
-
#
|
61
|
-
# @yieldparam [Net::SMTP] session
|
62
|
-
# The ESMTP session.
|
63
|
-
#
|
64
|
-
# @return [Net::SMTP]
|
65
|
-
# The ESMTP enabled session.
|
66
|
-
#
|
67
|
-
# @api public
|
68
|
-
#
|
69
|
-
def Net.esmtp_connect(host,options={})
|
70
|
-
session = Net.smtp_connect(host,options)
|
71
|
-
session.esmtp = true
|
72
|
-
|
73
|
-
yield session if block_given?
|
74
|
-
return session
|
75
|
-
end
|
76
|
-
|
77
|
-
#
|
78
|
-
# Starts an ESMTP session with the ESMTP enabled server.
|
79
|
-
#
|
80
|
-
# @param [String] host
|
81
|
-
# The host to connect to.
|
82
|
-
#
|
83
|
-
# @param [Hash] options
|
84
|
-
# Additional options.
|
85
|
-
#
|
86
|
-
# @yield [session]
|
87
|
-
# If a block is given, it will be passed an ESMTP enabled session
|
88
|
-
# object. After the block has returned, the session will be closed.
|
89
|
-
#
|
90
|
-
# @yieldparam [Net::SMTP] session
|
91
|
-
# The ESMTP session.
|
92
|
-
#
|
93
|
-
# @see Net.esmtp_connect
|
94
|
-
#
|
95
|
-
# @api public
|
96
|
-
#
|
97
|
-
def Net.esmtp_session(host,options={})
|
98
|
-
Net.smtp_session(host,options) do |session|
|
99
|
-
session.esmtp = true
|
100
|
-
|
101
|
-
yield session if block_given?
|
102
|
-
end
|
103
|
-
end
|
23
|
+
extend Ronin::Network::ESMTP
|
104
24
|
end
|
@@ -18,742 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/http'
|
21
|
-
require 'ronin/network/ssl'
|
22
|
-
|
23
|
-
require 'uri/query_params'
|
24
|
-
require 'net/http'
|
25
|
-
|
26
|
-
begin
|
27
|
-
require 'net/https'
|
28
|
-
rescue ::LoadError
|
29
|
-
end
|
30
21
|
|
31
22
|
module Net
|
32
|
-
|
33
|
-
# Starts a HTTP connection with the server.
|
34
|
-
#
|
35
|
-
# @param [Hash] options
|
36
|
-
# Additional options
|
37
|
-
#
|
38
|
-
# @option options [String, URI::HTTP] :url
|
39
|
-
# The full URL to request.
|
40
|
-
#
|
41
|
-
# @option options [String] :host
|
42
|
-
# The host the HTTP server is running on.
|
43
|
-
#
|
44
|
-
# @option options [Integer] :port (Net::HTTP.default_port)
|
45
|
-
# The port the HTTP server is listening on.
|
46
|
-
#
|
47
|
-
# @option options [String, Hash] :proxy (Ronin::Network::HTTP.proxy)
|
48
|
-
# A Hash of proxy settings to use when connecting to the HTTP server.
|
49
|
-
#
|
50
|
-
# @option options [String] :user
|
51
|
-
# The user to authenticate with when connecting to the HTTP server.
|
52
|
-
#
|
53
|
-
# @option options [String] :password
|
54
|
-
# The password to authenticate with when connecting to the HTTP server.
|
55
|
-
#
|
56
|
-
# @option options [Boolean, Hash] :ssl
|
57
|
-
# Enables SSL for the HTTP connection.
|
58
|
-
#
|
59
|
-
# @option :ssl [Symbol] :verify
|
60
|
-
# Specifies the SSL certificate verification mode.
|
61
|
-
#
|
62
|
-
# @yield [session]
|
63
|
-
# If a block is given, it will be passed the newly created HTTP
|
64
|
-
# session object.
|
65
|
-
#
|
66
|
-
# @yieldparam [Net::HTTP] session
|
67
|
-
# The newly created HTTP session.
|
68
|
-
#
|
69
|
-
# @return [Net::HTTP]
|
70
|
-
# The HTTP session object.
|
71
|
-
#
|
72
|
-
# @api public
|
73
|
-
#
|
74
|
-
def Net.http_connect(options={},&block)
|
75
|
-
options = Ronin::Network::HTTP.expand_options(options)
|
76
|
-
|
77
|
-
host = options[:host].to_s
|
78
|
-
port = options[:port]
|
79
|
-
proxy = options[:proxy]
|
80
|
-
proxy_host = if (proxy && proxy[:host])
|
81
|
-
proxy[:host].to_s
|
82
|
-
end
|
83
|
-
|
84
|
-
sess = Net::HTTP::Proxy(
|
85
|
-
proxy_host,
|
86
|
-
proxy[:port],
|
87
|
-
proxy[:user],
|
88
|
-
proxy[:password]
|
89
|
-
).new(host.to_s,port)
|
90
|
-
|
91
|
-
if options[:ssl]
|
92
|
-
sess.use_ssl = true
|
93
|
-
sess.verify_mode = Ronin::Network::SSL::VERIFY[options[:ssl][:verify]]
|
94
|
-
end
|
95
|
-
|
96
|
-
sess.start()
|
97
|
-
|
98
|
-
if block
|
99
|
-
if block.arity == 2
|
100
|
-
block.call(sess,options)
|
101
|
-
else
|
102
|
-
block.call(sess)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
return sess
|
107
|
-
end
|
108
|
-
|
109
|
-
#
|
110
|
-
# Creates a new temporary HTTP session with the server.
|
111
|
-
#
|
112
|
-
# @param [Hash] options
|
113
|
-
# Additional options
|
114
|
-
#
|
115
|
-
# @option options [String, URI::HTTP] :url
|
116
|
-
# The full URL to request.
|
117
|
-
#
|
118
|
-
# @option options [String] :host
|
119
|
-
# The host the HTTP server is running on.
|
120
|
-
#
|
121
|
-
# @option options [Integer] :port (Net::HTTP.default_port)
|
122
|
-
# The port the HTTP server is listening on.
|
123
|
-
#
|
124
|
-
# @option options [String] :user
|
125
|
-
# The user to authenticate with when connecting to the HTTP server.
|
126
|
-
#
|
127
|
-
# @option options [String] :password
|
128
|
-
# The password to authenticate with when connecting to the HTTP server.
|
129
|
-
#
|
130
|
-
# @option options [String, Hash] :proxy (Ronin::Network::HTTP.proxy)
|
131
|
-
# A Hash of proxy settings to use when connecting to the HTTP server.
|
132
|
-
#
|
133
|
-
# @option options [Boolean, Hash] :ssl
|
134
|
-
# Enables SSL for the HTTP connection.
|
135
|
-
#
|
136
|
-
# @option :ssl [Symbol] :verify
|
137
|
-
# Specifies the SSL certificate verification mode.
|
138
|
-
#
|
139
|
-
# @yield [session]
|
140
|
-
# If a block is given, it will be passed the newly created HTTP
|
141
|
-
# session object.
|
142
|
-
#
|
143
|
-
# @yieldparam [Net::HTTP] session
|
144
|
-
# The newly created HTTP session.
|
145
|
-
#
|
146
|
-
# @return [nil]
|
147
|
-
#
|
148
|
-
# @see Net.http_connect
|
149
|
-
#
|
150
|
-
# @api public
|
151
|
-
#
|
152
|
-
def Net.http_session(options={},&block)
|
153
|
-
Net.http_connect(options) do |sess,expanded_options|
|
154
|
-
if block
|
155
|
-
if block.arity == 2
|
156
|
-
block.call(sess,expanded_options)
|
157
|
-
else
|
158
|
-
block.call(sess)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
sess.finish
|
163
|
-
end
|
164
|
-
|
165
|
-
return nil
|
166
|
-
end
|
167
|
-
|
168
|
-
#
|
169
|
-
# Connects to the HTTP server and sends an HTTP Request.
|
170
|
-
#
|
171
|
-
# @param [Hash] options
|
172
|
-
# Additional options.
|
173
|
-
#
|
174
|
-
# @option options [Symbol, String] :method
|
175
|
-
# The HTTP method to use in the request.
|
176
|
-
#
|
177
|
-
# @option options [String] :path
|
178
|
-
# The path to request from the HTTP server.
|
179
|
-
#
|
180
|
-
# @option options [Hash] :headers
|
181
|
-
# The Hash of the HTTP headers to send with the request.
|
182
|
-
# May contain either Strings or Symbols, lower-case or camel-case keys.
|
183
|
-
#
|
184
|
-
# @yield [request, (options)]
|
185
|
-
# If a block is given, it will be passed the HTTP request object.
|
186
|
-
# If the block has an arity of 2, it will also be passed the expanded
|
187
|
-
# version of the given _options_.
|
188
|
-
#
|
189
|
-
# @yieldparam [Net::HTTP::Request] request
|
190
|
-
# The HTTP request object to use in the request.
|
191
|
-
#
|
192
|
-
# @yieldparam [Hash] options
|
193
|
-
# The expanded version of the given _options_.
|
194
|
-
#
|
195
|
-
# @return [Net::HTTP::Response]
|
196
|
-
# The response of the HTTP request.
|
197
|
-
#
|
198
|
-
# @see http_session
|
199
|
-
#
|
200
|
-
# @api public
|
201
|
-
#
|
202
|
-
def Net.http_request(options={},&block)
|
203
|
-
resp = nil
|
204
|
-
|
205
|
-
Net.http_session(options) do |http,expanded_options|
|
206
|
-
req = Ronin::Network::HTTP.request(expanded_options)
|
207
|
-
|
208
|
-
if block
|
209
|
-
if block.arity == 2
|
210
|
-
block.call(req,expanded_options)
|
211
|
-
else
|
212
|
-
block.call(req)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
resp = http.request(req)
|
217
|
-
end
|
218
|
-
|
219
|
-
return resp
|
220
|
-
end
|
221
|
-
|
222
|
-
#
|
223
|
-
# Returns the Status Code of the Response.
|
224
|
-
#
|
225
|
-
# @param [Hash] options
|
226
|
-
# Additional options.
|
227
|
-
#
|
228
|
-
# @option options [Symbol, String] :method (:head)
|
229
|
-
# The method to use for the request.
|
230
|
-
#
|
231
|
-
# @return [Integer]
|
232
|
-
# The HTTP Response Status.
|
233
|
-
#
|
234
|
-
# @see http_request
|
235
|
-
#
|
236
|
-
# @since 0.2.0
|
237
|
-
#
|
238
|
-
# @api public
|
239
|
-
#
|
240
|
-
def Net.http_status(options={})
|
241
|
-
options = {:method => :head}.merge(options)
|
242
|
-
|
243
|
-
return Net.http_request(options).code.to_i
|
244
|
-
end
|
245
|
-
|
246
|
-
#
|
247
|
-
# Checks if the response has an HTTP OK status code.
|
248
|
-
#
|
249
|
-
# @param [Hash] options
|
250
|
-
# Additional options.
|
251
|
-
#
|
252
|
-
# @option options [Symbol, String] :method (:head)
|
253
|
-
# The method to use for the request.
|
254
|
-
#
|
255
|
-
# @return [Boolean]
|
256
|
-
# Specifies whether the response had an HTTP OK status code or not.
|
257
|
-
#
|
258
|
-
# @see http_status
|
259
|
-
#
|
260
|
-
# @api public
|
261
|
-
#
|
262
|
-
def Net.http_ok?(options={})
|
263
|
-
Net.http_status(options) == 200
|
264
|
-
end
|
265
|
-
|
266
|
-
#
|
267
|
-
# Sends a HTTP Head request and returns the HTTP Server header.
|
268
|
-
#
|
269
|
-
# @param [Hash] options
|
270
|
-
# Additional options.
|
271
|
-
#
|
272
|
-
# @option options [Symbol, String] :method (:head)
|
273
|
-
# The method to use for the request.
|
274
|
-
#
|
275
|
-
# @return [String]
|
276
|
-
# The HTTP `Server` header.
|
277
|
-
#
|
278
|
-
# @see http_request
|
279
|
-
#
|
280
|
-
# @api public
|
281
|
-
#
|
282
|
-
def Net.http_server(options={})
|
283
|
-
options = {:method => :head}.merge(options)
|
284
|
-
|
285
|
-
return Net.http_request(options)['server']
|
286
|
-
end
|
287
|
-
|
288
|
-
#
|
289
|
-
# Sends an HTTP Head request and returns the HTTP X-Powered-By header.
|
290
|
-
#
|
291
|
-
# @param [Hash] options
|
292
|
-
# Additional options.
|
293
|
-
#
|
294
|
-
# @option options [Symbol, String] :method (:get)
|
295
|
-
# The method to use for the request.
|
296
|
-
#
|
297
|
-
# @return [String]
|
298
|
-
# The HTTP `X-Powered-By` header.
|
299
|
-
#
|
300
|
-
# @see http_request
|
301
|
-
#
|
302
|
-
# @api public
|
303
|
-
#
|
304
|
-
def Net.http_powered_by(options={})
|
305
|
-
options = {:method => :get}.merge(options)
|
306
|
-
|
307
|
-
return Net.http_request(options)['x-powered-by']
|
308
|
-
end
|
309
|
-
|
310
|
-
#
|
311
|
-
# Performs an HTTP Copy request.
|
312
|
-
#
|
313
|
-
# @param [Hash] options
|
314
|
-
# Additional options.
|
315
|
-
#
|
316
|
-
# @yield [response]
|
317
|
-
# If a block is given, it will be passed the response received
|
318
|
-
# from the request.
|
319
|
-
#
|
320
|
-
# @yieldparam [Net::HTTP::Response] response
|
321
|
-
# The HTTP response object.
|
322
|
-
#
|
323
|
-
# @return [Net::HTTP::Response]
|
324
|
-
# The response of the HTTP request.
|
325
|
-
#
|
326
|
-
# @see http_request
|
327
|
-
#
|
328
|
-
# @api public
|
329
|
-
#
|
330
|
-
def Net.http_copy(options={})
|
331
|
-
resp = Net.http_request(options.merge(:method => :copy))
|
332
|
-
|
333
|
-
yield resp if block_given?
|
334
|
-
return resp
|
335
|
-
end
|
336
|
-
|
337
|
-
#
|
338
|
-
# Performs an HTTP Delete request.
|
339
|
-
#
|
340
|
-
# @param [Hash] options
|
341
|
-
# Additional options.
|
342
|
-
#
|
343
|
-
# @yield [response]
|
344
|
-
# If a block is given, it will be passed the response received from
|
345
|
-
# the request.
|
346
|
-
#
|
347
|
-
# @yieldparam [Net::HTTP::Response] response
|
348
|
-
# The HTTP response object.
|
349
|
-
#
|
350
|
-
# @return [Net::HTTP::Response]
|
351
|
-
# The response of the HTTP request.
|
352
|
-
#
|
353
|
-
# @see http_request
|
354
|
-
#
|
355
|
-
# @api public
|
356
|
-
#
|
357
|
-
def Net.http_delete(options={},&block)
|
358
|
-
original_headers = options[:headers]
|
359
|
-
|
360
|
-
# set the HTTP Depth header
|
361
|
-
options[:headers] = {:depth => 'Infinity'}
|
362
|
-
|
363
|
-
if original_headers
|
364
|
-
options[:header].merge!(original_headers)
|
365
|
-
end
|
366
|
-
|
367
|
-
resp = Net.http_request(options.merge(:method => :delete))
|
368
|
-
|
369
|
-
yield resp if block_given?
|
370
|
-
return resp
|
371
|
-
end
|
372
|
-
|
373
|
-
#
|
374
|
-
# Performs an HTTP Get request.
|
375
|
-
#
|
376
|
-
# @param [Hash] options
|
377
|
-
# Additional options.
|
378
|
-
#
|
379
|
-
# @yield [response]
|
380
|
-
# If a block is given, it will be passed the response received from
|
381
|
-
# the request.
|
382
|
-
#
|
383
|
-
# @yieldparam [Net::HTTP::Response] response
|
384
|
-
# The HTTP response object.
|
385
|
-
#
|
386
|
-
# @return [Net::HTTP::Response]
|
387
|
-
# The response of the HTTP request.
|
388
|
-
#
|
389
|
-
# @see http_request
|
390
|
-
#
|
391
|
-
# @api public
|
392
|
-
#
|
393
|
-
def Net.http_get(options={},&block)
|
394
|
-
resp = Net.http_request(options.merge(:method => :get))
|
395
|
-
|
396
|
-
yield resp if block_given?
|
397
|
-
return resp
|
398
|
-
end
|
399
|
-
|
400
|
-
#
|
401
|
-
# Performs an HTTP Get request and returns the Response Headers.
|
402
|
-
#
|
403
|
-
# @param [Hash] options
|
404
|
-
# Additional options.
|
405
|
-
#
|
406
|
-
# @return [Hash{String => Array<String>}]
|
407
|
-
# The Headers of the HTTP response.
|
408
|
-
#
|
409
|
-
# @see http_get
|
410
|
-
#
|
411
|
-
# @since 0.2.0
|
412
|
-
#
|
413
|
-
# @api public
|
414
|
-
#
|
415
|
-
def Net.http_get_headers(options={})
|
416
|
-
Net.http_get(options).to_hash
|
417
|
-
end
|
418
|
-
|
419
|
-
#
|
420
|
-
# Performs an HTTP Get request and returns the Respond Body.
|
421
|
-
#
|
422
|
-
# @param [Hash] options
|
423
|
-
# Additional options.
|
424
|
-
#
|
425
|
-
# @return [String]
|
426
|
-
# The body of the HTTP response.
|
427
|
-
#
|
428
|
-
# @see http_get
|
429
|
-
#
|
430
|
-
# @api public
|
431
|
-
#
|
432
|
-
def Net.http_get_body(options={})
|
433
|
-
Net.http_get(options).body
|
434
|
-
end
|
435
|
-
|
436
|
-
#
|
437
|
-
# Performs an HTTP Head request.
|
438
|
-
#
|
439
|
-
# @param [Hash] options
|
440
|
-
# Additional options.
|
441
|
-
#
|
442
|
-
# @yield [response]
|
443
|
-
# If a block is given, it will be passed the response received from
|
444
|
-
# the request.
|
445
|
-
#
|
446
|
-
# @yieldparam [Net::HTTP::Response] response
|
447
|
-
# The HTTP response object.
|
448
|
-
#
|
449
|
-
# @return [Net::HTTP::Response]
|
450
|
-
# The response of the HTTP request.
|
451
|
-
#
|
452
|
-
# @see http_request
|
453
|
-
#
|
454
|
-
# @api public
|
455
|
-
#
|
456
|
-
def Net.http_head(options={},&block)
|
457
|
-
resp = Net.http_request(options.merge(:method => :head))
|
458
|
-
|
459
|
-
yield resp if block_given?
|
460
|
-
return resp
|
461
|
-
end
|
462
|
-
|
463
|
-
#
|
464
|
-
# Performs an HTTP Lock request.
|
465
|
-
#
|
466
|
-
# @param [Hash] options
|
467
|
-
# Additional options.
|
468
|
-
#
|
469
|
-
# @yield [response]
|
470
|
-
# If a block is given, it will be passed the response received from
|
471
|
-
# the request.
|
472
|
-
#
|
473
|
-
# @yieldparam [Net::HTTP::Response] response
|
474
|
-
# The HTTP response object.
|
475
|
-
#
|
476
|
-
# @return [Net::HTTP::Response]
|
477
|
-
# The response of the HTTP request.
|
478
|
-
#
|
479
|
-
# @see http_request
|
480
|
-
#
|
481
|
-
# @api public
|
482
|
-
#
|
483
|
-
def Net.http_lock(options={},&block)
|
484
|
-
resp = Net.http_request(options.merge(:method => :lock))
|
485
|
-
|
486
|
-
yield resp if block_given?
|
487
|
-
return resp
|
488
|
-
end
|
489
|
-
|
490
|
-
#
|
491
|
-
# Performs an HTTP Mkcol request.
|
492
|
-
#
|
493
|
-
# @param [Hash] options
|
494
|
-
# Additional options.
|
495
|
-
#
|
496
|
-
# @yield [response]
|
497
|
-
# If a block is given, it will be passed the response received from
|
498
|
-
# the request.
|
499
|
-
#
|
500
|
-
# @yieldparam [Net::HTTP::Response] response
|
501
|
-
# The HTTP response object.
|
502
|
-
#
|
503
|
-
# @return [Net::HTTP::Response]
|
504
|
-
# The response of the HTTP request.
|
505
|
-
#
|
506
|
-
# @see http_request
|
507
|
-
#
|
508
|
-
# @api public
|
509
|
-
#
|
510
|
-
def Net.http_mkcol(options={},&block)
|
511
|
-
resp = Net.http_request(options.merge(:method => :mkcol))
|
512
|
-
|
513
|
-
yield resp if block_given?
|
514
|
-
return resp
|
515
|
-
end
|
516
|
-
|
517
|
-
#
|
518
|
-
# Performs an HTTP Move request.
|
519
|
-
#
|
520
|
-
# @param [Hash] options
|
521
|
-
# Additional options.
|
522
|
-
#
|
523
|
-
# @yield [response]
|
524
|
-
# If a block is given, it will be passed the response received from
|
525
|
-
# the request.
|
526
|
-
#
|
527
|
-
# @yieldparam [Net::HTTP::Response] response
|
528
|
-
# The HTTP response object.
|
529
|
-
#
|
530
|
-
# @return [Net::HTTP::Response]
|
531
|
-
# The response of the HTTP request.
|
532
|
-
#
|
533
|
-
# @see http_request
|
534
|
-
#
|
535
|
-
# @api public
|
536
|
-
#
|
537
|
-
def Net.http_move(options={},&block)
|
538
|
-
resp = Net.http_request(options.merge(:method => :move))
|
539
|
-
|
540
|
-
yield resp if block_given?
|
541
|
-
return resp
|
542
|
-
end
|
543
|
-
|
544
|
-
#
|
545
|
-
# Performs an HTTP Options request.
|
546
|
-
#
|
547
|
-
# @param [Hash] options
|
548
|
-
# Additional options.
|
549
|
-
#
|
550
|
-
# @yield [response]
|
551
|
-
# If a block is given, it will be passed the response received from
|
552
|
-
# the request.
|
553
|
-
#
|
554
|
-
# @yieldparam [Net::HTTP::Response] response
|
555
|
-
# The HTTP response object.
|
556
|
-
#
|
557
|
-
# @return [Net::HTTP::Response]
|
558
|
-
# The response of the HTTP request.
|
559
|
-
#
|
560
|
-
# @see http_request
|
561
|
-
#
|
562
|
-
# @api public
|
563
|
-
#
|
564
|
-
def Net.http_options(options={},&block)
|
565
|
-
resp = Net.http_request(options.merge(:method => :options))
|
566
|
-
|
567
|
-
yield resp if block_given?
|
568
|
-
return resp
|
569
|
-
end
|
570
|
-
|
571
|
-
#
|
572
|
-
# Performs an HTTP Post request.
|
573
|
-
#
|
574
|
-
# @param [Hash] options
|
575
|
-
# Additional options.
|
576
|
-
#
|
577
|
-
# @option options [Hash, String] :form_data
|
578
|
-
# The form data to send with the HTTP Post request.
|
579
|
-
#
|
580
|
-
# @yield [response]
|
581
|
-
# If a block is given, it will be passed the response received from
|
582
|
-
# the request.
|
583
|
-
#
|
584
|
-
# @yieldparam [Net::HTTP::Response] response
|
585
|
-
# The HTTP response object.
|
586
|
-
#
|
587
|
-
# @return [Net::HTTP::Response]
|
588
|
-
# The response of the HTTP request.
|
589
|
-
#
|
590
|
-
# @see http_request
|
591
|
-
#
|
592
|
-
# @api public
|
593
|
-
#
|
594
|
-
def Net.http_post(options={},&block)
|
595
|
-
resp = Net.http_request(options.merge(:method => :post))
|
596
|
-
|
597
|
-
yield resp if block_given?
|
598
|
-
return resp
|
599
|
-
end
|
600
|
-
|
601
|
-
#
|
602
|
-
# Performs an HTTP Post request and returns the Response Headers.
|
603
|
-
#
|
604
|
-
# @param [Hash] options
|
605
|
-
# Additional options.
|
606
|
-
#
|
607
|
-
# @option options [Hash, String] :form_data
|
608
|
-
# The form data to send with the HTTP Post request.
|
609
|
-
#
|
610
|
-
# @return [Hash{String => Array<String>}]
|
611
|
-
# The headers of the HTTP response.
|
612
|
-
#
|
613
|
-
# @see http_post
|
614
|
-
#
|
615
|
-
# @since 0.2.0
|
616
|
-
#
|
617
|
-
# @api public
|
618
|
-
#
|
619
|
-
def Net.http_post_headers(options={})
|
620
|
-
Net.http_post(options).to_hash
|
621
|
-
end
|
622
|
-
|
623
|
-
#
|
624
|
-
# Performs an HTTP Post request and returns the Response Body.
|
625
|
-
#
|
626
|
-
# @param [Hash] options
|
627
|
-
# Additional options.
|
628
|
-
#
|
629
|
-
# @option options [Hash, String] :form_data
|
630
|
-
# The form data to send with the HTTP Post request.
|
631
|
-
#
|
632
|
-
# @return [String]
|
633
|
-
# The body of the HTTP response.
|
634
|
-
#
|
635
|
-
# @see http_post
|
636
|
-
#
|
637
|
-
# @api public
|
638
|
-
#
|
639
|
-
def Net.http_post_body(options={})
|
640
|
-
Net.http_post(options).body
|
641
|
-
end
|
642
|
-
|
643
|
-
#
|
644
|
-
# Performs an HTTP Propfind request.
|
645
|
-
#
|
646
|
-
# @param [Hash] options
|
647
|
-
# Additional options.
|
648
|
-
#
|
649
|
-
# @yield [response]
|
650
|
-
# If a block is given, it will be passed the response received from
|
651
|
-
# the request.
|
652
|
-
#
|
653
|
-
# @yieldparam [Net::HTTP::Response] response
|
654
|
-
# The HTTP response object.
|
655
|
-
#
|
656
|
-
# @return [Net::HTTP::Response]
|
657
|
-
# The response of the HTTP request.
|
658
|
-
#
|
659
|
-
# @see http_request
|
660
|
-
#
|
661
|
-
# @api public
|
662
|
-
#
|
663
|
-
def Net.http_prop_find(options={},&block)
|
664
|
-
original_headers = options[:headers]
|
665
|
-
|
666
|
-
# set the HTTP Depth header
|
667
|
-
options[:headers] = {:depth => '0'}
|
668
|
-
|
669
|
-
if original_headers
|
670
|
-
options[:header].merge!(original_headers)
|
671
|
-
end
|
672
|
-
|
673
|
-
resp = Net.http_request(options.merge(:method => :propfind))
|
674
|
-
|
675
|
-
yield resp if block_given?
|
676
|
-
return resp
|
677
|
-
end
|
678
|
-
|
679
|
-
#
|
680
|
-
# Performs an HTTP Proppatch request.
|
681
|
-
#
|
682
|
-
# @param [Hash] options
|
683
|
-
# Additional options.
|
684
|
-
#
|
685
|
-
# @yield [response]
|
686
|
-
# If a block is given, it will be passed the response received from
|
687
|
-
# the request.
|
688
|
-
#
|
689
|
-
# @yieldparam [Net::HTTP::Response] response
|
690
|
-
# The HTTP response object.
|
691
|
-
#
|
692
|
-
# @return [Net::HTTP::Response]
|
693
|
-
# The response of the HTTP request.
|
694
|
-
#
|
695
|
-
# @see http_request
|
696
|
-
#
|
697
|
-
# @api public
|
698
|
-
#
|
699
|
-
def Net.http_prop_patch(options={},&block)
|
700
|
-
resp = Net.http_request(options.merge(:method => :proppatch))
|
701
|
-
|
702
|
-
yield resp if block_given?
|
703
|
-
return resp
|
704
|
-
end
|
705
|
-
|
706
|
-
#
|
707
|
-
# Performs an HTTP Trace request.
|
708
|
-
#
|
709
|
-
# @param [Hash] options
|
710
|
-
# Additional options.
|
711
|
-
#
|
712
|
-
# @yield [response]
|
713
|
-
# If a block is given, it will be passed the response received from
|
714
|
-
# the request.
|
715
|
-
#
|
716
|
-
# @yieldparam [Net::HTTP::Response] response
|
717
|
-
# The HTTP response object.
|
718
|
-
#
|
719
|
-
# @return [Net::HTTP::Response]
|
720
|
-
# The response of the HTTP request.
|
721
|
-
#
|
722
|
-
# @see http_request
|
723
|
-
#
|
724
|
-
# @api public
|
725
|
-
#
|
726
|
-
def Net.http_trace(options={},&block)
|
727
|
-
resp = Net.http_request(options.merge(:method => :trace))
|
728
|
-
|
729
|
-
yield resp if block_given?
|
730
|
-
return resp
|
731
|
-
end
|
732
|
-
|
733
|
-
#
|
734
|
-
# Performs an HTTP Unlock request.
|
735
|
-
#
|
736
|
-
# @param [Hash] options
|
737
|
-
# Additional options.
|
738
|
-
#
|
739
|
-
# @yield [response]
|
740
|
-
# If a block is given, it will be passed the response received from
|
741
|
-
# the request.
|
742
|
-
#
|
743
|
-
# @yieldparam [Net::HTTP::Response] response
|
744
|
-
# The HTTP response object.
|
745
|
-
#
|
746
|
-
# @return [Net::HTTP::Response]
|
747
|
-
# The response of the HTTP request.
|
748
|
-
#
|
749
|
-
# @see http_request
|
750
|
-
#
|
751
|
-
# @api public
|
752
|
-
#
|
753
|
-
def Net.http_unlock(options={},&block)
|
754
|
-
resp = Net.http_request(options.merge(:method => :unlock))
|
755
|
-
|
756
|
-
yield resp if block_given?
|
757
|
-
return resp
|
758
|
-
end
|
23
|
+
extend Ronin::Network::HTTP
|
759
24
|
end
|