ronin-support 0.4.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +121 -33
- data/Gemfile +17 -18
- data/README.md +57 -33
- data/Rakefile +10 -3
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +21 -0
- data/lib/ronin/binary/hexdump.rb +20 -0
- data/lib/ronin/binary/hexdump/parser.rb +403 -0
- data/lib/ronin/binary/struct.rb +567 -0
- data/lib/ronin/binary/template.rb +454 -0
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +39 -33
- data/lib/ronin/extensions/ip_addr.rb +29 -31
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +50 -5
- data/lib/ronin/extensions/resolv.rb +7 -9
- data/lib/ronin/extensions/string.rb +10 -10
- data/lib/ronin/formatting.rb +5 -5
- data/lib/ronin/formatting/binary.rb +5 -5
- data/lib/ronin/formatting/digest.rb +5 -5
- data/lib/ronin/formatting/extensions.rb +5 -5
- data/lib/ronin/formatting/extensions/binary.rb +7 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +61 -0
- data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
- data/lib/ronin/formatting/extensions/binary/file.rb +44 -11
- data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
- data/lib/ronin/formatting/extensions/binary/integer.rb +66 -50
- data/lib/ronin/formatting/extensions/binary/string.rb +81 -205
- data/lib/ronin/formatting/extensions/digest.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
- data/lib/ronin/formatting/extensions/html.rb +5 -5
- data/lib/ronin/formatting/extensions/html/integer.rb +9 -13
- data/lib/ronin/formatting/extensions/html/string.rb +31 -39
- data/lib/ronin/formatting/extensions/http.rb +5 -5
- data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/http/string.rb +7 -7
- data/lib/ronin/formatting/extensions/sql.rb +5 -5
- data/lib/ronin/formatting/extensions/sql/string.rb +22 -24
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +13 -11
- data/lib/ronin/formatting/extensions/text/string.rb +70 -13
- data/lib/ronin/formatting/html.rb +5 -5
- data/lib/ronin/formatting/http.rb +5 -5
- data/lib/ronin/formatting/sql.rb +5 -5
- data/lib/ronin/formatting/text.rb +5 -5
- data/lib/ronin/fuzzing.rb +5 -5
- data/lib/ronin/fuzzing/extensions.rb +5 -5
- data/lib/ronin/fuzzing/extensions/string.rb +42 -213
- data/lib/ronin/fuzzing/fuzzer.rb +110 -0
- data/lib/ronin/fuzzing/fuzzing.rb +33 -26
- data/lib/ronin/fuzzing/mutator.rb +161 -0
- data/lib/ronin/fuzzing/repeater.rb +81 -0
- data/lib/ronin/fuzzing/template.rb +133 -0
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +7 -5
- data/lib/ronin/network/dns.rb +64 -24
- data/lib/ronin/network/esmtp.rb +5 -5
- data/lib/ronin/network/extensions.rb +5 -5
- data/lib/ronin/network/extensions/dns.rb +5 -5
- data/lib/ronin/network/extensions/dns/net.rb +5 -5
- data/lib/ronin/network/extensions/esmtp.rb +5 -5
- data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
- data/lib/ronin/network/extensions/http.rb +5 -5
- data/lib/ronin/network/extensions/http/net.rb +5 -5
- data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
- data/lib/ronin/network/extensions/imap.rb +5 -5
- data/lib/ronin/network/extensions/imap/net.rb +5 -5
- data/lib/ronin/network/extensions/pop3.rb +5 -5
- data/lib/ronin/network/extensions/pop3/net.rb +5 -5
- data/lib/ronin/network/extensions/smtp.rb +5 -5
- data/lib/ronin/network/extensions/smtp/net.rb +5 -5
- data/lib/ronin/network/extensions/ssl.rb +5 -5
- data/lib/ronin/network/extensions/ssl/net.rb +5 -5
- data/lib/ronin/network/extensions/tcp.rb +5 -5
- data/lib/ronin/network/extensions/tcp/net.rb +5 -5
- data/lib/ronin/network/extensions/telnet.rb +5 -5
- data/lib/ronin/network/extensions/telnet/net.rb +5 -5
- data/lib/ronin/network/extensions/udp.rb +5 -5
- data/lib/ronin/network/extensions/udp/net.rb +5 -5
- data/lib/ronin/network/ftp.rb +149 -0
- data/lib/ronin/network/http.rb +5 -5
- data/lib/ronin/network/http/exceptions.rb +5 -5
- data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
- data/lib/ronin/network/http/http.rb +65 -70
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +16 -15
- data/lib/ronin/network/mixins.rb +6 -5
- data/lib/ronin/network/mixins/dns.rb +5 -5
- data/lib/ronin/network/mixins/esmtp.rb +5 -5
- data/lib/ronin/network/mixins/ftp.rb +155 -0
- data/lib/ronin/network/mixins/http.rb +58 -587
- data/lib/ronin/network/mixins/imap.rb +5 -5
- data/lib/ronin/network/mixins/mixin.rb +5 -5
- data/lib/ronin/network/mixins/pop3.rb +5 -5
- data/lib/ronin/network/mixins/smtp.rb +5 -5
- data/lib/ronin/network/mixins/ssl.rb +5 -5
- data/lib/ronin/network/mixins/tcp.rb +43 -10
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +126 -6
- data/lib/ronin/network/mixins/unix.rb +279 -0
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +10 -10
- data/lib/ronin/network/proxy.rb +578 -0
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +12 -13
- data/lib/ronin/network/ssl.rb +16 -17
- data/lib/ronin/network/tcp.rb +7 -310
- data/lib/ronin/network/tcp/proxy.rb +417 -0
- data/lib/ronin/network/tcp/tcp.rb +452 -0
- data/lib/ronin/network/telnet.rb +34 -28
- data/lib/ronin/network/udp.rb +7 -271
- data/lib/ronin/network/udp/proxy.rb +191 -0
- data/lib/ronin/network/udp/udp.rb +452 -0
- data/lib/ronin/network/unix.rb +286 -0
- data/lib/ronin/path.rb +35 -39
- data/lib/ronin/spec/ui/output.rb +6 -12
- data/lib/ronin/support.rb +6 -5
- data/lib/ronin/support/inflector.rb +8 -12
- data/lib/ronin/support/support.rb +7 -5
- data/lib/ronin/support/version.rb +6 -6
- data/lib/ronin/templates.rb +5 -5
- data/lib/ronin/templates/erb.rb +5 -5
- data/lib/ronin/templates/template.rb +5 -5
- data/lib/ronin/ui/output.rb +5 -5
- data/lib/ronin/ui/output/helpers.rb +42 -28
- data/lib/ronin/ui/output/output.rb +17 -21
- data/lib/ronin/ui/output/terminal.rb +5 -5
- data/lib/ronin/ui/output/terminal/color.rb +15 -9
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +8 -11
- data/lib/ronin/wordlist.rb +110 -30
- data/ronin-support.gemspec +39 -109
- data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
- data/spec/binary/hexdump/parser_spec.rb +302 -0
- data/spec/binary/struct_spec.rb +496 -0
- data/spec/binary/template_spec.rb +416 -0
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +76 -50
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +119 -59
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +31 -30
- data/spec/formatting/binary/array_spec.rb +26 -0
- data/spec/formatting/binary/base64_spec.rb +50 -0
- data/spec/formatting/binary/float_spec.rb +36 -0
- data/spec/formatting/binary/integer_spec.rb +76 -50
- data/spec/formatting/binary/string_spec.rb +91 -198
- data/spec/formatting/digest/string_spec.rb +5 -5
- data/spec/formatting/html/integer_spec.rb +6 -6
- data/spec/formatting/html/string_spec.rb +10 -10
- data/spec/formatting/http/integer_spec.rb +3 -3
- data/spec/formatting/http/string_spec.rb +5 -5
- data/spec/formatting/sql/string_spec.rb +21 -19
- data/spec/formatting/text/array_spec.rb +15 -15
- data/spec/formatting/text/string_spec.rb +58 -28
- data/spec/fuzzing/extensions/string_spec.rb +87 -0
- data/spec/fuzzing/fuzzer_spec.rb +109 -0
- data/spec/fuzzing/fuzzing_spec.rb +24 -0
- data/spec/fuzzing/mutator_spec.rb +112 -0
- data/spec/fuzzing/repeater_spec.rb +57 -0
- data/spec/fuzzing/template_spec.rb +54 -0
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +89 -23
- data/spec/network/ftp_spec.rb +81 -0
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +2 -2
- data/spec/network/proxy_spec.rb +121 -0
- data/spec/network/shared/unix_server.rb +31 -0
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +53 -3
- data/spec/network/tcp/proxy_spec.rb +118 -0
- data/spec/network/tcp/tcp_spec.rb +316 -0
- data/spec/network/telnet_spec.rb +67 -0
- data/spec/network/udp/udp_spec.rb +298 -0
- data/spec/network/unix_spec.rb +182 -0
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +2 -3
- data/spec/support/inflector_spec.rb +4 -4
- data/spec/support_spec.rb +1 -1
- data/spec/templates/erb_spec.rb +3 -3
- data/spec/templates/template_spec.rb +10 -10
- data/spec/ui/shell_spec.rb +15 -15
- data/spec/wordlist_spec.rb +80 -19
- metadata +176 -121
- data/.gemtest +0 -0
- data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
- data/spec/fuzzing/string_spec.rb +0 -158
- data/spec/network/tcp_spec.rb +0 -247
- data/spec/network/udp_spec.rb +0 -248
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/extensions/ip_addr'
|
data/lib/ronin/network/imap.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/ssl'
|
@@ -36,7 +36,7 @@ module Ronin
|
|
36
36
|
#
|
37
37
|
# @api public
|
38
38
|
#
|
39
|
-
def
|
39
|
+
def self.default_port
|
40
40
|
@default_port ||= DEFAULT_PORT
|
41
41
|
end
|
42
42
|
|
@@ -48,7 +48,7 @@ module Ronin
|
|
48
48
|
#
|
49
49
|
# @api public
|
50
50
|
#
|
51
|
-
def
|
51
|
+
def self.default_port=(port)
|
52
52
|
@default_port = port
|
53
53
|
end
|
54
54
|
|
@@ -90,19 +90,20 @@ module Ronin
|
|
90
90
|
# @api public
|
91
91
|
#
|
92
92
|
def imap_connect(host,options={})
|
93
|
-
host
|
94
|
-
port
|
95
|
-
certs
|
96
|
-
auth
|
97
|
-
user
|
93
|
+
host = host.to_s
|
94
|
+
port = (options[:port] || IMAP.default_port)
|
95
|
+
certs = options[:certs]
|
96
|
+
auth = options[:auth]
|
97
|
+
user = options[:user]
|
98
98
|
passwd = options[:password]
|
99
99
|
|
100
100
|
if options[:ssl]
|
101
|
-
ssl
|
102
|
-
ssl_certs
|
101
|
+
ssl = true
|
102
|
+
ssl_certs = options[:ssl][:certs]
|
103
103
|
ssl_verify = SSL::VERIFY[options[:ssl][:verify]]
|
104
104
|
else
|
105
|
-
ssl
|
105
|
+
ssl = false
|
106
|
+
ssl_certs = nil
|
106
107
|
ssl_verify = false
|
107
108
|
end
|
108
109
|
|
data/lib/ronin/network/mixins.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/mixins/dns'
|
@@ -25,4 +25,5 @@ require 'ronin/network/mixins/esmtp'
|
|
25
25
|
require 'ronin/network/mixins/pop3'
|
26
26
|
require 'ronin/network/mixins/imap'
|
27
27
|
require 'ronin/network/mixins/telnet'
|
28
|
+
require 'ronin/network/mixins/ftp'
|
28
29
|
require 'ronin/network/mixins/http'
|
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/mixins/mixin'
|
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/mixins/mixin'
|
@@ -0,0 +1,155 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of ronin-support.
|
5
|
+
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# ronin-support 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 Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/network/mixins/mixin'
|
21
|
+
require 'ronin/network/ftp'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
module Network
|
25
|
+
module Mixins
|
26
|
+
#
|
27
|
+
# Adds FTP convenience methods and connection parameters to a class.
|
28
|
+
#
|
29
|
+
# Defines the following parameters:
|
30
|
+
#
|
31
|
+
# * `host` (`String`) - FTP host.
|
32
|
+
# * `port` (`Integer`) - FTP port.
|
33
|
+
# * `ftp_user` (`String`) - FTP user to login as.
|
34
|
+
# * `ftp_password` (`String`) - FTP password to login with.
|
35
|
+
# * `ftp_account` (`String`) - FTP account information to send.
|
36
|
+
#
|
37
|
+
# @since 0.5.0
|
38
|
+
#
|
39
|
+
module FTP
|
40
|
+
include Mixin, Network::FTP
|
41
|
+
|
42
|
+
# FTP host
|
43
|
+
parameter :host, :type => String,
|
44
|
+
:description => 'FTP host'
|
45
|
+
|
46
|
+
# FTP port
|
47
|
+
parameter :port, :type => Integer,
|
48
|
+
:description => 'FTP port'
|
49
|
+
|
50
|
+
# FTP user to login as
|
51
|
+
parameter :ftp_user, :type => String,
|
52
|
+
:description => 'FTP user to login as'
|
53
|
+
|
54
|
+
# FTP password to login with
|
55
|
+
parameter :ftp_password, :type => String,
|
56
|
+
:description => 'FTP password to login with'
|
57
|
+
|
58
|
+
# FTP account information to send
|
59
|
+
parameter :ftp_password, :type => String,
|
60
|
+
:description => 'FTP account information'
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
#
|
65
|
+
# Creates a connection to the FTP server. The `host`, `port`,
|
66
|
+
# `ftp_user`, `ftp_password` and `ftp_account` parameters
|
67
|
+
# will also be used to connect to the server.
|
68
|
+
#
|
69
|
+
# @param [Hash] options
|
70
|
+
# Additional options.
|
71
|
+
#
|
72
|
+
# @option options [Integer] :port (Network::FTP.default_port)
|
73
|
+
# The port to connect to.
|
74
|
+
#
|
75
|
+
# @option options [String] :user
|
76
|
+
# The username to authenticate with.
|
77
|
+
#
|
78
|
+
# @option options [String] :password
|
79
|
+
# The password to authenticate with.
|
80
|
+
#
|
81
|
+
# @option options [String] :account
|
82
|
+
# The account information to send via the FTP `ACCT` command.
|
83
|
+
#
|
84
|
+
# @yield [session]
|
85
|
+
# If a block is given, it will be passed an FTP session object.
|
86
|
+
#
|
87
|
+
# @yieldparam [Net::FTP] session
|
88
|
+
# The FTP session.
|
89
|
+
#
|
90
|
+
# @return [Net::FTP]
|
91
|
+
# The FTP session.
|
92
|
+
#
|
93
|
+
# @see Network::FTP#ftp_connect
|
94
|
+
#
|
95
|
+
# @api public
|
96
|
+
#
|
97
|
+
def ftp_connect(options={},&block)
|
98
|
+
print_info "Connecting to #{host_port} ..."
|
99
|
+
|
100
|
+
return super(self.host,ftp_merge_options(options),&block)
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# Starts a session with the FTP server. The `host`, `port`,
|
105
|
+
# `ftp_login`, `ftp_user` and `ftp_password` parameters
|
106
|
+
# will also be used to connect to the server.
|
107
|
+
#
|
108
|
+
# @yield [session]
|
109
|
+
# If a block is given, it will be passed an FTP session object.
|
110
|
+
# After the block has returned, the session will be closed.
|
111
|
+
#
|
112
|
+
# @yieldparam [Net::FTP] session
|
113
|
+
# The FTP session.
|
114
|
+
#
|
115
|
+
# @see Network::FTP#ftp_session
|
116
|
+
#
|
117
|
+
# @api public
|
118
|
+
#
|
119
|
+
def ftp_session(options={},&block)
|
120
|
+
super(ftp_merge_options(options)) do |sess|
|
121
|
+
yield sess if block_given?
|
122
|
+
|
123
|
+
print_info "Logging out ..."
|
124
|
+
end
|
125
|
+
|
126
|
+
print_info "Disconnected to #{host_port}"
|
127
|
+
return nil
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
#
|
133
|
+
# Merges the FTP parameters into the options for {Network::FTP}
|
134
|
+
# methods.
|
135
|
+
#
|
136
|
+
# @param [Hash] options
|
137
|
+
# The original options.
|
138
|
+
#
|
139
|
+
# @return [Hash]
|
140
|
+
# The merged options.
|
141
|
+
#
|
142
|
+
# @api private
|
143
|
+
#
|
144
|
+
def ftp_merge_options(options={})
|
145
|
+
options[:port] ||= self.port
|
146
|
+
options[:user] ||= self.ftp_user
|
147
|
+
options[:password] ||= self.ftp_password
|
148
|
+
options[:account] ||= self.ftp_account
|
149
|
+
|
150
|
+
return options
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2006-
|
2
|
+
# Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
3
|
#
|
4
|
-
# This file is part of
|
4
|
+
# This file is part of ronin-support.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
7
7
|
# it under the terms of the GNU Lesser General Public License as published
|
8
8
|
# by the Free Software Foundation, either version 3 of the License, or
|
9
9
|
# (at your option) any later version.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# ronin-support is distributed in the hope that it will be useful,
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Lesser General Public License for more details.
|
15
15
|
#
|
16
16
|
# You should have received a copy of the GNU Lesser General Public License
|
17
|
-
# along with
|
17
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/network/mixins/mixin'
|
@@ -78,7 +78,7 @@ module Ronin
|
|
78
78
|
end
|
79
79
|
|
80
80
|
#
|
81
|
-
#
|
81
|
+
# Starts a HTTP connection with the server.
|
82
82
|
#
|
83
83
|
# @param [Hash] options
|
84
84
|
# Additional options
|
@@ -86,51 +86,46 @@ module Ronin
|
|
86
86
|
# @option options [String, URI::HTTP] :url
|
87
87
|
# The full URL to request.
|
88
88
|
#
|
89
|
-
# @option options [String] :user
|
90
|
-
# The user to authenticate with when connecting to the HTTP
|
91
|
-
# server.
|
92
|
-
#
|
93
|
-
# @option options [String] :password
|
94
|
-
# The password to authenticate with when connecting to the HTTP
|
95
|
-
# server.
|
96
|
-
#
|
97
89
|
# @option options [String] :host
|
98
90
|
# The host the HTTP server is running on.
|
99
91
|
#
|
100
92
|
# @option options [Integer] :port (Net::HTTP.default_port)
|
101
93
|
# The port the HTTP server is listening on.
|
102
94
|
#
|
103
|
-
# @option options [String] :
|
104
|
-
#
|
95
|
+
# @option options [String, Hash] :proxy (HTTP.proxy)
|
96
|
+
# A Hash of proxy settings to use when connecting to the HTTP server.
|
105
97
|
#
|
106
|
-
# @
|
107
|
-
#
|
108
|
-
# object.
|
98
|
+
# @option options [String] :user
|
99
|
+
# The user to authenticate with when connecting to the HTTP server.
|
109
100
|
#
|
110
|
-
# @
|
101
|
+
# @option options [String] :password
|
102
|
+
# The password to authenticate with when connecting to the HTTP
|
103
|
+
# server.
|
104
|
+
#
|
105
|
+
# @option options [Boolean, Hash] :ssl
|
106
|
+
# Enables SSL for the HTTP connection.
|
107
|
+
#
|
108
|
+
# @option :ssl [Symbol] :verify
|
109
|
+
# Specifies the SSL certificate verification mode.
|
110
|
+
#
|
111
|
+
# @yield [http]
|
112
|
+
# If a block is given, it will be passed the newly created HTTP
|
113
|
+
# session object.
|
114
|
+
#
|
115
|
+
# @yieldparam [Net::HTTP] http
|
111
116
|
# The newly created HTTP session.
|
112
117
|
#
|
113
118
|
# @return [Net::HTTP]
|
114
119
|
# The HTTP session object.
|
115
120
|
#
|
116
|
-
# @see Network::HTTP#
|
121
|
+
# @see Network::HTTP#http_connect
|
117
122
|
#
|
118
123
|
# @api public
|
119
124
|
#
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
super(options)
|
124
|
-
print_info "Starting HTTP Session with #{host_port}"
|
125
|
-
|
126
|
-
if block.arity == 2
|
127
|
-
block.call(http,expanded_options)
|
128
|
-
else
|
129
|
-
block.call(http)
|
130
|
-
end
|
131
|
-
|
132
|
-
print_info "Closing HTTP Session with #{host_port}"
|
133
|
-
end
|
125
|
+
# @since 0.5.0
|
126
|
+
#
|
127
|
+
def http_connect(options={},&block)
|
128
|
+
super(http_merge_options(options),&block)
|
134
129
|
end
|
135
130
|
|
136
131
|
#
|
@@ -149,13 +144,13 @@ module Ronin
|
|
149
144
|
# If the block has an arity of 2, it will also be passed the
|
150
145
|
# expanded version of the given options.
|
151
146
|
#
|
152
|
-
# @yieldparam [Net::
|
147
|
+
# @yieldparam [Net::HTTPRequest] request
|
153
148
|
# The HTTP request object to use in the request.
|
154
149
|
#
|
155
150
|
# @yieldparam [Hash] options
|
156
151
|
# The expanded version of the given options.
|
157
152
|
#
|
158
|
-
# @return [Net::
|
153
|
+
# @return [Net::HTTPResponse]
|
159
154
|
# The response of the HTTP request.
|
160
155
|
#
|
161
156
|
# @see Network::HTTP#http_request
|
@@ -163,523 +158,32 @@ module Ronin
|
|
163
158
|
# @api public
|
164
159
|
#
|
165
160
|
def http_request(options={},&block)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
#
|
175
|
-
# @param [Hash] options
|
176
|
-
# Additional options.
|
177
|
-
#
|
178
|
-
# @option options [Symbol, String] :method (:head)
|
179
|
-
# The method to use for the request.
|
180
|
-
#
|
181
|
-
# @return [Integer]
|
182
|
-
# The HTTP Response Status.
|
183
|
-
#
|
184
|
-
# @see Network::HTTP#http_status
|
185
|
-
#
|
186
|
-
# @since 1.1.0
|
187
|
-
#
|
188
|
-
# @api public
|
189
|
-
#
|
190
|
-
def http_status(options={})
|
191
|
-
options = http_merge_options(options)
|
192
|
-
|
193
|
-
if (result = super(options))
|
194
|
-
print_debug "HTTP #{result} #{http_options_to_s(options)}"
|
195
|
-
end
|
161
|
+
response = super(options) do |request,expanded_options|
|
162
|
+
if block
|
163
|
+
if block.arity == 2
|
164
|
+
block.call(request,expanded_options)
|
165
|
+
else
|
166
|
+
block.call(request)
|
167
|
+
end
|
168
|
+
end
|
196
169
|
|
197
|
-
|
198
|
-
|
170
|
+
host = options.fetch(:host,self.host)
|
171
|
+
port = options.fetch(:port,self.port)
|
199
172
|
|
200
|
-
|
201
|
-
# Checks if the response has an HTTP OK status code.
|
202
|
-
#
|
203
|
-
# @param [Hash] options
|
204
|
-
# Additional options.
|
205
|
-
#
|
206
|
-
# @option options [Symbol, String] :method (:head)
|
207
|
-
# The method to use for the request.
|
208
|
-
#
|
209
|
-
# @return [Boolean]
|
210
|
-
# Specifies whether the response had an HTTP OK status code or not.
|
211
|
-
#
|
212
|
-
# @see Network::HTTP#http_ok?
|
213
|
-
#
|
214
|
-
# @since 1.1.0
|
215
|
-
#
|
216
|
-
# @api public
|
217
|
-
#
|
218
|
-
def http_ok?(options={})
|
219
|
-
options = http_merge_options(options)
|
173
|
+
print_info "HTTP #{request.method} #{host}:#{port} #{request.path}"
|
220
174
|
|
221
|
-
|
222
|
-
|
175
|
+
request.each_capitalized do |name,value|
|
176
|
+
print_debug " #{name}: #{value}"
|
177
|
+
end
|
223
178
|
end
|
224
179
|
|
225
|
-
|
226
|
-
end
|
227
|
-
|
228
|
-
#
|
229
|
-
# Sends a HTTP Head request and returns the HTTP Server header.
|
230
|
-
#
|
231
|
-
# @param [Hash] options
|
232
|
-
# Additional options.
|
233
|
-
#
|
234
|
-
# @option options [Symbol, String] :method (:head)
|
235
|
-
# The method to use for the request.
|
236
|
-
#
|
237
|
-
# @return [String]
|
238
|
-
# The HTTP `Server` header.
|
239
|
-
#
|
240
|
-
# @see Network::HTTP#http_server
|
241
|
-
#
|
242
|
-
# @since 1.1.0
|
243
|
-
#
|
244
|
-
# @api public
|
245
|
-
#
|
246
|
-
def http_server(options={})
|
247
|
-
options = http_merge_options(options)
|
180
|
+
print_info "HTTP #{response.code} #{response.message}"
|
248
181
|
|
249
|
-
|
250
|
-
print_debug "
|
182
|
+
response.each_capitalized do |name,value|
|
183
|
+
print_debug " #{name}: #{value}"
|
251
184
|
end
|
252
185
|
|
253
|
-
return
|
254
|
-
end
|
255
|
-
|
256
|
-
#
|
257
|
-
# Sends an HTTP Head request and returns the HTTP X-Powered-By header.
|
258
|
-
#
|
259
|
-
# @param [Hash] options
|
260
|
-
# Additional options.
|
261
|
-
#
|
262
|
-
# @option options [Symbol, String] :method (:get)
|
263
|
-
# The method to use for the request.
|
264
|
-
#
|
265
|
-
# @return [String]
|
266
|
-
# The HTTP `X-Powered-By` header.
|
267
|
-
#
|
268
|
-
# @see Network::HTTP#http_powered_by
|
269
|
-
#
|
270
|
-
# @since 1.1.0
|
271
|
-
#
|
272
|
-
# @api public
|
273
|
-
#
|
274
|
-
def http_powered_by(options={})
|
275
|
-
options = http_merge_options(options)
|
276
|
-
|
277
|
-
if (result = super(options))
|
278
|
-
print_debug "HTTP X-Powered-By: #{result}"
|
279
|
-
end
|
280
|
-
|
281
|
-
return result
|
282
|
-
end
|
283
|
-
|
284
|
-
#
|
285
|
-
# Performs an HTTP Copy request.
|
286
|
-
#
|
287
|
-
# @yield [response]
|
288
|
-
# If a block is given, it will be passed the response received
|
289
|
-
# from the request.
|
290
|
-
#
|
291
|
-
# @yieldparam [Net::HTTP::Response] response
|
292
|
-
# The HTTP response object.
|
293
|
-
#
|
294
|
-
# @return [Net::HTTP::Response]
|
295
|
-
# The response of the HTTP request.
|
296
|
-
#
|
297
|
-
# @see Network::HTTP#http_copy
|
298
|
-
#
|
299
|
-
# @api public
|
300
|
-
#
|
301
|
-
def http_copy(options={},&block)
|
302
|
-
options = http_merge_options(options)
|
303
|
-
print_info "HTTP COPY #{http_options_to_s(options)}"
|
304
|
-
|
305
|
-
return super(options,&block)
|
306
|
-
end
|
307
|
-
|
308
|
-
#
|
309
|
-
# Performs an HTTP Delete request.
|
310
|
-
#
|
311
|
-
# @yield [response]
|
312
|
-
# If a block is given, it will be passed the response received
|
313
|
-
# from the request.
|
314
|
-
#
|
315
|
-
# @yieldparam [Net::HTTP::Response] response
|
316
|
-
# The HTTP response object.
|
317
|
-
#
|
318
|
-
# @return [Net::HTTP::Response]
|
319
|
-
# The response of the HTTP request.
|
320
|
-
#
|
321
|
-
# @see Network::HTTP#http_delete
|
322
|
-
#
|
323
|
-
# @api public
|
324
|
-
#
|
325
|
-
def http_delete(options={},&block)
|
326
|
-
options = http_merge_options(options)
|
327
|
-
print_info "HTTP DELETE #{http_options_to_s(options)}"
|
328
|
-
|
329
|
-
return super(options,&block)
|
330
|
-
end
|
331
|
-
|
332
|
-
#
|
333
|
-
# Performs an HTTP Get request.
|
334
|
-
#
|
335
|
-
# @yield [response]
|
336
|
-
# If a block is given, it will be passed the response received
|
337
|
-
# from the request.
|
338
|
-
#
|
339
|
-
# @yieldparam [Net::HTTP::Response] response
|
340
|
-
# The HTTP response object.
|
341
|
-
#
|
342
|
-
# @return [Net::HTTP::Response]
|
343
|
-
# The response of the HTTP request.
|
344
|
-
#
|
345
|
-
# @see Network::HTTP#http_get
|
346
|
-
#
|
347
|
-
# @api public
|
348
|
-
#
|
349
|
-
def http_get(options={},&block)
|
350
|
-
options = http_merge_options(options)
|
351
|
-
print_info "HTTP GET #{http_options_to_s(options)}"
|
352
|
-
|
353
|
-
return super(options,&block)
|
354
|
-
end
|
355
|
-
|
356
|
-
#
|
357
|
-
# Performs an HTTP Get request.
|
358
|
-
#
|
359
|
-
# @yield [response]
|
360
|
-
# If a block is given, it will be passed the response received
|
361
|
-
# from the request.
|
362
|
-
#
|
363
|
-
# @yieldparam [Net::HTTP::Response] response
|
364
|
-
# The HTTP response object.
|
365
|
-
#
|
366
|
-
# @return [String]
|
367
|
-
# The body of the HTTP Get request.
|
368
|
-
#
|
369
|
-
# @see Network::HTTP#http_get_body
|
370
|
-
#
|
371
|
-
# @api public
|
372
|
-
#
|
373
|
-
def http_get_body(options={},&block)
|
374
|
-
options = http_merge_options(options)
|
375
|
-
print_info "HTTP GET #{http_options_to_s(options)}"
|
376
|
-
|
377
|
-
return super(options,&block)
|
378
|
-
end
|
379
|
-
|
380
|
-
#
|
381
|
-
# Performs an HTTP Head request.
|
382
|
-
#
|
383
|
-
# @yield [response]
|
384
|
-
# If a block is given, it will be passed the response received
|
385
|
-
# from the request.
|
386
|
-
#
|
387
|
-
# @yieldparam [Net::HTTP::Response] response
|
388
|
-
# The HTTP response object.
|
389
|
-
#
|
390
|
-
# @return [Net::HTTP::Response]
|
391
|
-
# The response of the HTTP request.
|
392
|
-
#
|
393
|
-
# @see Network::HTTP#http_head
|
394
|
-
#
|
395
|
-
# @api public
|
396
|
-
#
|
397
|
-
def http_head(options={},&block)
|
398
|
-
options = http_merge_options(options)
|
399
|
-
print_info "HTTP HEAD #{http_options_to_s(options)}"
|
400
|
-
|
401
|
-
return super(options,&block)
|
402
|
-
end
|
403
|
-
|
404
|
-
#
|
405
|
-
# Performs an HTTP Lock request.
|
406
|
-
#
|
407
|
-
# @yield [response]
|
408
|
-
# If a block is given, it will be passed the response received
|
409
|
-
# from the request.
|
410
|
-
#
|
411
|
-
# @yieldparam [Net::HTTP::Response] response
|
412
|
-
# The HTTP response object.
|
413
|
-
#
|
414
|
-
# @return [Net::HTTP::Response]
|
415
|
-
# The response of the HTTP request.
|
416
|
-
#
|
417
|
-
# @see Network::HTTP#http_lock
|
418
|
-
#
|
419
|
-
# @api public
|
420
|
-
#
|
421
|
-
def http_lock(options={},&block)
|
422
|
-
options = http_merge_options(options)
|
423
|
-
print_info "HTTP LOCK #{http_options_to_s(options)}"
|
424
|
-
|
425
|
-
return super(options,&block)
|
426
|
-
end
|
427
|
-
|
428
|
-
#
|
429
|
-
# Performs an HTTP Mkcol request.
|
430
|
-
#
|
431
|
-
# @yield [response]
|
432
|
-
# If a block is given, it will be passed the response received
|
433
|
-
# from the request.
|
434
|
-
#
|
435
|
-
# @yieldparam [Net::HTTP::Response] response
|
436
|
-
# The HTTP response object.
|
437
|
-
#
|
438
|
-
# @return [Net::HTTP::Response]
|
439
|
-
# The response of the HTTP request.
|
440
|
-
#
|
441
|
-
# @see Network::HTTP#http_mkcol
|
442
|
-
#
|
443
|
-
# @api public
|
444
|
-
#
|
445
|
-
def http_mkcol(options={},&block)
|
446
|
-
options = http_merge_options(options)
|
447
|
-
print_info "HTTP MKCOL #{http_options_to_s(options)}"
|
448
|
-
|
449
|
-
return super(options,&block)
|
450
|
-
end
|
451
|
-
|
452
|
-
#
|
453
|
-
# Performs an HTTP Move request.
|
454
|
-
#
|
455
|
-
# @yield [response]
|
456
|
-
# If a block is given, it will be passed the response received
|
457
|
-
# from the request.
|
458
|
-
#
|
459
|
-
# @yieldparam [Net::HTTP::Response] response
|
460
|
-
# The HTTP response object.
|
461
|
-
#
|
462
|
-
# @return [Net::HTTP::Response]
|
463
|
-
# The response of the HTTP request.
|
464
|
-
#
|
465
|
-
# @see Network::HTTP#http_move
|
466
|
-
#
|
467
|
-
# @api public
|
468
|
-
#
|
469
|
-
def http_move(options={},&block)
|
470
|
-
options = http_merge_options(options)
|
471
|
-
print_info "HTTP MOVE #{http_options_to_s(options)}"
|
472
|
-
|
473
|
-
return super(options,&block)
|
474
|
-
end
|
475
|
-
|
476
|
-
#
|
477
|
-
# Performs an HTTP Options request.
|
478
|
-
#
|
479
|
-
# @yield [response]
|
480
|
-
# If a block is given, it will be passed the response received
|
481
|
-
# from the request.
|
482
|
-
#
|
483
|
-
# @yieldparam [Net::HTTP::Response] response
|
484
|
-
# The HTTP response object.
|
485
|
-
#
|
486
|
-
# @return [Net::HTTP::Response]
|
487
|
-
# The response of the HTTP request.
|
488
|
-
#
|
489
|
-
# @see Network::HTTP#http_options
|
490
|
-
#
|
491
|
-
# @api public
|
492
|
-
#
|
493
|
-
def http_options(options={},&block)
|
494
|
-
options = http_merge_options(options)
|
495
|
-
print_info "HTTP OPTIONS #{http_options_to_s(options)}"
|
496
|
-
|
497
|
-
return super(options,&block)
|
498
|
-
end
|
499
|
-
|
500
|
-
#
|
501
|
-
# Performs an HTTP Post request.
|
502
|
-
#
|
503
|
-
# @param [Hash] options
|
504
|
-
# Additional options.
|
505
|
-
#
|
506
|
-
# @option options [String] :post_data
|
507
|
-
# The `POSTDATA` to send with the HTTP Post request.
|
508
|
-
#
|
509
|
-
# @yield [response]
|
510
|
-
# If a block is given, it will be passed the response received
|
511
|
-
# from the request.
|
512
|
-
#
|
513
|
-
# @yieldparam [Net::HTTP::Response] response
|
514
|
-
# The HTTP response object.
|
515
|
-
#
|
516
|
-
# @return [Net::HTTP::Response]
|
517
|
-
# The response of the HTTP request.
|
518
|
-
#
|
519
|
-
# @see Network::HTTP#http_post
|
520
|
-
#
|
521
|
-
# @api public
|
522
|
-
#
|
523
|
-
def http_post(options={},&block)
|
524
|
-
options = http_merge_options(options)
|
525
|
-
print_info "HTTP POST #{http_options_to_s(options)}"
|
526
|
-
|
527
|
-
return super(options,&block)
|
528
|
-
end
|
529
|
-
|
530
|
-
#
|
531
|
-
# Performs an HTTP Post request.
|
532
|
-
#
|
533
|
-
# @yield [response]
|
534
|
-
# If a block is given, it will be passed the response received
|
535
|
-
# from the request.
|
536
|
-
#
|
537
|
-
# @yieldparam [Net::HTTP::Response] response
|
538
|
-
# The HTTP response object.
|
539
|
-
#
|
540
|
-
# @return [String]
|
541
|
-
# The body of the Post request.
|
542
|
-
#
|
543
|
-
# @see Network::HTTP#http_post_body
|
544
|
-
#
|
545
|
-
# @api public
|
546
|
-
#
|
547
|
-
def http_post_body(options={},&block)
|
548
|
-
options = http_merge_options(options)
|
549
|
-
print_info "HTTP POST #{http_options_to_s(options)}"
|
550
|
-
|
551
|
-
return super(options,&block)
|
552
|
-
end
|
553
|
-
|
554
|
-
#
|
555
|
-
# Performs an HTTP PUT request.
|
556
|
-
#
|
557
|
-
# @param [Hash] options
|
558
|
-
# Additional options.
|
559
|
-
#
|
560
|
-
# @option options [String] :body
|
561
|
-
# The body for the request.
|
562
|
-
#
|
563
|
-
# @option options [String] :post_data
|
564
|
-
# The `POSTDATA` to send with the HTTP PUT request.
|
565
|
-
#
|
566
|
-
# @yield [response]
|
567
|
-
# If a block is given, it will be passed the response received
|
568
|
-
# from the request.
|
569
|
-
#
|
570
|
-
# @yieldparam [Net::HTTP::Response] response
|
571
|
-
# The HTTP response object.
|
572
|
-
#
|
573
|
-
# @return [Net::HTTP::Response]
|
574
|
-
# The response of the HTTP request.
|
575
|
-
#
|
576
|
-
# @see Network::HTTP#http_put
|
577
|
-
#
|
578
|
-
# @since 0.4.0
|
579
|
-
#
|
580
|
-
# @api public
|
581
|
-
#
|
582
|
-
def http_put(options={},&block)
|
583
|
-
options = http_merge_options(options)
|
584
|
-
print_info "HTTP PUT #{http_options_to_s(options)}"
|
585
|
-
|
586
|
-
return super(options,&block)
|
587
|
-
end
|
588
|
-
|
589
|
-
#
|
590
|
-
# Performs an HTTP Propfind request.
|
591
|
-
#
|
592
|
-
# @yield [response]
|
593
|
-
# If a block is given, it will be passed the response received
|
594
|
-
# from the request.
|
595
|
-
#
|
596
|
-
# @yieldparam [Net::HTTP::Response] response
|
597
|
-
# The HTTP response object.
|
598
|
-
#
|
599
|
-
# @return [Net::HTTP::Response]
|
600
|
-
# The response of the HTTP request.
|
601
|
-
#
|
602
|
-
# @see Network::HTTP#http_prop_find
|
603
|
-
#
|
604
|
-
# @api public
|
605
|
-
#
|
606
|
-
def http_prop_find(options={},&block)
|
607
|
-
options = http_merge_options(options)
|
608
|
-
print_info "HTTP PROPFIND #{http_options_to_s(options)}"
|
609
|
-
|
610
|
-
return super(options,&block)
|
611
|
-
end
|
612
|
-
|
613
|
-
#
|
614
|
-
# Performs an HTTP Proppatch request.
|
615
|
-
#
|
616
|
-
# @yield [response]
|
617
|
-
# If a block is given, it will be passed the response received
|
618
|
-
# from the request.
|
619
|
-
#
|
620
|
-
# @yieldparam [Net::HTTP::Response] response
|
621
|
-
# The HTTP response object.
|
622
|
-
#
|
623
|
-
# @return [Net::HTTP::Response]
|
624
|
-
# The response of the HTTP request.
|
625
|
-
#
|
626
|
-
# @see Network::HTTP#http_prop_patch
|
627
|
-
#
|
628
|
-
# @api public
|
629
|
-
#
|
630
|
-
def http_prop_patch(options={},&block)
|
631
|
-
options = http_merge_options(options)
|
632
|
-
print_info "HTTP PROPPATCH #{http_options_to_s(options)}"
|
633
|
-
|
634
|
-
return super(options,&block)
|
635
|
-
end
|
636
|
-
|
637
|
-
#
|
638
|
-
# Performs an HTTP Trace request.
|
639
|
-
#
|
640
|
-
# @yield [response]
|
641
|
-
# If a block is given, it will be passed the response received
|
642
|
-
# from the request.
|
643
|
-
#
|
644
|
-
# @yieldparam [Net::HTTP::Response] response
|
645
|
-
# The HTTP response object.
|
646
|
-
#
|
647
|
-
# @return [Net::HTTP::Response]
|
648
|
-
# The response of the HTTP request.
|
649
|
-
#
|
650
|
-
# @see Network::HTTP#http_trace
|
651
|
-
#
|
652
|
-
# @api public
|
653
|
-
#
|
654
|
-
def http_trace(options={},&block)
|
655
|
-
options = http_merge_options(options)
|
656
|
-
print_info "HTTP TRACE #{http_options_to_s(options)}"
|
657
|
-
|
658
|
-
return super(options,&block)
|
659
|
-
end
|
660
|
-
|
661
|
-
#
|
662
|
-
# Performs an HTTP Unlock request.
|
663
|
-
#
|
664
|
-
# @yield [response]
|
665
|
-
# If a block is given, it will be passed the response received
|
666
|
-
# from the request.
|
667
|
-
#
|
668
|
-
# @yieldparam [Net::HTTP::Response] response
|
669
|
-
# The HTTP response object.
|
670
|
-
#
|
671
|
-
# @return [Net::HTTP::Response]
|
672
|
-
# The response of the HTTP request.
|
673
|
-
#
|
674
|
-
# @see Network::HTTP#http_unlock
|
675
|
-
#
|
676
|
-
# @api public
|
677
|
-
#
|
678
|
-
def http_unlock(options={},&block)
|
679
|
-
options = http_merge_options(options)
|
680
|
-
print_info "HTTP UNLOCK #{http_options_to_s(options)}"
|
681
|
-
|
682
|
-
return super(options,&block)
|
186
|
+
return response
|
683
187
|
end
|
684
188
|
|
685
189
|
private
|
@@ -698,58 +202,25 @@ module Ronin
|
|
698
202
|
# @api private
|
699
203
|
#
|
700
204
|
def http_merge_options(options={})
|
701
|
-
options
|
702
|
-
|
205
|
+
options = options.dup
|
206
|
+
|
207
|
+
options[:proxy] ||= self.http_proxy if self.http_proxy
|
208
|
+
options[:host] ||= self.host if self.host
|
209
|
+
options[:port] ||= self.port if self.port
|
703
210
|
|
704
211
|
if (self.http_vhost || self.http_user_agent)
|
705
|
-
headers = options
|
212
|
+
headers = (options[:headers] ||= {})
|
706
213
|
|
707
|
-
headers[:host]
|
214
|
+
headers[:host] ||= self.http_vhost if self.http_vhost
|
708
215
|
headers[:user_agent] ||= self.http_user_agent if self.http_user_agent
|
709
|
-
|
710
|
-
options[:headers] = headers
|
711
216
|
end
|
712
217
|
|
713
|
-
options[:user]
|
218
|
+
options[:user] ||= self.http_user if self.http_user
|
714
219
|
options[:password] ||= self.http_password if self.http_password
|
715
220
|
|
716
|
-
options[:proxy] ||= self.http_proxy if self.http_proxy
|
717
|
-
|
718
221
|
return options
|
719
222
|
end
|
720
223
|
|
721
|
-
#
|
722
|
-
# Converts the HTTP options to a printable String.
|
723
|
-
#
|
724
|
-
# @param [Hash] options
|
725
|
-
# HTTP options.
|
726
|
-
#
|
727
|
-
# @return [String]
|
728
|
-
# The printable String.
|
729
|
-
#
|
730
|
-
# @since 1.1.0
|
731
|
-
#
|
732
|
-
# @api private
|
733
|
-
#
|
734
|
-
def http_options_to_s(options)
|
735
|
-
fields = ["#{options[:host]}:#{options[:port]}"]
|
736
|
-
|
737
|
-
if (options[:user] || options[:password])
|
738
|
-
fields << "#{options[:user]}:#{options[:password]}"
|
739
|
-
end
|
740
|
-
|
741
|
-
path = options[:path]
|
742
|
-
path += "?#{options[:query]}" if options[:query]
|
743
|
-
|
744
|
-
fields << path
|
745
|
-
|
746
|
-
if options[:headers]
|
747
|
-
fields << ("%p" % options[:headers])
|
748
|
-
end
|
749
|
-
|
750
|
-
return fields.join(' ')
|
751
|
-
end
|
752
|
-
|
753
224
|
end
|
754
225
|
end
|
755
226
|
end
|