ronin 0.2.4 → 0.3.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.tar.gz.sig +0 -0
- data/History.txt +95 -0
- data/Manifest.txt +55 -25
- data/README.txt +64 -52
- data/Rakefile +21 -14
- data/bin/ronin +1 -1
- data/bin/ronin-add +1 -1
- data/bin/ronin-console +1 -1
- data/bin/ronin-help +1 -1
- data/bin/ronin-install +1 -1
- data/bin/ronin-list +1 -1
- data/bin/ronin-remove +1 -1
- data/bin/ronin-uninstall +1 -1
- data/bin/ronin-update +1 -1
- data/lib/ronin.rb +2 -4
- data/lib/ronin/arch.rb +66 -21
- data/lib/ronin/author.rb +27 -18
- data/lib/ronin/cacheable.rb +63 -23
- data/lib/ronin/code/emittable.rb +1 -4
- data/lib/ronin/code/reference.rb +2 -5
- data/lib/ronin/code/symbol_table.rb +1 -4
- data/lib/ronin/code/token.rb +1 -4
- data/lib/ronin/config.rb +31 -10
- data/lib/ronin/database.rb +1 -4
- data/lib/ronin/database/database.rb +42 -23
- data/lib/ronin/database/exceptions.rb +1 -4
- data/lib/ronin/database/exceptions/invalid_config.rb +1 -4
- data/lib/ronin/environment.rb +1 -5
- data/lib/ronin/extensions.rb +1 -5
- data/lib/ronin/extensions/array.rb +8 -6
- data/lib/ronin/extensions/file.rb +9 -4
- data/lib/ronin/extensions/ip_addr.rb +33 -13
- data/lib/ronin/extensions/kernel.rb +44 -9
- data/lib/ronin/extensions/meta.rb +1 -4
- data/lib/ronin/extensions/string.rb +8 -7
- data/lib/ronin/extensions/uri.rb +1 -4
- data/lib/ronin/extensions/uri/http.rb +1 -48
- data/lib/ronin/extensions/uri/query_params.rb +27 -8
- data/lib/ronin/formatting.rb +1 -4
- data/lib/ronin/formatting/binary.rb +1 -4
- data/lib/ronin/formatting/digest.rb +1 -4
- data/lib/ronin/formatting/extensions.rb +1 -4
- data/lib/ronin/formatting/extensions/binary.rb +1 -4
- data/lib/ronin/formatting/extensions/binary/file.rb +3 -28
- data/lib/ronin/formatting/extensions/binary/integer.rb +31 -12
- data/lib/ronin/formatting/extensions/binary/string.rb +59 -36
- data/lib/ronin/formatting/extensions/digest.rb +1 -4
- data/lib/ronin/formatting/extensions/digest/string.rb +31 -9
- data/lib/ronin/formatting/extensions/http.rb +1 -4
- data/lib/ronin/formatting/extensions/http/string.rb +16 -9
- data/lib/ronin/formatting/extensions/text.rb +1 -4
- data/lib/ronin/formatting/extensions/text/array.rb +17 -7
- data/lib/ronin/formatting/extensions/text/string.rb +70 -27
- data/lib/ronin/formatting/http.rb +1 -4
- data/lib/ronin/formatting/text.rb +1 -4
- data/lib/ronin/license.rb +72 -65
- data/lib/ronin/model.rb +1 -4
- data/lib/ronin/model/has_description.rb +37 -8
- data/lib/ronin/model/has_license.rb +12 -8
- data/lib/ronin/model/has_name.rb +10 -7
- data/lib/ronin/model/has_version.rb +14 -4
- data/lib/ronin/model/model.rb +71 -14
- data/lib/ronin/network.rb +1 -4
- data/lib/ronin/network/esmtp.rb +1 -4
- data/lib/ronin/network/extensions.rb +1 -4
- data/lib/ronin/network/extensions/esmtp.rb +1 -4
- data/lib/ronin/network/extensions/esmtp/net.rb +49 -21
- data/lib/ronin/network/extensions/http.rb +1 -4
- data/lib/ronin/network/extensions/http/net.rb +319 -531
- data/lib/ronin/network/extensions/imap.rb +1 -4
- data/lib/ronin/network/extensions/imap/net.rb +50 -23
- data/lib/ronin/network/extensions/pop3.rb +1 -4
- data/lib/ronin/network/extensions/pop3/net.rb +40 -17
- data/lib/ronin/network/extensions/smtp.rb +1 -4
- data/lib/ronin/network/extensions/smtp/net.rb +49 -21
- data/lib/ronin/network/extensions/tcp.rb +1 -4
- data/lib/ronin/network/extensions/tcp/net.rb +234 -31
- data/lib/ronin/network/extensions/telnet.rb +1 -4
- data/lib/ronin/network/extensions/telnet/net.rb +83 -51
- data/lib/ronin/network/extensions/udp.rb +1 -4
- data/lib/ronin/network/extensions/udp/net.rb +164 -27
- data/lib/ronin/{sessions.rb → network/helpers.rb} +10 -13
- data/lib/ronin/network/helpers/esmtp.rb +129 -0
- data/lib/ronin/{sessions/session.rb → network/helpers/helper.rb} +25 -17
- data/lib/ronin/network/helpers/http.rb +444 -0
- data/lib/ronin/network/helpers/imap.rb +115 -0
- data/lib/ronin/network/helpers/pop3.rb +110 -0
- data/lib/ronin/network/helpers/smtp.rb +123 -0
- data/lib/ronin/network/helpers/tcp.rb +309 -0
- data/lib/ronin/network/helpers/telnet.rb +158 -0
- data/lib/ronin/network/helpers/udp.rb +197 -0
- data/lib/ronin/network/http.rb +3 -156
- data/lib/ronin/network/http/exceptions.rb +1 -4
- data/lib/ronin/network/http/exceptions/unknown_request.rb +1 -4
- data/lib/ronin/network/http/http.rb +214 -0
- data/lib/ronin/network/http/proxy.rb +308 -0
- data/lib/ronin/network/imap.rb +7 -6
- data/lib/ronin/network/pop3.rb +7 -6
- data/lib/ronin/network/smtp.rb +1 -4
- data/lib/ronin/network/smtp/email.rb +34 -18
- data/lib/ronin/network/smtp/smtp.rb +19 -7
- data/lib/ronin/network/tcp.rb +1 -4
- data/lib/ronin/network/telnet.rb +25 -12
- data/lib/ronin/network/udp.rb +1 -4
- data/lib/ronin/os.rb +43 -21
- data/lib/ronin/path.rb +29 -9
- data/lib/ronin/platform.rb +1 -4
- data/lib/ronin/platform/exceptions.rb +1 -4
- data/lib/ronin/platform/exceptions/extension_not_found.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_cached.rb +1 -4
- data/lib/ronin/platform/exceptions/overlay_not_found.rb +1 -4
- data/lib/ronin/platform/extension.rb +195 -52
- data/lib/ronin/platform/extension_cache.rb +60 -24
- data/lib/ronin/platform/maintainer.rb +15 -8
- data/lib/ronin/platform/object_cache.rb +29 -8
- data/lib/ronin/platform/overlay.rb +82 -26
- data/lib/ronin/platform/overlay_cache.rb +179 -56
- data/lib/ronin/platform/platform.rb +154 -58
- data/lib/ronin/platform/ronin.rb +38 -11
- data/lib/ronin/product.rb +17 -17
- data/lib/ronin/rpc.rb +1 -4
- data/lib/ronin/rpc/call.rb +1 -4
- data/lib/ronin/rpc/client.rb +1 -4
- data/lib/ronin/rpc/console.rb +1 -4
- data/lib/ronin/rpc/exceptions.rb +1 -4
- data/lib/ronin/rpc/exceptions/not_implemented.rb +1 -4
- data/lib/ronin/rpc/exceptions/response_missing.rb +1 -4
- data/lib/ronin/rpc/response.rb +1 -4
- data/lib/ronin/rpc/service.rb +1 -4
- data/lib/ronin/rpc/shell.rb +1 -4
- data/lib/ronin/scanners.rb +1 -4
- data/lib/ronin/scanners/exceptions.rb +1 -4
- data/lib/ronin/scanners/exceptions/unknown_category.rb +1 -4
- data/lib/ronin/scanners/scanner.rb +82 -26
- data/lib/ronin/static.rb +1 -4
- data/lib/ronin/static/finders.rb +1 -4
- data/lib/ronin/static/static.rb +16 -7
- data/lib/ronin/templates.rb +2 -4
- data/lib/ronin/templates/erb.rb +24 -10
- data/lib/ronin/templates/template.rb +130 -0
- data/lib/ronin/ui.rb +2 -6
- data/lib/ronin/ui/command_line.rb +1 -4
- data/lib/ronin/ui/command_line/command.rb +137 -68
- data/lib/ronin/ui/command_line/command_line.rb +52 -29
- data/lib/ronin/ui/command_line/commands/add.rb +39 -67
- data/lib/ronin/ui/command_line/commands/console.rb +23 -27
- data/lib/ronin/ui/command_line/commands/help.rb +10 -29
- data/lib/ronin/ui/command_line/commands/install.rb +31 -56
- data/lib/ronin/ui/command_line/commands/list.rb +34 -52
- data/lib/ronin/ui/command_line/commands/remove.rb +12 -32
- data/lib/ronin/ui/command_line/commands/uninstall.rb +11 -31
- data/lib/ronin/ui/command_line/commands/update.rb +15 -35
- data/lib/ronin/ui/command_line/exceptions.rb +1 -4
- data/lib/ronin/ui/command_line/exceptions/unknown_command.rb +1 -4
- data/lib/ronin/ui/console.rb +54 -23
- data/lib/ronin/ui/hexdump.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions.rb +1 -4
- data/lib/ronin/ui/hexdump/extensions/file.rb +8 -6
- data/lib/ronin/ui/hexdump/extensions/kernel.rb +4 -5
- data/lib/ronin/ui/hexdump/hexdump.rb +8 -5
- data/lib/ronin/{sessions/exceptions.rb → ui/output.rb} +3 -5
- data/lib/ronin/ui/output/handler.rb +121 -0
- data/lib/ronin/ui/output/helpers.rb +110 -0
- data/lib/ronin/ui/output/output.rb +144 -0
- data/lib/ronin/ui/shell.rb +38 -12
- data/lib/ronin/version.rb +2 -5
- data/lib/ronin/{sessions/exceptions/variable_missing.rb → yard.rb} +2 -10
- data/lib/ronin/{ronin.rb → yard/handlers.rb} +5 -15
- data/lib/ronin/yard/handlers/ruby.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/base.rb +27 -0
- data/lib/ronin/yard/handlers/ruby/belongs_to_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/eval_block_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/has_handler.rb +49 -0
- data/lib/ronin/yard/handlers/ruby/legacy.rb +26 -0
- data/lib/ronin/yard/handlers/ruby/legacy/belongs_to_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/eval_block_handler.rb +19 -0
- data/lib/ronin/yard/handlers/ruby/legacy/has_handler.rb +34 -0
- data/lib/ronin/yard/handlers/ruby/legacy/metaclass_eval_handler.rb +21 -0
- data/lib/ronin/yard/handlers/ruby/legacy/property_handler.rb +41 -0
- data/lib/ronin/yard/handlers/ruby/legacy/scanner_handler.rb +61 -0
- data/lib/ronin/yard/handlers/ruby/metaclass_eval_handler.rb +18 -0
- data/lib/ronin/yard/handlers/ruby/property_handler.rb +45 -0
- data/lib/ronin/yard/handlers/ruby/scanner_handler.rb +66 -0
- data/spec/author_spec.rb +3 -3
- data/spec/extensions/classes/some_class.rb +2 -0
- data/spec/extensions/kernel_spec.rb +17 -0
- data/spec/extensions/uri/http_spec.rb +0 -31
- data/spec/formatting/binary/integer_spec.rb +4 -0
- data/spec/formatting/text/string_spec.rb +96 -0
- data/spec/license_spec.rb +6 -6
- data/spec/model/classes/basic_model.rb +13 -0
- data/spec/model/classes/custom_model.rb +17 -0
- data/spec/model/classes/described_model.rb +10 -0
- data/spec/model/has_description_spec.rb +42 -0
- data/spec/model/has_license_spec.rb +18 -4
- data/spec/model/model_spec.rb +68 -0
- data/spec/network/helpers/classes/test_helper.rb +11 -0
- data/spec/network/helpers/classes/uses_test_helper.rb +10 -0
- data/spec/network/helpers/helper_spec.rb +25 -0
- data/spec/network/{http_spec.rb → http/http_spec.rb} +0 -0
- data/spec/network/http/proxy_spec.rb +116 -0
- data/spec/os_spec.rb +4 -4
- data/spec/platform/extension_cache_spec.rb +14 -0
- data/spec/platform/extension_spec.rb +11 -0
- data/spec/platform/platform_spec.rb +8 -0
- data/spec/product_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -1
- data/spec/templates/classes/{uses_erb.rb → example_erb.rb} +1 -1
- data/spec/templates/classes/example_template.rb +21 -0
- data/spec/templates/erb_spec.rb +2 -2
- data/spec/templates/helpers/static.rb +5 -0
- data/spec/templates/helpers/static/templates/_relative.erb +1 -0
- data/spec/templates/helpers/static/templates/example.erb +1 -0
- data/spec/templates/template_spec.rb +41 -0
- data/spec/ui/command_line/classes/test_command.rb +23 -0
- data/spec/ui/command_line/command_spec.rb +31 -0
- data/spec/ui/output_spec.rb +29 -0
- data/static/ronin/platform/overlay.xsl +135 -114
- data/tasks/spec.rb +1 -0
- data/tasks/yard.rb +18 -0
- metadata +98 -59
- metadata.gz.sig +0 -0
- data/TODO.txt +0 -15
- data/lib/ronin/extensions/hash.rb +0 -62
- data/lib/ronin/sessions/esmtp.rb +0 -57
- data/lib/ronin/sessions/http.rb +0 -678
- data/lib/ronin/sessions/imap.rb +0 -54
- data/lib/ronin/sessions/pop3.rb +0 -52
- data/lib/ronin/sessions/smtp.rb +0 -57
- data/lib/ronin/sessions/tcp.rb +0 -100
- data/lib/ronin/sessions/telnet.rb +0 -55
- data/lib/ronin/sessions/udp.rb +0 -73
- data/lib/ronin/ui/command_line/options.rb +0 -136
- data/lib/ronin/ui/diagnostics.rb +0 -66
- data/lib/ronin/ui/verbose.rb +0 -58
- data/spec/extensions/hash_spec.rb +0 -38
- data/spec/sessions/classes/test_session.rb +0 -11
- data/spec/sessions/classes/uses_test_session.rb +0 -10
- data/spec/sessions/session_spec.rb +0 -25
- data/spec/ui/verbose_spec.rb +0 -17
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with this program; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/network/helpers/helper'
|
|
22
|
+
require 'ronin/network/esmtp'
|
|
23
|
+
|
|
24
|
+
module Ronin
|
|
25
|
+
module Network
|
|
26
|
+
module Helpers
|
|
27
|
+
module ESMTP
|
|
28
|
+
include Helper
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# @see Ronin::Network::SMTP.message.
|
|
34
|
+
#
|
|
35
|
+
# @since 0.3.0
|
|
36
|
+
#
|
|
37
|
+
def esmtp_message(options={},&block)
|
|
38
|
+
Network::SMTP.message(options,&block)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Creates a connection to the ESMTP server. The +@host+, +@port+,
|
|
43
|
+
# +@esmtp_login+, +@esmtp_user+ and +@esmtp_password+ instance
|
|
44
|
+
# variables will also be used to connect to the ESMTP server.
|
|
45
|
+
#
|
|
46
|
+
# @param [Hash] options
|
|
47
|
+
# Additional options.
|
|
48
|
+
#
|
|
49
|
+
# @option options [Integer] :port (Ronin::Network::SMTP.default_port)
|
|
50
|
+
# The port to connect to.
|
|
51
|
+
#
|
|
52
|
+
# @option options [String] :helo
|
|
53
|
+
# The HELO domain.
|
|
54
|
+
#
|
|
55
|
+
# @option options [Symbol] :auth
|
|
56
|
+
# The type of authentication to use.
|
|
57
|
+
# Can be either +:login+, +:plain+, or +:cram_md5+.
|
|
58
|
+
#
|
|
59
|
+
# @option options [String] :user
|
|
60
|
+
# The user-name to authenticate with.
|
|
61
|
+
#
|
|
62
|
+
# @option options [String] :password
|
|
63
|
+
# The password to authenticate with.
|
|
64
|
+
#
|
|
65
|
+
# @yield [session]
|
|
66
|
+
# If a block is given, it will be passed an ESMTP enabled
|
|
67
|
+
# session object.
|
|
68
|
+
#
|
|
69
|
+
# @yieldparam [Net::SMTP] session
|
|
70
|
+
# The ESMTP session.
|
|
71
|
+
#
|
|
72
|
+
# @return [Net::SMTP]
|
|
73
|
+
# The ESMTP enabled session.
|
|
74
|
+
#
|
|
75
|
+
# @since 0.3.0
|
|
76
|
+
#
|
|
77
|
+
def esmtp_connect(options={},&block)
|
|
78
|
+
require_variable :host
|
|
79
|
+
|
|
80
|
+
options[:port] ||= @port
|
|
81
|
+
options[:login] ||= @esmtp_login
|
|
82
|
+
options[:user] ||= @esmtp_user
|
|
83
|
+
options[:password] ||= @esmtp_password
|
|
84
|
+
|
|
85
|
+
if @port
|
|
86
|
+
print_info "Connecting to #{@host}:#{@port} ..."
|
|
87
|
+
else
|
|
88
|
+
print_info "Connecting to #{@host} ..."
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
return ::Net.esmtp_connect(@host,options,&block)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#
|
|
95
|
+
# Starts a session with the ESMTP server. The +@host+, +@port+,
|
|
96
|
+
# +@esmtp_login+, +@esmtp_user+ and +@esmtp_password+ instance
|
|
97
|
+
# variables will also be used to connect to the ESMTP server.
|
|
98
|
+
#
|
|
99
|
+
# @param [Hash] options
|
|
100
|
+
# Additional options.
|
|
101
|
+
#
|
|
102
|
+
# @yield [session]
|
|
103
|
+
# If a block is given, it will be passed an ESMTP enabled
|
|
104
|
+
# session object. After the block has returned, the session
|
|
105
|
+
# will be closed.
|
|
106
|
+
#
|
|
107
|
+
# @yieldparam [Net::SMTP] session
|
|
108
|
+
# The ESMTP session.
|
|
109
|
+
#
|
|
110
|
+
# @see esmtp_connect
|
|
111
|
+
# @since 0.3.0
|
|
112
|
+
#
|
|
113
|
+
def esmtp_session(options={},&block)
|
|
114
|
+
esmtp_connect(options) do |sess|
|
|
115
|
+
block.call(sess) if block
|
|
116
|
+
|
|
117
|
+
sess.close
|
|
118
|
+
|
|
119
|
+
if @port
|
|
120
|
+
print_info "Disconnecting from #{@host}:#{@port}"
|
|
121
|
+
else
|
|
122
|
+
print_info "Disconnecting from #{@host}"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
|
|
3
|
-
# Ronin - A ruby development platform designed for information security
|
|
4
|
-
# and data exploration tasks.
|
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
|
5
3
|
#
|
|
6
4
|
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
7
5
|
#
|
|
@@ -18,26 +16,36 @@
|
|
|
18
16
|
# You should have received a copy of the GNU General Public License
|
|
19
17
|
# along with this program; if not, write to the Free Software
|
|
20
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
-
#++
|
|
22
19
|
#
|
|
23
20
|
|
|
24
|
-
require 'ronin/
|
|
21
|
+
require 'ronin/ui/output/helpers'
|
|
25
22
|
|
|
26
23
|
module Ronin
|
|
27
|
-
module
|
|
28
|
-
module
|
|
29
|
-
|
|
24
|
+
module Network
|
|
25
|
+
module Helpers
|
|
26
|
+
module Helper
|
|
27
|
+
include UI::Output::Helpers
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Tests wether an instance variable has been set.
|
|
33
|
+
#
|
|
34
|
+
# @return [true]
|
|
35
|
+
# The instance variable has been set.
|
|
36
|
+
#
|
|
37
|
+
# @raise [RuntimeError]
|
|
38
|
+
# The instance variable was not set.
|
|
39
|
+
#
|
|
40
|
+
# @since 0.3.0
|
|
41
|
+
#
|
|
42
|
+
def require_variable(name)
|
|
43
|
+
if instance_variable_get("@#{name}").nil?
|
|
44
|
+
raise(RuntimeError,"the instance variable @#{name} was not set",caller)
|
|
45
|
+
end
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
return true
|
|
48
|
+
end
|
|
41
49
|
end
|
|
42
50
|
end
|
|
43
51
|
end
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
5
|
+
#
|
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU General Public License
|
|
17
|
+
# along with this program; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/network/helpers/helper'
|
|
22
|
+
require 'ronin/network/http'
|
|
23
|
+
|
|
24
|
+
module Ronin
|
|
25
|
+
module Network
|
|
26
|
+
module Helpers
|
|
27
|
+
module HTTP
|
|
28
|
+
include Helper
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Resets the HTTP proxy settings.
|
|
34
|
+
#
|
|
35
|
+
# @since 0.3.0
|
|
36
|
+
#
|
|
37
|
+
def disable_http_proxy
|
|
38
|
+
@http_proxy = nil
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Connects to the HTTP server.
|
|
43
|
+
#
|
|
44
|
+
# @param [Hash] options
|
|
45
|
+
# Additional options
|
|
46
|
+
#
|
|
47
|
+
# @option options [String, URI::HTTP] :url
|
|
48
|
+
# The full URL to request.
|
|
49
|
+
#
|
|
50
|
+
# @option options [String] :user
|
|
51
|
+
# The user to authenticate with when connecting to the HTTP
|
|
52
|
+
# server.
|
|
53
|
+
#
|
|
54
|
+
# @option options [String] :password
|
|
55
|
+
# The password to authenticate with when connecting to the HTTP
|
|
56
|
+
# server.
|
|
57
|
+
#
|
|
58
|
+
# @option options [String] :host
|
|
59
|
+
# The host the HTTP server is running on.
|
|
60
|
+
#
|
|
61
|
+
# @option options [Integer] :port (Net::HTTP.default_port)
|
|
62
|
+
# The port the HTTP server is listening on.
|
|
63
|
+
#
|
|
64
|
+
# @option options [String] :path
|
|
65
|
+
# The path to request from the HTTP server.
|
|
66
|
+
#
|
|
67
|
+
# @yield [session]
|
|
68
|
+
# If a block is given, it will be passes the new HTTP session
|
|
69
|
+
# object.
|
|
70
|
+
#
|
|
71
|
+
# @yieldparam [Net::HTTP] session
|
|
72
|
+
# The newly created HTTP session.
|
|
73
|
+
#
|
|
74
|
+
# @return [Net::HTTP]
|
|
75
|
+
# The HTTP session object.
|
|
76
|
+
#
|
|
77
|
+
# @since 0.3.0
|
|
78
|
+
#
|
|
79
|
+
def http_session(options={},&block)
|
|
80
|
+
Net.http_session(http_merge_options(options),&block)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# Connects to the HTTP server and sends an HTTP Request using the
|
|
85
|
+
# given _options_.
|
|
86
|
+
#
|
|
87
|
+
# @param [Hash] options
|
|
88
|
+
# Additional options.
|
|
89
|
+
#
|
|
90
|
+
# @option options [Hash{String,Symbol => Object}] :headers
|
|
91
|
+
# The Hash of the HTTP headers to send with the request.
|
|
92
|
+
# May contain either Strings or Symbols, lower-case or
|
|
93
|
+
# camel-case keys.
|
|
94
|
+
#
|
|
95
|
+
# @yield [request, (options)]
|
|
96
|
+
# If a block is given, it will be passed the HTTP request object.
|
|
97
|
+
# If the block has an arity of 2, it will also be passed the
|
|
98
|
+
# expanded version of the given _options_.
|
|
99
|
+
#
|
|
100
|
+
# @yieldparam [Net::HTTP::Request] request
|
|
101
|
+
# The HTTP request object to use in the request.
|
|
102
|
+
#
|
|
103
|
+
# @yieldparam [Hash] options
|
|
104
|
+
# The expanded version of the given _options_.
|
|
105
|
+
#
|
|
106
|
+
# @return [Net::HTTP::Response]
|
|
107
|
+
# The response of the HTTP request.
|
|
108
|
+
#
|
|
109
|
+
# @see http_session
|
|
110
|
+
# @since 0.3.0
|
|
111
|
+
#
|
|
112
|
+
def http_request(options={},&block)
|
|
113
|
+
Net.http_request(http_merge_options(options),&block)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
#
|
|
117
|
+
# Performes an HTTP Copy request with the given _options_.
|
|
118
|
+
#
|
|
119
|
+
# @yield [response]
|
|
120
|
+
# If a block is given, it will be passed the response received
|
|
121
|
+
# from the request.
|
|
122
|
+
#
|
|
123
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
124
|
+
# The HTTP response object.
|
|
125
|
+
#
|
|
126
|
+
# @return [Net::HTTP::Response]
|
|
127
|
+
# The response of the HTTP request.
|
|
128
|
+
#
|
|
129
|
+
# @see http_request
|
|
130
|
+
# @since 0.3.0
|
|
131
|
+
#
|
|
132
|
+
def http_copy(options={},&block)
|
|
133
|
+
Net.http_copy(http_merge_options(options),&block)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# Performes an HTTP Delete request with the given _options_.
|
|
138
|
+
#
|
|
139
|
+
# @yield [response]
|
|
140
|
+
# If a block is given, it will be passed the response received
|
|
141
|
+
# from the request.
|
|
142
|
+
#
|
|
143
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
144
|
+
# The HTTP response object.
|
|
145
|
+
#
|
|
146
|
+
# @return [Net::HTTP::Response]
|
|
147
|
+
# The response of the HTTP request.
|
|
148
|
+
#
|
|
149
|
+
# @see http_request
|
|
150
|
+
# @since 0.3.0
|
|
151
|
+
#
|
|
152
|
+
def http_delete(options={},&block)
|
|
153
|
+
Net.http_delete(http_merge_options(options),&block)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
#
|
|
157
|
+
# Performes an HTTP Get request with the given _options_.
|
|
158
|
+
#
|
|
159
|
+
# @yield [response]
|
|
160
|
+
# If a block is given, it will be passed the response received
|
|
161
|
+
# from the request.
|
|
162
|
+
#
|
|
163
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
164
|
+
# The HTTP response object.
|
|
165
|
+
#
|
|
166
|
+
# @return [Net::HTTP::Response]
|
|
167
|
+
# The response of the HTTP request.
|
|
168
|
+
#
|
|
169
|
+
# @see http_request
|
|
170
|
+
# @since 0.3.0
|
|
171
|
+
#
|
|
172
|
+
def http_get(options={},&block)
|
|
173
|
+
Net.http_get(http_merge_options(options),&block)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
#
|
|
177
|
+
# Performes an HTTP Get request with the given _options_.
|
|
178
|
+
#
|
|
179
|
+
# @yield [response]
|
|
180
|
+
# If a block is given, it will be passed the response received
|
|
181
|
+
# from the request.
|
|
182
|
+
#
|
|
183
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
184
|
+
# The HTTP response object.
|
|
185
|
+
#
|
|
186
|
+
# @return [String]
|
|
187
|
+
# The body of the HTTP Get request.
|
|
188
|
+
#
|
|
189
|
+
# @see http_get
|
|
190
|
+
# @since 0.3.0
|
|
191
|
+
#
|
|
192
|
+
def http_get_body(options={},&block)
|
|
193
|
+
Net.http_get_body(http_merge_options(options),&block)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
#
|
|
197
|
+
# Performes an HTTP Head request with the given _options_.
|
|
198
|
+
#
|
|
199
|
+
# @yield [response]
|
|
200
|
+
# If a block is given, it will be passed the response received
|
|
201
|
+
# from the request.
|
|
202
|
+
#
|
|
203
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
204
|
+
# The HTTP response object.
|
|
205
|
+
#
|
|
206
|
+
# @return [Net::HTTP::Response]
|
|
207
|
+
# The response of the HTTP request.
|
|
208
|
+
#
|
|
209
|
+
# @see http_request
|
|
210
|
+
# @since 0.3.0
|
|
211
|
+
#
|
|
212
|
+
def http_head(options={},&block)
|
|
213
|
+
Net.http_head(http_merge_options(options),&block)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
#
|
|
217
|
+
# Performes an HTTP Lock request with the given _options_.
|
|
218
|
+
#
|
|
219
|
+
# @yield [response]
|
|
220
|
+
# If a block is given, it will be passed the response received
|
|
221
|
+
# from the request.
|
|
222
|
+
#
|
|
223
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
224
|
+
# The HTTP response object.
|
|
225
|
+
#
|
|
226
|
+
# @return [Net::HTTP::Response]
|
|
227
|
+
# The response of the HTTP request.
|
|
228
|
+
#
|
|
229
|
+
# @see http_request
|
|
230
|
+
# @since 0.3.0
|
|
231
|
+
#
|
|
232
|
+
def http_lock(options={},&block)
|
|
233
|
+
Net.http_lock(http_merge_options(options),&block)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
#
|
|
237
|
+
# Performes an HTTP Mkcol request with the given _options_.
|
|
238
|
+
#
|
|
239
|
+
# @yield [response]
|
|
240
|
+
# If a block is given, it will be passed the response received
|
|
241
|
+
# from the request.
|
|
242
|
+
#
|
|
243
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
244
|
+
# The HTTP response object.
|
|
245
|
+
#
|
|
246
|
+
# @return [Net::HTTP::Response]
|
|
247
|
+
# The response of the HTTP request.
|
|
248
|
+
#
|
|
249
|
+
# @see http_request
|
|
250
|
+
# @since 0.3.0
|
|
251
|
+
#
|
|
252
|
+
def http_mkcol(options={},&block)
|
|
253
|
+
Net.http_mkcol(http_merge_options(options),&block)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
#
|
|
257
|
+
# Performes an HTTP Move request with the given _options_.
|
|
258
|
+
#
|
|
259
|
+
# @yield [response]
|
|
260
|
+
# If a block is given, it will be passed the response received
|
|
261
|
+
# from the request.
|
|
262
|
+
#
|
|
263
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
264
|
+
# The HTTP response object.
|
|
265
|
+
#
|
|
266
|
+
# @return [Net::HTTP::Response]
|
|
267
|
+
# The response of the HTTP request.
|
|
268
|
+
#
|
|
269
|
+
# @see http_request
|
|
270
|
+
# @since 0.3.0
|
|
271
|
+
#
|
|
272
|
+
def http_move(options={},&block)
|
|
273
|
+
Net.http_move(http_merge_options(options),&block)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
#
|
|
277
|
+
# Performes an HTTP Options request with the given _options_.
|
|
278
|
+
#
|
|
279
|
+
# @yield [response]
|
|
280
|
+
# If a block is given, it will be passed the response received
|
|
281
|
+
# from the request.
|
|
282
|
+
#
|
|
283
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
284
|
+
# The HTTP response object.
|
|
285
|
+
#
|
|
286
|
+
# @return [Net::HTTP::Response]
|
|
287
|
+
# The response of the HTTP request.
|
|
288
|
+
#
|
|
289
|
+
# @see http_request
|
|
290
|
+
# @since 0.3.0
|
|
291
|
+
#
|
|
292
|
+
def http_options(options={},&block)
|
|
293
|
+
Net.http_options(http_merge_options(options),&block)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
#
|
|
297
|
+
# Performes an HTTP Post request with the given _options_.
|
|
298
|
+
#
|
|
299
|
+
# @param [Hash] options
|
|
300
|
+
# Additional options.
|
|
301
|
+
#
|
|
302
|
+
# @option options [String] :post_data
|
|
303
|
+
# The +POSTDATA+ to send with the HTTP Post request.
|
|
304
|
+
#
|
|
305
|
+
# @yield [response]
|
|
306
|
+
# If a block is given, it will be passed the response received
|
|
307
|
+
# from the request.
|
|
308
|
+
#
|
|
309
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
310
|
+
# The HTTP response object.
|
|
311
|
+
#
|
|
312
|
+
# @return [Net::HTTP::Response]
|
|
313
|
+
# The response of the HTTP request.
|
|
314
|
+
#
|
|
315
|
+
# @see http_request
|
|
316
|
+
# @since 0.3.0
|
|
317
|
+
#
|
|
318
|
+
def http_post(options={},&block)
|
|
319
|
+
Net.http_post(http_merge_options(options),&block)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
#
|
|
323
|
+
# Performes an HTTP Post request with the given _options_.
|
|
324
|
+
#
|
|
325
|
+
# @yield [response]
|
|
326
|
+
# If a block is given, it will be passed the response received
|
|
327
|
+
# from the request.
|
|
328
|
+
#
|
|
329
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
330
|
+
# The HTTP response object.
|
|
331
|
+
#
|
|
332
|
+
# @return [String]
|
|
333
|
+
# The body of the Post request.
|
|
334
|
+
#
|
|
335
|
+
# @see http_post
|
|
336
|
+
# @since 0.3.0
|
|
337
|
+
#
|
|
338
|
+
def http_post_body(options={},&block)
|
|
339
|
+
Net.http_post_body(http_merge_options(options),&block)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
#
|
|
343
|
+
# Performes an HTTP Propfind request with the given _options_.
|
|
344
|
+
#
|
|
345
|
+
# @yield [response]
|
|
346
|
+
# If a block is given, it will be passed the response received
|
|
347
|
+
# from the request.
|
|
348
|
+
#
|
|
349
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
350
|
+
# The HTTP response object.
|
|
351
|
+
#
|
|
352
|
+
# @return [Net::HTTP::Response]
|
|
353
|
+
# The response of the HTTP request.
|
|
354
|
+
#
|
|
355
|
+
# @see http_request
|
|
356
|
+
# @since 0.3.0
|
|
357
|
+
#
|
|
358
|
+
def http_prop_find(options={},&block)
|
|
359
|
+
Net.http_prop_find(http_merge_options(options),&block)
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
#
|
|
363
|
+
# Performes an HTTP Proppatch request with the given _options_.
|
|
364
|
+
#
|
|
365
|
+
# @yield [response]
|
|
366
|
+
# If a block is given, it will be passed the response received
|
|
367
|
+
# from the request.
|
|
368
|
+
#
|
|
369
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
370
|
+
# The HTTP response object.
|
|
371
|
+
#
|
|
372
|
+
# @return [Net::HTTP::Response]
|
|
373
|
+
# The response of the HTTP request.
|
|
374
|
+
#
|
|
375
|
+
# @see http_request
|
|
376
|
+
# @since 0.3.0
|
|
377
|
+
#
|
|
378
|
+
def http_prop_patch(options={},&block)
|
|
379
|
+
Net.http_prop_patch(http_merge_options(options),&block)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
#
|
|
383
|
+
# Performes an HTTP Trace request with the given _options_.
|
|
384
|
+
#
|
|
385
|
+
# @yield [response]
|
|
386
|
+
# If a block is given, it will be passed the response received
|
|
387
|
+
# from the request.
|
|
388
|
+
#
|
|
389
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
390
|
+
# The HTTP response object.
|
|
391
|
+
#
|
|
392
|
+
# @return [Net::HTTP::Response]
|
|
393
|
+
# The response of the HTTP request.
|
|
394
|
+
#
|
|
395
|
+
# @see http_request
|
|
396
|
+
# @since 0.3.0
|
|
397
|
+
#
|
|
398
|
+
def http_trace(options={},&block)
|
|
399
|
+
Net.http_trace(http_merge_options(options),&block)
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
#
|
|
403
|
+
# Performes an HTTP Unlock request with the given _options_.
|
|
404
|
+
#
|
|
405
|
+
# @yield [response]
|
|
406
|
+
# If a block is given, it will be passed the response received
|
|
407
|
+
# from the request.
|
|
408
|
+
#
|
|
409
|
+
# @yieldparam [Net::HTTP::Response] response
|
|
410
|
+
# The HTTP response object.
|
|
411
|
+
#
|
|
412
|
+
# @return [Net::HTTP::Response]
|
|
413
|
+
# The response of the HTTP request.
|
|
414
|
+
#
|
|
415
|
+
# @see http_request
|
|
416
|
+
# @since 0.3.0
|
|
417
|
+
#
|
|
418
|
+
def http_unlock(options={},&block)
|
|
419
|
+
Net.http_unlock(http_merge_options(options),&block)
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
private
|
|
423
|
+
|
|
424
|
+
def http_merge_options(options={})
|
|
425
|
+
options[:host] ||= @host if @host
|
|
426
|
+
options[:port] ||= @port if @port
|
|
427
|
+
|
|
428
|
+
options[:headers] ||= {}
|
|
429
|
+
headers = options[:headers]
|
|
430
|
+
|
|
431
|
+
headers[:host] ||= @http_vhost if @http_vhost
|
|
432
|
+
|
|
433
|
+
options[:user] ||= @http_user if @http_user
|
|
434
|
+
options[:password] ||= @http_password if @http_password
|
|
435
|
+
|
|
436
|
+
options[:proxy] ||= @http_proxy if @http_proxy
|
|
437
|
+
options[:user_agent] ||= @http_user_agent if @http_user_agent
|
|
438
|
+
|
|
439
|
+
return options
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
end
|
|
444
|
+
end
|