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
@@ -32,7 +32,7 @@ describe String do
|
|
32
32
|
let(:html_escaped) { "one & two" }
|
33
33
|
|
34
34
|
it "should HTML escape itself" do
|
35
|
-
subject.html_escape.
|
35
|
+
expect(subject.html_escape).to eq(html_escaped)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,7 +40,7 @@ describe String do
|
|
40
40
|
let(:html_escaped) { "one & two" }
|
41
41
|
|
42
42
|
it "should HTML unescape itself" do
|
43
|
-
html_escaped.html_unescape.
|
43
|
+
expect(html_escaped.html_unescape).to eq(subject)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -50,7 +50,7 @@ describe String do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should HTML format all chars" do
|
53
|
-
subject.format_html.
|
53
|
+
expect(subject.format_html).to eq(formatted_html)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -61,11 +61,11 @@ describe String do
|
|
61
61
|
let(:normal_chars) { "abc" }
|
62
62
|
|
63
63
|
it "should escape special JavaScript characters" do
|
64
|
-
special_chars.js_escape.
|
64
|
+
expect(special_chars.js_escape).to eq(escaped_special_chars)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should ignore normal characters" do
|
68
|
-
normal_chars.js_escape.
|
68
|
+
expect(normal_chars.js_escape).to eq(normal_chars)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -77,19 +77,19 @@ describe String do
|
|
77
77
|
let(:js_mixed) { "%u6F%u6E%u65 %26 two" }
|
78
78
|
|
79
79
|
it "should unescape JavaScript unicode characters" do
|
80
|
-
js_unicode.js_unescape.
|
80
|
+
expect(js_unicode.js_unescape).to eq(subject)
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should unescape JavaScript hex characters" do
|
84
|
-
js_hex.js_unescape.
|
84
|
+
expect(js_hex.js_unescape).to eq(subject)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should unescape backslash-escaped characters" do
|
88
|
-
"\\b\\t\\n\\f\\r\\\"\\\\".js_unescape.
|
88
|
+
expect("\\b\\t\\n\\f\\r\\\"\\\\".js_unescape).to eq("\b\t\n\f\r\"\\")
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should ignore non-escaped characters" do
|
92
|
-
js_mixed.js_unescape.
|
92
|
+
expect(js_mixed.js_unescape).to eq(subject)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -97,7 +97,7 @@ describe String do
|
|
97
97
|
let(:js_formatted) { '\x6F\x6E\x65\x20\x26\x20\x74\x77\x6F' }
|
98
98
|
|
99
99
|
it "should JavaScript escape all characters" do
|
100
|
-
subject.format_js.
|
100
|
+
expect(subject.format_js).to eq(js_formatted)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -20,7 +20,7 @@ describe Integer do
|
|
20
20
|
let(:uri_encoded) { '%20' }
|
21
21
|
|
22
22
|
it "should URI encode itself" do
|
23
|
-
subject.uri_encode.
|
23
|
+
expect(subject.uri_encode).to eq(uri_encoded)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ describe Integer do
|
|
28
28
|
let(:uri_escaped) { '+' }
|
29
29
|
|
30
30
|
it "should URI escape itself" do
|
31
|
-
subject.uri_escape.
|
31
|
+
expect(subject.uri_escape).to eq(uri_escaped)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,7 +36,7 @@ describe Integer do
|
|
36
36
|
let(:http_formatted) { '%20' }
|
37
37
|
|
38
38
|
it "should format the byte" do
|
39
|
-
subject.format_http.
|
39
|
+
expect(subject.format_http).to eq(http_formatted)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -30,7 +30,7 @@ describe String do
|
|
30
30
|
let(:uri_encoded) { "mod%20%25%203" }
|
31
31
|
|
32
32
|
it "should URI encode itself" do
|
33
|
-
subject.uri_encode.
|
33
|
+
expect(subject.uri_encode).to eq(uri_encoded)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -40,7 +40,7 @@ describe String do
|
|
40
40
|
let(:uri_decoded) { "mod % 3" }
|
41
41
|
|
42
42
|
it "should URI decode itself" do
|
43
|
-
subject.uri_decode.
|
43
|
+
expect(subject.uri_decode).to eq(uri_decoded)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -50,7 +50,7 @@ describe String do
|
|
50
50
|
let(:uri_escaped) { "x+%2B+y" }
|
51
51
|
|
52
52
|
it "should URI escape itself" do
|
53
|
-
subject.uri_escape.
|
53
|
+
expect(subject.uri_escape).to eq(uri_escaped)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -60,7 +60,7 @@ describe String do
|
|
60
60
|
let(:uri_unescaped) { "x + y" }
|
61
61
|
|
62
62
|
it "should URI unescape itself" do
|
63
|
-
subject.uri_unescape.
|
63
|
+
expect(subject.uri_unescape).to eq(uri_unescaped)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -70,7 +70,7 @@ describe String do
|
|
70
70
|
let(:http_formatted) { "%6D%6F%64%20%25%20%33" }
|
71
71
|
|
72
72
|
it "should format each byte of the String" do
|
73
|
-
subject.format_http.
|
73
|
+
expect(subject.format_http).to eq(http_formatted)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -2,73 +2,75 @@ require 'spec_helper'
|
|
2
2
|
require 'ronin/formatting/extensions/sql/string'
|
3
3
|
|
4
4
|
describe String do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@string_with_quotes = %{"O'Brian"}
|
9
|
-
end
|
5
|
+
let(:string) {'/etc/passwd' }
|
6
|
+
let(:sql_encoded) { '0x2f6574632f706173737764' }
|
7
|
+
let(:string_with_quotes) { %{"O'Brian"} }
|
10
8
|
|
11
9
|
it "should provide the #sql_escape method" do
|
12
|
-
|
10
|
+
expect(string).to respond_to(:sql_escape)
|
13
11
|
end
|
14
12
|
|
15
13
|
it "should provide the #sql_encode method" do
|
16
|
-
|
14
|
+
expect(string).to respond_to(:sql_encode)
|
17
15
|
end
|
18
16
|
|
19
17
|
it "should provide the #sql_decode method" do
|
20
|
-
|
18
|
+
expect(string).to respond_to(:sql_decode)
|
21
19
|
end
|
22
20
|
|
23
21
|
describe "#sql_escape" do
|
24
22
|
it "should be able to single-quote escape" do
|
25
|
-
|
23
|
+
expect(string_with_quotes.sql_escape(:single)).to eq(%{'"O''Brian"'})
|
26
24
|
end
|
27
25
|
|
28
26
|
it "should be able to double-quote escape" do
|
29
|
-
|
27
|
+
expect(string_with_quotes.sql_escape(:double)).to eq(%{"""O'Brian"""})
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be able to tick-mark escape" do
|
31
|
+
expect(string_with_quotes.sql_escape(:tick)).to eq(%{`"O'Brian"`})
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
describe "#sql_encode" do
|
34
36
|
it "should be able to be SQL-hex encoded" do
|
35
|
-
|
37
|
+
expect(string.sql_encode).to eq(sql_encoded)
|
36
38
|
end
|
37
39
|
|
38
40
|
it "should return an empty String if empty" do
|
39
|
-
''.sql_encode.
|
41
|
+
expect(''.sql_encode).to eq('')
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
describe "#sql_decode" do
|
44
46
|
it "should be able to be SQL-hex decoded" do
|
45
|
-
encoded =
|
47
|
+
encoded = string.sql_encode
|
46
48
|
|
47
|
-
encoded.
|
48
|
-
encoded.sql_decode.
|
49
|
+
expect(encoded).to eq(sql_encoded)
|
50
|
+
expect(encoded.sql_decode).to eq(string)
|
49
51
|
end
|
50
52
|
|
51
53
|
it "should be able to decode SQL comma-escaping" do
|
52
|
-
"'Conan O''Brian'".sql_decode.
|
54
|
+
expect("'Conan O''Brian'".sql_decode).to eq("Conan O'Brian")
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
58
|
describe "#sql_inject" do
|
57
59
|
context "when there is a leading quote character" do
|
58
60
|
it "should remove the first and last quote character" do
|
59
|
-
"'1' OR '1'='1'".sql_inject.
|
61
|
+
expect("'1' OR '1'='1'".sql_inject).to eq("1' OR '1'='1")
|
60
62
|
end
|
61
63
|
|
62
64
|
context "when there is no matching leading/trailing quote characters" do
|
63
65
|
it "should comment-terminate the String" do
|
64
|
-
"'1' OR 1=1".sql_inject.
|
66
|
+
expect("'1' OR 1=1".sql_inject).to eq("1' OR 1=1--")
|
65
67
|
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
context "when there is no leading quote character" do
|
70
72
|
it "should not modify the String" do
|
71
|
-
"1 OR 1=1".sql_inject.
|
73
|
+
expect("1 OR 1=1".sql_inject).to eq("1 OR 1=1")
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
@@ -31,43 +31,43 @@ describe Array do
|
|
31
31
|
|
32
32
|
describe "#bytes" do
|
33
33
|
it "should convert an Array of bytes to an Array of bytes" do
|
34
|
-
byte_array.bytes.
|
34
|
+
expect(byte_array.bytes).to eq(byte_array)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should convert an Array of chars to an Array of bytes" do
|
38
|
-
char_array.bytes.
|
38
|
+
expect(char_array.bytes).to eq(byte_array)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should safely handle mixed byte/char/string Arrays" do
|
42
|
-
mixed_array.bytes.
|
42
|
+
expect(mixed_array.bytes).to eq(byte_array)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#chars" do
|
47
47
|
it "should convert an Array of bytes to an Array of chars" do
|
48
|
-
byte_array.chars.
|
48
|
+
expect(byte_array.chars).to eq(char_array)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should safely convert an Array of chars to an Array of chars" do
|
52
|
-
char_array.chars.
|
52
|
+
expect(char_array.chars).to eq(char_array)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should safely handle mixed byte/char/string Arrays" do
|
56
|
-
mixed_array.chars.
|
56
|
+
expect(mixed_array.chars).to eq(char_array)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "#char_string" do
|
61
61
|
it "should convert an Array of bytes to a String" do
|
62
|
-
byte_array.char_string.
|
62
|
+
expect(byte_array.char_string).to eq(string)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should convert an Array of chars to a String" do
|
66
|
-
char_array.char_string.
|
66
|
+
expect(char_array.char_string).to eq(string)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should safely handle mixed byte/char/string Arrays" do
|
70
|
-
mixed_array.char_string.
|
70
|
+
expect(mixed_array.char_string).to eq(string)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -75,15 +75,15 @@ describe Array do
|
|
75
75
|
let(:hex_chars) { ['\x41', '\x41', '\x20'] }
|
76
76
|
|
77
77
|
it "should convert an Array of bytes into hexadecimal chars" do
|
78
|
-
byte_array.hex_chars.
|
78
|
+
expect(byte_array.hex_chars).to eq(hex_chars)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should convert an Array of chars into hexadecimal chars" do
|
82
|
-
char_array.hex_chars.
|
82
|
+
expect(char_array.hex_chars).to eq(hex_chars)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should safely handle mixed byte/char/string Arrays" do
|
86
|
-
mixed_array.hex_chars.
|
86
|
+
expect(mixed_array.hex_chars).to eq(hex_chars)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -91,15 +91,15 @@ describe Array do
|
|
91
91
|
let(:hex_integers) { ['0x41', '0x41', '0x20'] }
|
92
92
|
|
93
93
|
it "should convert an Array of bytes into hexadecimal integers" do
|
94
|
-
byte_array.hex_integers.
|
94
|
+
expect(byte_array.hex_integers).to eq(hex_integers)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should convert an Array of chars into hexadecimal integers" do
|
98
|
-
char_array.hex_integers.
|
98
|
+
expect(char_array.hex_integers).to eq(hex_integers)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should safely handle mixed byte/char/string Arrays" do
|
102
|
-
mixed_array.hex_integers.
|
102
|
+
expect(mixed_array.hex_integers).to eq(hex_integers)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -24,67 +24,75 @@ describe String do
|
|
24
24
|
should respond_to(:insert_after)
|
25
25
|
end
|
26
26
|
|
27
|
+
it "should provide String#escape" do
|
28
|
+
should respond_to(:escape)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should provide String#unescape" do
|
32
|
+
should respond_to(:unescape)
|
33
|
+
end
|
34
|
+
|
27
35
|
describe "#format_bytes" do
|
28
36
|
it "should format each byte in the String" do
|
29
|
-
subject.format_bytes { |b|
|
37
|
+
expect(subject.format_bytes { |b|
|
30
38
|
sprintf("%%%x",b)
|
31
|
-
}.
|
39
|
+
}).to eq("%68%65%6c%6c%6f")
|
32
40
|
end
|
33
41
|
|
34
42
|
it "should format specific bytes in a String" do
|
35
|
-
subject.format_bytes(:include => [104, 108]) { |b|
|
43
|
+
expect(subject.format_bytes(:include => [104, 108]) { |b|
|
36
44
|
b - 32
|
37
|
-
}.
|
45
|
+
}).to eq('HeLLo')
|
38
46
|
end
|
39
47
|
|
40
48
|
it "should not format specific bytes in a String" do
|
41
|
-
subject.format_bytes(:exclude => [101, 111]) { |b|
|
49
|
+
expect(subject.format_bytes(:exclude => [101, 111]) { |b|
|
42
50
|
b - 32
|
43
|
-
}.
|
51
|
+
}).to eq('HeLLo')
|
44
52
|
end
|
45
53
|
|
46
54
|
it "should format ranges of bytes in a String" do
|
47
|
-
subject.format_bytes(:include => (104..108)) { |b|
|
55
|
+
expect(subject.format_bytes(:include => (104..108)) { |b|
|
48
56
|
b - 32
|
49
|
-
}.
|
57
|
+
}).to eq('HeLLo')
|
50
58
|
end
|
51
59
|
|
52
60
|
it "should not format ranges of bytes in a String" do
|
53
|
-
subject.format_bytes(:exclude => (104..108)) { |b|
|
61
|
+
expect(subject.format_bytes(:exclude => (104..108)) { |b|
|
54
62
|
b - 32
|
55
|
-
}.
|
63
|
+
}).to eq('hEllO')
|
56
64
|
end
|
57
65
|
end
|
58
66
|
|
59
67
|
describe "#format_chars" do
|
60
68
|
it "should format each character in the String" do
|
61
|
-
subject.format_chars { |c|
|
69
|
+
expect(subject.format_chars { |c|
|
62
70
|
"#{c}."
|
63
|
-
}.
|
71
|
+
}).to eq("h.e.l.l.o.")
|
64
72
|
end
|
65
73
|
|
66
74
|
it "should format specific chars in a String" do
|
67
|
-
subject.format_chars(:include => ['h', 'l']) { |c|
|
75
|
+
expect(subject.format_chars(:include => ['h', 'l']) { |c|
|
68
76
|
c.upcase
|
69
|
-
}.
|
77
|
+
}).to eq('HeLLo')
|
70
78
|
end
|
71
79
|
|
72
80
|
it "should not format specific chars in a String" do
|
73
|
-
subject.format_chars(:exclude => ['h', 'l']) { |c|
|
81
|
+
expect(subject.format_chars(:exclude => ['h', 'l']) { |c|
|
74
82
|
c.upcase
|
75
|
-
}.
|
83
|
+
}).to eq('hEllO')
|
76
84
|
end
|
77
85
|
|
78
86
|
it "should format ranges of chars in a String" do
|
79
|
-
subject.format_chars(:include => /[h-l]/) { |c|
|
87
|
+
expect(subject.format_chars(:include => /[h-l]/) { |c|
|
80
88
|
c.upcase
|
81
|
-
}.
|
89
|
+
}).to eq('HeLLo')
|
82
90
|
end
|
83
91
|
|
84
92
|
it "should not format ranges of chars in a String" do
|
85
|
-
subject.format_chars(:exclude => /[h-l]/) { |c|
|
93
|
+
expect(subject.format_chars(:exclude => /[h-l]/) { |c|
|
86
94
|
c.upcase
|
87
|
-
}.
|
95
|
+
}).to eq('hEllO')
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
@@ -92,41 +100,63 @@ describe String do
|
|
92
100
|
it "should capitalize each character when :probability is 1.0" do
|
93
101
|
new_string = subject.random_case(:probability => 1.0)
|
94
102
|
|
95
|
-
subject.upcase.
|
103
|
+
expect(subject.upcase).to eq(new_string)
|
96
104
|
end
|
97
105
|
|
98
106
|
it "should not capitalize any characters when :probability is 0.0" do
|
99
107
|
new_string = subject.random_case(:probability => 0.0)
|
100
108
|
|
101
|
-
subject.
|
109
|
+
expect(subject).to eq(new_string)
|
102
110
|
end
|
103
111
|
end
|
104
112
|
|
105
113
|
describe "#insert_before" do
|
106
114
|
it "should inject data before a matched String" do
|
107
|
-
subject.insert_before('ll','x').
|
115
|
+
expect(subject.insert_before('ll','x')).to eq("hexllo")
|
108
116
|
end
|
109
117
|
|
110
118
|
it "should inject data before a matched Regexp" do
|
111
|
-
subject.insert_before(/l+/,'x').
|
119
|
+
expect(subject.insert_before(/l+/,'x')).to eq("hexllo")
|
112
120
|
end
|
113
121
|
|
114
122
|
it "should not inject data if no matches are found" do
|
115
|
-
subject.insert_before(/x/,'x').
|
123
|
+
expect(subject.insert_before(/x/,'x')).to eq(subject)
|
116
124
|
end
|
117
125
|
end
|
118
126
|
|
119
127
|
describe "#insert_after" do
|
120
128
|
it "should inject data after a matched String" do
|
121
|
-
subject.insert_after('ll','x').
|
129
|
+
expect(subject.insert_after('ll','x')).to eq("hellxo")
|
122
130
|
end
|
123
131
|
|
124
132
|
it "should inject data after a matched Regexp" do
|
125
|
-
subject.insert_after(/l+/,'x').
|
133
|
+
expect(subject.insert_after(/l+/,'x')).to eq("hellxo")
|
126
134
|
end
|
127
135
|
|
128
136
|
it "should not inject data if no matches are found" do
|
129
|
-
subject.insert_after(/x/,'x').
|
137
|
+
expect(subject.insert_after(/x/,'x')).to eq(subject)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "#unescape" do
|
142
|
+
it "should not unescape a normal String" do
|
143
|
+
expect("hello".unescape).to eq("hello")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should unescape a hex String" do
|
147
|
+
expect("\\x68\\x65\\x6c\\x6c\\x6f\\x4e".unescape).to eq("hello\x4e")
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should unescape an octal String" do
|
151
|
+
expect("hello\012".unescape).to eq("hello\n")
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should unescape control characters" do
|
155
|
+
expect("hello\\n".unescape).to eq("hello\n")
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should unescape normal characters" do
|
159
|
+
expect("hell\\o".unescape).to eq("hello")
|
130
160
|
end
|
131
161
|
end
|
132
162
|
end
|