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/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/ui/output/helpers'
|
@@ -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'
|
@@ -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'
|
@@ -64,6 +64,29 @@ module Ronin
|
|
64
64
|
|
65
65
|
protected
|
66
66
|
|
67
|
+
#
|
68
|
+
# Tests whether the TCP port, specified by the `host` and `port`
|
69
|
+
# parameters, is open.
|
70
|
+
#
|
71
|
+
# @param [Integer] timeout (5)
|
72
|
+
# The maximum time to attempt connecting.
|
73
|
+
#
|
74
|
+
# @return [Boolean, nil]
|
75
|
+
# Specifies whether the remote TCP port is open.
|
76
|
+
# If the connection was not accepted, `nil` will be returned.
|
77
|
+
#
|
78
|
+
# @see Network::TCP#tcp_open?
|
79
|
+
#
|
80
|
+
# @api public
|
81
|
+
#
|
82
|
+
# @since 0.5.0
|
83
|
+
#
|
84
|
+
def tcp_open?(timeout=nil)
|
85
|
+
print_info "Testing if #{host_port} is open ..."
|
86
|
+
|
87
|
+
super(self.host,self.port,self.local_host,self.local_port,timeout)
|
88
|
+
end
|
89
|
+
|
67
90
|
#
|
68
91
|
# Opens a TCP connection to the host and port specified by the
|
69
92
|
# `host` and `port` parameters. If the `local_host` and
|
@@ -147,7 +170,7 @@ module Ronin
|
|
147
170
|
def tcp_session(&block)
|
148
171
|
print_info "Connecting to #{host_port} ..."
|
149
172
|
|
150
|
-
|
173
|
+
super(self.host,self.port,self.local_host,self.local_port,&block)
|
151
174
|
|
152
175
|
print_info "Disconnected from #{host_port}"
|
153
176
|
return nil
|
@@ -189,7 +212,7 @@ module Ronin
|
|
189
212
|
#
|
190
213
|
# @example
|
191
214
|
# buffer = "GET /" + ('A' * 4096) + "\n\r"
|
192
|
-
#
|
215
|
+
# tcp_send(buffer)
|
193
216
|
# # => true
|
194
217
|
#
|
195
218
|
# @see Network::TCP#tcp_send
|
@@ -287,15 +310,17 @@ module Ronin
|
|
287
310
|
# @return [nil]
|
288
311
|
#
|
289
312
|
# @example
|
290
|
-
#
|
313
|
+
# tcp_accept do |client|
|
291
314
|
# client.puts 'lol'
|
292
315
|
# end
|
293
316
|
#
|
294
|
-
# @see Network::TCP#
|
317
|
+
# @see Network::TCP#tcp_accept
|
295
318
|
#
|
296
319
|
# @api public
|
297
320
|
#
|
298
|
-
|
321
|
+
# @since 0.5.0
|
322
|
+
#
|
323
|
+
def tcp_accept(&block)
|
299
324
|
print_info "Listening on #{server_host_port} ..."
|
300
325
|
|
301
326
|
super(self.server_port,self.server_host) do |client|
|
@@ -314,6 +339,14 @@ module Ronin
|
|
314
339
|
return nil
|
315
340
|
end
|
316
341
|
|
342
|
+
#
|
343
|
+
# @deprecated
|
344
|
+
# Deprecated as of 0.5.0. Use {#tcp_accept} instead.
|
345
|
+
#
|
346
|
+
def tcp_single_server(&block)
|
347
|
+
tcp_accept(&block)
|
348
|
+
end
|
349
|
+
|
317
350
|
private
|
318
351
|
|
319
352
|
#
|
@@ -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'
|
@@ -64,6 +64,27 @@ module Ronin
|
|
64
64
|
|
65
65
|
protected
|
66
66
|
|
67
|
+
#
|
68
|
+
# Tests whether the UDP port, specified by the `host` and `port`
|
69
|
+
# parameters, is open.
|
70
|
+
#
|
71
|
+
# @param [Integer] timeout (5)
|
72
|
+
# The maximum time to attempt connecting.
|
73
|
+
#
|
74
|
+
# @return [Boolean, nil]
|
75
|
+
# Specifies whether the remote UDP port is open.
|
76
|
+
# If no data or ICMP error were received, `nil` will be returned.
|
77
|
+
#
|
78
|
+
# @api public
|
79
|
+
#
|
80
|
+
# @since 0.5.0
|
81
|
+
#
|
82
|
+
def udp_open?(timeout=nil)
|
83
|
+
print_info "Testing if #{host_port} is open ..."
|
84
|
+
|
85
|
+
super(self.host,self.port,self.local_host,self.local_port,timeout)
|
86
|
+
end
|
87
|
+
|
67
88
|
#
|
68
89
|
# Opens a UDP connection to the host and port specified by the
|
69
90
|
# `host` and `port` parameters. If the `local_host` and
|
@@ -164,7 +185,7 @@ module Ronin
|
|
164
185
|
#
|
165
186
|
# @example
|
166
187
|
# buffer = "GET /" + ('A' * 4096) + "\n\r"
|
167
|
-
#
|
188
|
+
# udp_send(buffer)
|
168
189
|
# # => true
|
169
190
|
#
|
170
191
|
# @see Network::UDP#udp_send
|
@@ -240,6 +261,105 @@ module Ronin
|
|
240
261
|
return nil
|
241
262
|
end
|
242
263
|
|
264
|
+
#
|
265
|
+
# Creates a new UDPServer listening on the `server_host` and
|
266
|
+
# `server_port` parameters, accepting messages from clients in a loop.
|
267
|
+
#
|
268
|
+
# @yield [server, (client_host, client_port), mesg]
|
269
|
+
# The given block will be passed the client host/port and the received
|
270
|
+
# message.
|
271
|
+
#
|
272
|
+
# @yieldparam [UDPServer] server
|
273
|
+
# The UDPServer.
|
274
|
+
#
|
275
|
+
# @yieldparam [String] client_host
|
276
|
+
# The source host of the mesg.
|
277
|
+
#
|
278
|
+
# @yieldparam [Integer] client_port
|
279
|
+
# The source port of the mesg.
|
280
|
+
#
|
281
|
+
# @yieldparam [String] mesg
|
282
|
+
# The received message.
|
283
|
+
#
|
284
|
+
# @return [nil]
|
285
|
+
#
|
286
|
+
# @example
|
287
|
+
# udp_server_loop do |server,(host,port),mesg|
|
288
|
+
# server.send('hello',host,port)
|
289
|
+
# end
|
290
|
+
#
|
291
|
+
# @see Network::UDP#udp_server_loop
|
292
|
+
#
|
293
|
+
# @api public
|
294
|
+
#
|
295
|
+
# @since 0.5.0
|
296
|
+
#
|
297
|
+
def udp_server_loop(&block)
|
298
|
+
print_info "Listening on #{self.server_host_port} ..."
|
299
|
+
|
300
|
+
super(self.server_port,self.server_host,&block)
|
301
|
+
|
302
|
+
print_info "Closed #{self.server_host_port}"
|
303
|
+
return nil
|
304
|
+
end
|
305
|
+
|
306
|
+
#
|
307
|
+
# Creates a new UDPServer listening on the `server_host` and
|
308
|
+
# `server_port` parameters, accepts only one message from a client.
|
309
|
+
#
|
310
|
+
# @yield [server, (client_host, client_port), mesg]
|
311
|
+
# The given block will be passed the client host/port and the received
|
312
|
+
# message.
|
313
|
+
#
|
314
|
+
# @yieldparam [UDPServer] server
|
315
|
+
# The UDPServer.
|
316
|
+
#
|
317
|
+
# @yieldparam [String] client_host
|
318
|
+
# The source host of the mesg.
|
319
|
+
#
|
320
|
+
# @yieldparam [Integer] client_port
|
321
|
+
# The source port of the mesg.
|
322
|
+
#
|
323
|
+
# @yieldparam [String] mesg
|
324
|
+
# The received message.
|
325
|
+
#
|
326
|
+
# @return [nil]
|
327
|
+
#
|
328
|
+
# @example
|
329
|
+
# udp_recv do |server,(host,port),mesg|
|
330
|
+
# server.send('hello',host,port)
|
331
|
+
# end
|
332
|
+
#
|
333
|
+
# @see Network::UDP#udp_recv
|
334
|
+
#
|
335
|
+
# @api public
|
336
|
+
#
|
337
|
+
# @since 0.5.0
|
338
|
+
#
|
339
|
+
def udp_recv(&block)
|
340
|
+
print_info "Listening on #{self.server_host_port} ..."
|
341
|
+
|
342
|
+
super(self.server_port,self.server_host) do |server,(host,port),mesg|
|
343
|
+
print_info "Received message from #{host}:#{port}"
|
344
|
+
print_debug mesg
|
345
|
+
|
346
|
+
yield server, [host, port], mesg if block_given?
|
347
|
+
end
|
348
|
+
|
349
|
+
print_info "Closed #{self.server_host_port}"
|
350
|
+
return nil
|
351
|
+
end
|
352
|
+
|
353
|
+
#
|
354
|
+
# @deprecated
|
355
|
+
# Deprecated as of 0.5.0. Use {#udp_recv} instead.
|
356
|
+
#
|
357
|
+
# @since 0.5.0
|
358
|
+
#
|
359
|
+
def udp_single_server(&block)
|
360
|
+
udp_recv(&block)
|
361
|
+
end
|
362
|
+
|
243
363
|
private
|
244
364
|
|
245
365
|
#
|
@@ -0,0 +1,279 @@
|
|
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/unix'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
module Network
|
25
|
+
module Mixins
|
26
|
+
#
|
27
|
+
# Adds UNIX Socket convenience methods and connection parameters to a
|
28
|
+
# class.
|
29
|
+
#
|
30
|
+
# Defines the following parameters:
|
31
|
+
#
|
32
|
+
# * `path` (`String`) - UNIX Socket path.
|
33
|
+
#
|
34
|
+
# @since 0.5.0
|
35
|
+
#
|
36
|
+
module UNIX
|
37
|
+
include Mixin, Network::UNIX
|
38
|
+
|
39
|
+
# UNIX path
|
40
|
+
parameter :path, :type => String,
|
41
|
+
:description => 'UNIX Socket path'
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
#
|
46
|
+
# Connects to a UNIX socket specified by the `path` parameter.
|
47
|
+
#
|
48
|
+
# @yield [socket]
|
49
|
+
# If a block is given, it will be passed an UNIX socket object.
|
50
|
+
#
|
51
|
+
# @yieldparam [UNIXSocket] socket
|
52
|
+
# The UNIX socket.
|
53
|
+
#
|
54
|
+
# @return [UNIXSocket]
|
55
|
+
# The UNIX socket.
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# socket = unix_connect
|
59
|
+
#
|
60
|
+
# @see Network::UNIX#unix_connect
|
61
|
+
#
|
62
|
+
# @api public
|
63
|
+
#
|
64
|
+
def unix_connect(&block)
|
65
|
+
print_info "Connecting to #{self.path} ..."
|
66
|
+
|
67
|
+
super(self.path,&block)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Creates a new UNIXSocket object, connected to the `path` parameter.
|
72
|
+
# The given data will then be written to the newly created UNIXSocket.
|
73
|
+
#
|
74
|
+
# @param [String] data
|
75
|
+
# The data to send to the socket.
|
76
|
+
#
|
77
|
+
# @yield [socket]
|
78
|
+
# If a block is given, it will be passed the newly created socket.
|
79
|
+
#
|
80
|
+
# @yieldparam [UNIXSocket] socket
|
81
|
+
# The newly created UNIXSocket object.
|
82
|
+
#
|
83
|
+
# @return [UNIXSocket]
|
84
|
+
# The newly created UNIXSocket object.
|
85
|
+
#
|
86
|
+
# @see Network::UNIX#unix_connect_and_send
|
87
|
+
#
|
88
|
+
# @api public
|
89
|
+
#
|
90
|
+
def unix_connect_and_send(data,&block)
|
91
|
+
print_info "Connecting to #{self.path} ..."
|
92
|
+
print_debug "Sending data: #{data.inspect}"
|
93
|
+
|
94
|
+
return super(data,self.path,&block)
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Creates a UNIX session to the host and port specified by the
|
99
|
+
# `host` and `port` parameters. If the `local_host` and `local_port`
|
100
|
+
# parameters are set, they will be used for the local host and port
|
101
|
+
# of the UNIX connection.
|
102
|
+
#
|
103
|
+
# @yield [socket]
|
104
|
+
# If a block is given, it will be passed the newly created socket.
|
105
|
+
# After the block has returned, the socket will then be closed.
|
106
|
+
#
|
107
|
+
# @yieldparam [UNIXsocket] socket
|
108
|
+
# The newly created UNIXSocket object.
|
109
|
+
#
|
110
|
+
# @see Network::UNIX#unix_session
|
111
|
+
#
|
112
|
+
# @api public
|
113
|
+
#
|
114
|
+
def unix_session(&block)
|
115
|
+
print_info "Connecting to #{self.path} ..."
|
116
|
+
|
117
|
+
super(self.host,&block)
|
118
|
+
|
119
|
+
print_info "Disconnected from #{self.path}"
|
120
|
+
return nil
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# Connects to the UNIX socket, specified by the `path` parameter,
|
125
|
+
# sends the given data and then disconnects.
|
126
|
+
#
|
127
|
+
# @param [String] data
|
128
|
+
# The data to send to the UNIX socket.
|
129
|
+
#
|
130
|
+
# @return [true]
|
131
|
+
# The data was successfully sent.
|
132
|
+
#
|
133
|
+
# @example
|
134
|
+
# buffer = "GET /" + ('A' * 4096) + "\n\r"
|
135
|
+
# unix_send(buffer)
|
136
|
+
# # => true
|
137
|
+
#
|
138
|
+
# @see Network::UNIX#unix_send
|
139
|
+
#
|
140
|
+
# @api public
|
141
|
+
#
|
142
|
+
# @since 0.4.0
|
143
|
+
#
|
144
|
+
def unix_send(data)
|
145
|
+
print_info "Connecting to #{self.path} ..."
|
146
|
+
print_debug "Sending data: #{data.inspect}"
|
147
|
+
|
148
|
+
super(data,self.path,&block)
|
149
|
+
|
150
|
+
print_info "Disconnected from #{self.path}"
|
151
|
+
return true
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Opens a UNIX socket, listening on the `path` parameter.
|
156
|
+
#
|
157
|
+
# @yield [server]
|
158
|
+
# The given block will be passed the newly created server.
|
159
|
+
#
|
160
|
+
# @yieldparam [UNIXServer] server
|
161
|
+
# The newly created server.
|
162
|
+
#
|
163
|
+
# @return [UNIXServer]
|
164
|
+
# The newly created server.
|
165
|
+
#
|
166
|
+
# @example
|
167
|
+
# unix_server
|
168
|
+
#
|
169
|
+
# @see Network::UNIX#unix_server
|
170
|
+
#
|
171
|
+
# @api public
|
172
|
+
#
|
173
|
+
def unix_server(&block)
|
174
|
+
print_info "Listening on #{self.path} ..."
|
175
|
+
|
176
|
+
return super(self.path,&block)
|
177
|
+
end
|
178
|
+
|
179
|
+
#
|
180
|
+
# Opens a UNIX socket temporarily, listening on the `path` parameter.
|
181
|
+
#
|
182
|
+
# @yield [server]
|
183
|
+
# The given block will be passed the newly created server.
|
184
|
+
# When the block has finished, the server will be closed.
|
185
|
+
#
|
186
|
+
# @yieldparam [UNIXServer] server
|
187
|
+
# The newly created server.
|
188
|
+
#
|
189
|
+
# @return [nil]
|
190
|
+
#
|
191
|
+
# @example
|
192
|
+
# unix_server_session do |server|
|
193
|
+
# # ...
|
194
|
+
# end
|
195
|
+
#
|
196
|
+
# @see Network::UNIX#unix_server_session
|
197
|
+
#
|
198
|
+
# @api public
|
199
|
+
#
|
200
|
+
def unix_server_session(&block)
|
201
|
+
print_info "Listening on #{self.path} ..."
|
202
|
+
|
203
|
+
super(self.path,&block)
|
204
|
+
|
205
|
+
print_info "Closed #{self.path}"
|
206
|
+
return nil
|
207
|
+
end
|
208
|
+
|
209
|
+
#
|
210
|
+
# Opens a UNIX socket specified by the `path` parameter,
|
211
|
+
# accepts a connection, then closes the socket.
|
212
|
+
#
|
213
|
+
# @yield [client]
|
214
|
+
# If a block is given, it will be passed the accepted connection.
|
215
|
+
#
|
216
|
+
# @yieldparam [UNIXSocket] client
|
217
|
+
# The accepted connection to UNIX socket.
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# unix_accept do |client|
|
221
|
+
# # ...
|
222
|
+
# end
|
223
|
+
#
|
224
|
+
# @see Network::UNIX#unix_accept
|
225
|
+
#
|
226
|
+
# @api public
|
227
|
+
#
|
228
|
+
def unix_accept
|
229
|
+
print_info "Listening on #{self.path} ..."
|
230
|
+
|
231
|
+
super(self.path) do |client|
|
232
|
+
print_info "Client connected to #{self.path}"
|
233
|
+
|
234
|
+
yield client if block_given?
|
235
|
+
|
236
|
+
print_info "Client disconnecting from #{self.path} ..."
|
237
|
+
end
|
238
|
+
|
239
|
+
print_info "Closed #{self.path}"
|
240
|
+
return nil
|
241
|
+
end
|
242
|
+
|
243
|
+
#
|
244
|
+
# Opens a UNIX socket specified by the `path` parameter,
|
245
|
+
# accepts connections in a loop.
|
246
|
+
#
|
247
|
+
# @yield [client]
|
248
|
+
# If a block is given, it will be passed each accepted connection.
|
249
|
+
#
|
250
|
+
# @yieldparam [UNIXSocket] client
|
251
|
+
# An accepted connection to UNIX socket.
|
252
|
+
#
|
253
|
+
# @example
|
254
|
+
# unix_server_loop do |client|
|
255
|
+
# # ...
|
256
|
+
# end
|
257
|
+
#
|
258
|
+
# @see Network::UNIX#unix_server_loop
|
259
|
+
#
|
260
|
+
# @api public
|
261
|
+
#
|
262
|
+
def unix_server_loop
|
263
|
+
print_info "Listening on #{self.path} ..."
|
264
|
+
|
265
|
+
super(self.path) do |client|
|
266
|
+
print_info "Client connected: #{self.path}"
|
267
|
+
|
268
|
+
yield client if block_given?
|
269
|
+
|
270
|
+
print_info "Client disconnecting: #{self.path} ..."
|
271
|
+
end
|
272
|
+
|
273
|
+
print_info "Closed #{self.path}"
|
274
|
+
return nil
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|