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/formatting/extensions/text/string'
|
@@ -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
|
class Array
|
@@ -40,10 +40,12 @@ class Array
|
|
40
40
|
bytes = []
|
41
41
|
|
42
42
|
each do |element|
|
43
|
-
|
44
|
-
|
43
|
+
case element
|
44
|
+
when Integer then bytes << element
|
45
45
|
else
|
46
|
-
element.to_s.each_byte
|
46
|
+
element.to_s.each_byte do |b|
|
47
|
+
bytes << b
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -65,8 +67,8 @@ class Array
|
|
65
67
|
#
|
66
68
|
def chars
|
67
69
|
array_bytes = bytes
|
68
|
-
|
69
70
|
array_bytes.map! { |b| b.chr }
|
71
|
+
|
70
72
|
return array_bytes
|
71
73
|
end
|
72
74
|
|
@@ -103,8 +105,8 @@ class Array
|
|
103
105
|
#
|
104
106
|
def hex_chars
|
105
107
|
array_bytes = bytes
|
106
|
-
|
107
108
|
array_bytes.map! { |b| '\x%x' % b }
|
109
|
+
|
108
110
|
return array_bytes
|
109
111
|
end
|
110
112
|
|
@@ -127,8 +129,8 @@ class Array
|
|
127
129
|
#
|
128
130
|
def hex_integers
|
129
131
|
array_bytes = bytes
|
130
|
-
|
131
132
|
array_bytes.map! { |b| '0x%x' % b }
|
133
|
+
|
132
134
|
return array_bytes
|
133
135
|
end
|
134
136
|
|
@@ -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 'set'
|
@@ -99,10 +99,8 @@ class String
|
|
99
99
|
formatted = ''
|
100
100
|
|
101
101
|
matches = lambda { |filter,c|
|
102
|
-
if
|
103
|
-
|
104
|
-
elsif filter.kind_of?(Regexp)
|
105
|
-
c =~ filter
|
102
|
+
if filter.respond_to?(:include?) then filter.include?(c)
|
103
|
+
elsif filter.kind_of?(Regexp) then c =~ filter
|
106
104
|
end
|
107
105
|
}
|
108
106
|
|
@@ -143,10 +141,8 @@ class String
|
|
143
141
|
prob = (options[:probability] || 0.5)
|
144
142
|
|
145
143
|
format_chars(options) do |c|
|
146
|
-
if rand <= prob
|
147
|
-
|
148
|
-
else
|
149
|
-
c
|
144
|
+
if rand <= prob then c.swapcase
|
145
|
+
else c
|
150
146
|
end
|
151
147
|
end
|
152
148
|
end
|
@@ -237,4 +233,65 @@ class String
|
|
237
233
|
return padded
|
238
234
|
end
|
239
235
|
|
236
|
+
alias escape dump
|
237
|
+
|
238
|
+
# Common escaped characters.
|
239
|
+
UNESCAPE_CHARS = Hash.new do |hash,char|
|
240
|
+
if char[0,1] == '\\'
|
241
|
+
char[1,1]
|
242
|
+
else
|
243
|
+
char
|
244
|
+
end
|
245
|
+
end
|
246
|
+
UNESCAPE_CHARS['\0'] = "\0"
|
247
|
+
UNESCAPE_CHARS['\a'] = "\a"
|
248
|
+
UNESCAPE_CHARS['\b'] = "\b"
|
249
|
+
UNESCAPE_CHARS['\t'] = "\t"
|
250
|
+
UNESCAPE_CHARS['\n'] = "\n"
|
251
|
+
UNESCAPE_CHARS['\v'] = "\v"
|
252
|
+
UNESCAPE_CHARS['\f'] = "\f"
|
253
|
+
UNESCAPE_CHARS['\r'] = "\r"
|
254
|
+
|
255
|
+
#
|
256
|
+
# Unescapes the escaped String.
|
257
|
+
#
|
258
|
+
# @return [String]
|
259
|
+
# The unescaped version of the hex escaped String.
|
260
|
+
#
|
261
|
+
# @example
|
262
|
+
# "\\x68\\x65\\x6c\\x6c\\x6f".unescape
|
263
|
+
# # => "hello"
|
264
|
+
#
|
265
|
+
# @api public
|
266
|
+
#
|
267
|
+
# @since 0.5.0
|
268
|
+
#
|
269
|
+
def unescape
|
270
|
+
buffer = ''
|
271
|
+
hex_index = 0
|
272
|
+
hex_length = length
|
273
|
+
|
274
|
+
while (hex_index < hex_length)
|
275
|
+
hex_substring = self[hex_index..-1]
|
276
|
+
|
277
|
+
if hex_substring =~ /^\\[0-7]{3}/
|
278
|
+
buffer << hex_substring[0,4].to_i(8)
|
279
|
+
hex_index += 3
|
280
|
+
elsif hex_substring =~ /^\\x[0-9a-fA-F]{1,2}/
|
281
|
+
hex_substring[2..-1].scan(/^[0-9a-fA-F]{1,2}/) do |hex_byte|
|
282
|
+
buffer << hex_byte.to_i(16)
|
283
|
+
hex_index += (2 + hex_byte.length)
|
284
|
+
end
|
285
|
+
elsif hex_substring =~ /^\\./
|
286
|
+
buffer << UNESCAPE_CHARS[hex_substring[0,2]]
|
287
|
+
hex_index += 2
|
288
|
+
else
|
289
|
+
buffer << hex_substring[0,1]
|
290
|
+
hex_index += 1
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
return buffer
|
295
|
+
end
|
296
|
+
|
240
297
|
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/formatting/extensions/html'
|
@@ -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/formatting/extensions/http'
|
data/lib/ronin/formatting/sql.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/formatting/extensions/sql'
|
@@ -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/formatting/extensions/text'
|
data/lib/ronin/fuzzing.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/fuzzing/extensions'
|
@@ -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/fuzzing/extensions/string'
|
@@ -1,37 +1,36 @@
|
|
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
|
-
require 'ronin/
|
20
|
+
require 'ronin/fuzzing/template'
|
21
|
+
require 'ronin/fuzzing/repeater'
|
22
|
+
require 'ronin/fuzzing/fuzzer'
|
23
|
+
require 'ronin/fuzzing/mutator'
|
21
24
|
require 'ronin/fuzzing/fuzzing'
|
22
|
-
|
23
|
-
require 'combinatorics/generator'
|
24
|
-
require 'combinatorics/list_comprehension'
|
25
|
-
require 'combinatorics/power_set'
|
26
|
-
require 'chars'
|
25
|
+
require 'ronin/extensions/regexp'
|
27
26
|
|
28
27
|
class String
|
29
28
|
|
30
29
|
#
|
31
30
|
# Generate permutations of Strings from a format template.
|
32
31
|
#
|
33
|
-
# @param [Array(<String,Symbol,Enumerable>, <Integer,Array,Range>)]
|
34
|
-
# The
|
32
|
+
# @param [Array(<String,Symbol,Enumerable>, <Integer,Array,Range>)] fields
|
33
|
+
# The fields which defines the string or character sets which will
|
35
34
|
# make up parts of the String.
|
36
35
|
#
|
37
36
|
# @yield [string]
|
@@ -50,34 +49,34 @@ class String
|
|
50
49
|
# A given string set was not a String, Symbol or Enumerable.
|
51
50
|
# A given string set length was not an Integer or Enumerable.
|
52
51
|
#
|
53
|
-
# @example Generate Strings with ranges of repeating sub-strings
|
52
|
+
# @example Generate Strings with ranges of repeating sub-strings:
|
54
53
|
#
|
55
|
-
# @example Generate Strings with three alpha chars and one numeric chars
|
54
|
+
# @example Generate Strings with three alpha chars and one numeric chars:
|
56
55
|
# String.generate([:alpha, 3], :numeric) do |password|
|
57
56
|
# puts password
|
58
57
|
# end
|
59
58
|
#
|
60
|
-
# @example Generate Strings with two to four alpha chars
|
59
|
+
# @example Generate Strings with two to four alpha chars:
|
61
60
|
# String.generate([:alpha, 2..4]) do |password|
|
62
61
|
# puts password
|
63
62
|
# end
|
64
63
|
#
|
65
|
-
# @example Generate Strings using alpha and punctuation chars
|
64
|
+
# @example Generate Strings using alpha and punctuation chars:
|
66
65
|
# String.generate([Chars.alpha + Chars.punctuation, 4]) do |password|
|
67
66
|
# puts password
|
68
67
|
# end
|
69
68
|
#
|
70
|
-
# @example Generate Strings from a custom char set
|
69
|
+
# @example Generate Strings from a custom char set:
|
71
70
|
# String.generate([['a', 'b', 'c'], 3], [['1', '2', '3'], 3]) do |password|
|
72
71
|
# puts password
|
73
72
|
# end
|
74
73
|
#
|
75
|
-
# @example Generate Strings containing known Strings
|
74
|
+
# @example Generate Strings containing known Strings:
|
76
75
|
# String.generate("rock", [:numeric, 4]) do |password|
|
77
76
|
# puts password
|
78
77
|
# end
|
79
78
|
#
|
80
|
-
# @example Generate Strings with ranges of repeating sub-strings
|
79
|
+
# @example Generate Strings with ranges of repeating sub-strings:
|
81
80
|
# String.generate(['/AA', (1..100).step(5)]) do |path|
|
82
81
|
# puts path
|
83
82
|
# end
|
@@ -86,69 +85,14 @@ class String
|
|
86
85
|
#
|
87
86
|
# @api public
|
88
87
|
#
|
89
|
-
def self.generate(*
|
90
|
-
|
91
|
-
|
92
|
-
sets = []
|
93
|
-
|
94
|
-
template.each do |pattern|
|
95
|
-
set, length = pattern
|
96
|
-
set = case set
|
97
|
-
when String
|
98
|
-
[set].each
|
99
|
-
when Symbol
|
100
|
-
name = set.to_s.upcase
|
101
|
-
|
102
|
-
unless Chars.const_defined?(name)
|
103
|
-
raise(ArgumentError,"unknown charset #{set.inspect}")
|
104
|
-
end
|
105
|
-
|
106
|
-
Chars.const_get(name).each_char
|
107
|
-
when Enumerable
|
108
|
-
set
|
109
|
-
else
|
110
|
-
raise(TypeError,"set must be a String, Symbol or Enumerable")
|
111
|
-
end
|
112
|
-
|
113
|
-
case length
|
114
|
-
when Integer
|
115
|
-
length.times { sets << set.dup }
|
116
|
-
when Array, Range
|
117
|
-
sets << Combinatorics::Generator.new do |g|
|
118
|
-
length.each do |sublength|
|
119
|
-
superset = Array.new(sublength) { set.dup }
|
120
|
-
|
121
|
-
superset.comprehension { |strings| g.yield strings.join }
|
122
|
-
end
|
123
|
-
end
|
124
|
-
when nil
|
125
|
-
sets << set
|
126
|
-
else
|
127
|
-
raise(TypeError,"length must be an Integer, Range or Array")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
sets.comprehension do |strings|
|
132
|
-
new_string = ''
|
133
|
-
|
134
|
-
strings.each do |string|
|
135
|
-
new_string << case string
|
136
|
-
when Integer
|
137
|
-
string.chr
|
138
|
-
else
|
139
|
-
string.to_s
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
yield new_string
|
144
|
-
end
|
145
|
-
return nil
|
88
|
+
def self.generate(*fields,&block)
|
89
|
+
Ronin::Fuzzing::Template.new(fields).each(&block)
|
146
90
|
end
|
147
91
|
|
148
92
|
#
|
149
93
|
# Repeats the String.
|
150
94
|
#
|
151
|
-
# @param [Enumerable
|
95
|
+
# @param [Enumerable<Integer>, Integer] lengths
|
152
96
|
# The number of times to repeat the String.
|
153
97
|
#
|
154
98
|
# @yield [repeated]
|
@@ -181,32 +125,23 @@ class String
|
|
181
125
|
#
|
182
126
|
# @since 0.4.0
|
183
127
|
#
|
184
|
-
def repeating(
|
185
|
-
|
186
|
-
|
187
|
-
|
128
|
+
def repeating(lengths,&block)
|
129
|
+
case lengths
|
130
|
+
when Integer
|
131
|
+
# if lengths is an Integer, simply multiply the String and return
|
132
|
+
repeated = (self * lengths)
|
188
133
|
|
189
134
|
yield repeated if block_given?
|
190
135
|
return repeated
|
136
|
+
else
|
137
|
+
return Ronin::Fuzzing::Repeater.new(lengths).each(self,&block)
|
191
138
|
end
|
192
|
-
|
193
|
-
return enum_for(:repeating,n) unless block_given?
|
194
|
-
|
195
|
-
unless n.kind_of?(Enumerable)
|
196
|
-
raise(TypeError,"argument must be Enumerable or an Integer")
|
197
|
-
end
|
198
|
-
|
199
|
-
n.each do |length|
|
200
|
-
yield(self * length)
|
201
|
-
end
|
202
|
-
|
203
|
-
return self
|
204
139
|
end
|
205
140
|
|
206
141
|
#
|
207
142
|
# Incrementally fuzzes the String.
|
208
143
|
#
|
209
|
-
# @param [Hash{Regexp,String =>
|
144
|
+
# @param [Hash{Regexp,String,Symbol => Enumerable,Symbol}] substitutions
|
210
145
|
# Patterns and their substitutions.
|
211
146
|
#
|
212
147
|
# @yield [fuzz]
|
@@ -228,64 +163,21 @@ class String
|
|
228
163
|
# p str
|
229
164
|
# end
|
230
165
|
#
|
166
|
+
# @example Replace a {Regexp::UNIX_PATH} with {Ronin::Fuzzing#format_strings}:
|
167
|
+
# "GET /downloads/".fuzz(:unix_path => :format_string)
|
168
|
+
#
|
231
169
|
# @since 0.3.0
|
232
170
|
#
|
233
171
|
# @api public
|
234
172
|
#
|
235
|
-
def fuzz(substitutions={})
|
236
|
-
|
237
|
-
|
238
|
-
substitutions.each do |pattern,substitution|
|
239
|
-
pattern = case pattern
|
240
|
-
when Regexp
|
241
|
-
pattern
|
242
|
-
when String
|
243
|
-
Regexp.new(Regexp.escape(pattern))
|
244
|
-
when Symbol
|
245
|
-
Regexp.const_get(pattern.to_s.upcase)
|
246
|
-
else
|
247
|
-
raise(TypeError,"cannot convert #{pattern.inspect} to a Regexp")
|
248
|
-
end
|
249
|
-
|
250
|
-
substitution = case substitution
|
251
|
-
when Enumerable
|
252
|
-
substitution
|
253
|
-
when Symbol
|
254
|
-
Ronin::Fuzzing[substitution]
|
255
|
-
else
|
256
|
-
raise(TypeError,"substitutions must be Enumerable or a Symbol")
|
257
|
-
end
|
258
|
-
|
259
|
-
scanner = StringScanner.new(self)
|
260
|
-
indices = []
|
261
|
-
|
262
|
-
while scanner.scan_until(pattern)
|
263
|
-
indices << [scanner.pos - scanner.matched_size, scanner.matched_size]
|
264
|
-
end
|
265
|
-
|
266
|
-
indices.each do |index,length|
|
267
|
-
substitution.each do |substitute|
|
268
|
-
substitute = case substitute
|
269
|
-
when Proc
|
270
|
-
substitute.call(self[index,length])
|
271
|
-
when Integer
|
272
|
-
substitute.chr
|
273
|
-
else
|
274
|
-
substitute.to_s
|
275
|
-
end
|
276
|
-
|
277
|
-
fuzzed = dup
|
278
|
-
fuzzed[index,length] = substitute
|
279
|
-
yield fuzzed
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
173
|
+
def fuzz(substitutions={},&block)
|
174
|
+
Ronin::Fuzzing::Fuzzer.new(substitutions).each(self,&block)
|
283
175
|
end
|
284
176
|
|
285
177
|
#
|
286
178
|
# Permutes over every possible mutation of the String.
|
287
179
|
#
|
288
|
-
# @param [Hash{Regexp,String,Symbol => Symbol
|
180
|
+
# @param [Hash{Regexp,String,Symbol => Enumerable,Symbol}] mutations
|
289
181
|
# The patterns and substitutions to mutate the String with.
|
290
182
|
#
|
291
183
|
# @yield [mutant]
|
@@ -297,6 +189,10 @@ class String
|
|
297
189
|
# @return [Enumerator]
|
298
190
|
# If no block is given, an Enumerator will be returned.
|
299
191
|
#
|
192
|
+
# @raise [TypeError]
|
193
|
+
# A mutation pattern was not a Regexp, String or Symbol.
|
194
|
+
# A mutation substitution was not a Symbol or Enumerable.
|
195
|
+
#
|
300
196
|
# @example
|
301
197
|
# "hello old dog".mutate('e' => ['3'], 'l' => ['1'], 'o' => ['0']) do |str|
|
302
198
|
# puts str
|
@@ -306,75 +202,8 @@ class String
|
|
306
202
|
#
|
307
203
|
# @api public
|
308
204
|
#
|
309
|
-
def mutate(mutations={})
|
310
|
-
|
311
|
-
|
312
|
-
matches = Set[]
|
313
|
-
|
314
|
-
mutations.each do |pattern,mutation|
|
315
|
-
pattern = case pattern
|
316
|
-
when Regexp
|
317
|
-
pattern
|
318
|
-
when String
|
319
|
-
Regexp.new(Regexp.escape(pattern))
|
320
|
-
when Symbol
|
321
|
-
Regexp.const_get(pattern.to_s.upcase)
|
322
|
-
else
|
323
|
-
raise(TypeError,"cannot convert #{pattern.inspect} to a Regexp")
|
324
|
-
end
|
325
|
-
|
326
|
-
scanner = StringScanner.new(self)
|
327
|
-
|
328
|
-
while scanner.scan_until(pattern)
|
329
|
-
length = scanner.matched_size
|
330
|
-
index = scanner.pos - length
|
331
|
-
original = scanner.matched
|
332
|
-
|
333
|
-
mutator = Combinatorics::Generator.new do |g|
|
334
|
-
mutation.each do |mutate|
|
335
|
-
g.yield case mutate
|
336
|
-
when Proc
|
337
|
-
mutate.call(original)
|
338
|
-
when Integer
|
339
|
-
mutate.chr
|
340
|
-
else
|
341
|
-
mutate.to_s
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
matches << [index, length, mutator]
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
matches.powerset do |submatches|
|
351
|
-
# ignore the empty Set
|
352
|
-
next if submatches.empty?
|
353
|
-
|
354
|
-
# sort the submatches by index
|
355
|
-
submatches = submatches.sort_by { |index,length,mutator| index }
|
356
|
-
sets = []
|
357
|
-
prev_index = 0
|
358
|
-
|
359
|
-
submatches.each do |index,length,mutator|
|
360
|
-
# add the previous substring to the set of Strings
|
361
|
-
if index > prev_index
|
362
|
-
sets << [self[prev_index,index - prev_index]]
|
363
|
-
end
|
364
|
-
|
365
|
-
# add the mutator to the set of Strings
|
366
|
-
sets << mutator
|
367
|
-
|
368
|
-
prev_index = index + length
|
369
|
-
end
|
370
|
-
|
371
|
-
# add the remaining substring to the set of Strings
|
372
|
-
if prev_index < self.length
|
373
|
-
sets << [self[prev_index..-1]]
|
374
|
-
end
|
375
|
-
|
376
|
-
sets.comprehension { |strings| yield strings.join }
|
377
|
-
end
|
205
|
+
def mutate(mutations={},&block)
|
206
|
+
Ronin::Fuzzing::Mutator.new(mutations).each(self,&block)
|
378
207
|
end
|
379
208
|
|
380
209
|
end
|