ronin-support 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +28 -0
- data/Gemfile +6 -7
- data/README.md +53 -32
- data/Rakefile +1 -2
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +5 -5
- data/lib/ronin/binary/hexdump.rb +5 -5
- data/lib/ronin/binary/hexdump/parser.rb +5 -5
- data/lib/ronin/binary/struct.rb +5 -5
- data/lib/ronin/binary/template.rb +7 -7
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +37 -31
- data/lib/ronin/extensions/ip_addr.rb +6 -7
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +5 -5
- data/lib/ronin/extensions/resolv.rb +5 -5
- data/lib/ronin/extensions/string.rb +5 -5
- 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 +5 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
- 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 +5 -5
- data/lib/ronin/formatting/extensions/html/string.rb +7 -7
- 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 +15 -13
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +5 -5
- data/lib/ronin/formatting/extensions/text/string.rb +5 -5
- 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 +5 -5
- data/lib/ronin/fuzzing/fuzzer.rb +5 -5
- data/lib/ronin/fuzzing/fuzzing.rb +7 -7
- data/lib/ronin/fuzzing/mutator.rb +5 -5
- data/lib/ronin/fuzzing/repeater.rb +5 -5
- data/lib/ronin/fuzzing/template.rb +5 -5
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +5 -5
- data/lib/ronin/network/dns.rb +5 -5
- 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 +5 -5
- 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 +52 -57
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +5 -5
- data/lib/ronin/network/mixins.rb +5 -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 +5 -5
- data/lib/ronin/network/mixins/http.rb +7 -7
- 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 +5 -5
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +5 -5
- data/lib/ronin/network/mixins/unix.rb +5 -5
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +5 -5
- data/lib/ronin/network/proxy.rb +5 -5
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +5 -5
- data/lib/ronin/network/ssl.rb +7 -7
- data/lib/ronin/network/tcp.rb +5 -5
- data/lib/ronin/network/tcp/proxy.rb +5 -5
- data/lib/ronin/network/tcp/tcp.rb +32 -23
- data/lib/ronin/network/telnet.rb +7 -5
- data/lib/ronin/network/udp.rb +5 -5
- data/lib/ronin/network/udp/proxy.rb +5 -5
- data/lib/ronin/network/udp/udp.rb +28 -26
- data/lib/ronin/network/unix.rb +7 -7
- data/lib/ronin/path.rb +32 -36
- data/lib/ronin/spec/ui/output.rb +5 -5
- data/lib/ronin/support.rb +5 -5
- data/lib/ronin/support/inflector.rb +5 -5
- data/lib/ronin/support/support.rb +5 -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 +5 -5
- 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 +5 -5
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +5 -5
- data/lib/ronin/wordlist.rb +7 -7
- data/ronin-support.gemspec +1 -0
- data/spec/binary/hexdump/parser_spec.rb +22 -22
- data/spec/binary/struct_spec.rb +56 -56
- data/spec/binary/template_spec.rb +106 -104
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +30 -30
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +69 -69
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +30 -29
- data/spec/formatting/binary/array_spec.rb +2 -2
- data/spec/formatting/binary/base64_spec.rb +8 -8
- data/spec/formatting/binary/float_spec.rb +6 -4
- data/spec/formatting/binary/integer_spec.rb +25 -25
- data/spec/formatting/binary/string_spec.rb +32 -30
- 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 +33 -33
- data/spec/fuzzing/extensions/string_spec.rb +11 -11
- data/spec/fuzzing/fuzzer_spec.rb +15 -15
- data/spec/fuzzing/fuzzing_spec.rb +5 -5
- data/spec/fuzzing/mutator_spec.rb +15 -15
- data/spec/fuzzing/repeater_spec.rb +7 -7
- data/spec/fuzzing/template_spec.rb +11 -11
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +34 -32
- data/spec/network/ftp_spec.rb +9 -9
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +1 -1
- data/spec/network/proxy_spec.rb +19 -19
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +9 -9
- data/spec/network/tcp/proxy_spec.rb +9 -7
- data/spec/network/tcp/tcp_spec.rb +161 -118
- data/spec/network/telnet_spec.rb +5 -5
- data/spec/network/udp/udp_spec.rb +123 -96
- data/spec/network/unix_spec.rb +24 -25
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +0 -1
- 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 +19 -19
- metadata +408 -366
- data/.gemtest +0 -0
@@ -30,7 +30,7 @@ describe String do
|
|
30
30
|
let(:digest_md5) { "098f6bcd4621d373cade4e832627b4f6" }
|
31
31
|
|
32
32
|
it "should return the MD5 digest of itself" do
|
33
|
-
subject.md5.
|
33
|
+
expect(subject.md5).to eq(digest_md5)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -40,7 +40,7 @@ describe String do
|
|
40
40
|
let(:digest_sha1) { "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3" }
|
41
41
|
|
42
42
|
it "should return the SHA1 digest of itself" do
|
43
|
-
subject.sha1.
|
43
|
+
expect(subject.sha1).to eq(digest_sha1)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -52,7 +52,7 @@ describe String do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return the SHA2 digest of itself" do
|
55
|
-
subject.sha2.
|
55
|
+
expect(subject.sha2).to eq(digest_sha2)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -64,7 +64,7 @@ describe String do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should return the SHA256 digest of itself" do
|
67
|
-
subject.sha256.
|
67
|
+
expect(subject.sha256).to eq(digest_sha256)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -76,7 +76,7 @@ describe String do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should return the SHA512 digest of itself" do
|
79
|
-
subject.sha512.
|
79
|
+
expect(subject.sha512).to eq(digest_sha512)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -24,7 +24,7 @@ describe Integer do
|
|
24
24
|
let(:html_escaped) { "&" }
|
25
25
|
|
26
26
|
it "should HTML escape itself" do
|
27
|
-
subject.html_escape.
|
27
|
+
expect(subject.html_escape).to eq(html_escaped)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -32,7 +32,7 @@ describe Integer do
|
|
32
32
|
let(:formatted_html) { "&" }
|
33
33
|
|
34
34
|
it "should HTML format all chars" do
|
35
|
-
subject.format_html.
|
35
|
+
expect(subject.format_html).to eq(formatted_html)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -44,11 +44,11 @@ describe Integer do
|
|
44
44
|
let(:normal_char) { 'A' }
|
45
45
|
|
46
46
|
it "should escape special JavaScript characters" do
|
47
|
-
special_byte.js_escape.
|
47
|
+
expect(special_byte.js_escape).to eq(escaped_special_byte)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should ignore normal characters" do
|
51
|
-
normal_byte.js_escape.
|
51
|
+
expect(normal_byte.js_escape).to eq(normal_char)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -56,11 +56,11 @@ describe Integer do
|
|
56
56
|
let(:js_escaped) { '\x26' }
|
57
57
|
|
58
58
|
it "should JavaScript format ascii bytes" do
|
59
|
-
subject.format_js.
|
59
|
+
expect(subject.format_js).to eq(js_escaped)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should JavaScript format unicode bytes" do
|
63
|
-
0xd556.format_js.
|
63
|
+
expect(0xd556.format_js).to eq('\uD556')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -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
|
@@ -34,65 +34,65 @@ describe String do
|
|
34
34
|
|
35
35
|
describe "#format_bytes" do
|
36
36
|
it "should format each byte in the String" do
|
37
|
-
subject.format_bytes { |b|
|
37
|
+
expect(subject.format_bytes { |b|
|
38
38
|
sprintf("%%%x",b)
|
39
|
-
}.
|
39
|
+
}).to eq("%68%65%6c%6c%6f")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should format specific bytes in a String" do
|
43
|
-
subject.format_bytes(:include => [104, 108]) { |b|
|
43
|
+
expect(subject.format_bytes(:include => [104, 108]) { |b|
|
44
44
|
b - 32
|
45
|
-
}.
|
45
|
+
}).to eq('HeLLo')
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should not format specific bytes in a String" do
|
49
|
-
subject.format_bytes(:exclude => [101, 111]) { |b|
|
49
|
+
expect(subject.format_bytes(:exclude => [101, 111]) { |b|
|
50
50
|
b - 32
|
51
|
-
}.
|
51
|
+
}).to eq('HeLLo')
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should format ranges of bytes in a String" do
|
55
|
-
subject.format_bytes(:include => (104..108)) { |b|
|
55
|
+
expect(subject.format_bytes(:include => (104..108)) { |b|
|
56
56
|
b - 32
|
57
|
-
}.
|
57
|
+
}).to eq('HeLLo')
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not format ranges of bytes in a String" do
|
61
|
-
subject.format_bytes(:exclude => (104..108)) { |b|
|
61
|
+
expect(subject.format_bytes(:exclude => (104..108)) { |b|
|
62
62
|
b - 32
|
63
|
-
}.
|
63
|
+
}).to eq('hEllO')
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "#format_chars" do
|
68
68
|
it "should format each character in the String" do
|
69
|
-
subject.format_chars { |c|
|
69
|
+
expect(subject.format_chars { |c|
|
70
70
|
"#{c}."
|
71
|
-
}.
|
71
|
+
}).to eq("h.e.l.l.o.")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should format specific chars in a String" do
|
75
|
-
subject.format_chars(:include => ['h', 'l']) { |c|
|
75
|
+
expect(subject.format_chars(:include => ['h', 'l']) { |c|
|
76
76
|
c.upcase
|
77
|
-
}.
|
77
|
+
}).to eq('HeLLo')
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not format specific chars in a String" do
|
81
|
-
subject.format_chars(:exclude => ['h', 'l']) { |c|
|
81
|
+
expect(subject.format_chars(:exclude => ['h', 'l']) { |c|
|
82
82
|
c.upcase
|
83
|
-
}.
|
83
|
+
}).to eq('hEllO')
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should format ranges of chars in a String" do
|
87
|
-
subject.format_chars(:include => /[h-l]/) { |c|
|
87
|
+
expect(subject.format_chars(:include => /[h-l]/) { |c|
|
88
88
|
c.upcase
|
89
|
-
}.
|
89
|
+
}).to eq('HeLLo')
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should not format ranges of chars in a String" do
|
93
|
-
subject.format_chars(:exclude => /[h-l]/) { |c|
|
93
|
+
expect(subject.format_chars(:exclude => /[h-l]/) { |c|
|
94
94
|
c.upcase
|
95
|
-
}.
|
95
|
+
}).to eq('hEllO')
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -100,63 +100,63 @@ describe String do
|
|
100
100
|
it "should capitalize each character when :probability is 1.0" do
|
101
101
|
new_string = subject.random_case(:probability => 1.0)
|
102
102
|
|
103
|
-
subject.upcase.
|
103
|
+
expect(subject.upcase).to eq(new_string)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should not capitalize any characters when :probability is 0.0" do
|
107
107
|
new_string = subject.random_case(:probability => 0.0)
|
108
108
|
|
109
|
-
subject.
|
109
|
+
expect(subject).to eq(new_string)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe "#insert_before" do
|
114
114
|
it "should inject data before a matched String" do
|
115
|
-
subject.insert_before('ll','x').
|
115
|
+
expect(subject.insert_before('ll','x')).to eq("hexllo")
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should inject data before a matched Regexp" do
|
119
|
-
subject.insert_before(/l+/,'x').
|
119
|
+
expect(subject.insert_before(/l+/,'x')).to eq("hexllo")
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should not inject data if no matches are found" do
|
123
|
-
subject.insert_before(/x/,'x').
|
123
|
+
expect(subject.insert_before(/x/,'x')).to eq(subject)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
describe "#insert_after" do
|
128
128
|
it "should inject data after a matched String" do
|
129
|
-
subject.insert_after('ll','x').
|
129
|
+
expect(subject.insert_after('ll','x')).to eq("hellxo")
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should inject data after a matched Regexp" do
|
133
|
-
subject.insert_after(/l+/,'x').
|
133
|
+
expect(subject.insert_after(/l+/,'x')).to eq("hellxo")
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should not inject data if no matches are found" do
|
137
|
-
subject.insert_after(/x/,'x').
|
137
|
+
expect(subject.insert_after(/x/,'x')).to eq(subject)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
describe "#unescape" do
|
142
142
|
it "should not unescape a normal String" do
|
143
|
-
"hello".unescape.
|
143
|
+
expect("hello".unescape).to eq("hello")
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should unescape a hex String" do
|
147
|
-
"\\x68\\x65\\x6c\\x6c\\x6f\\x4e".unescape.
|
147
|
+
expect("\\x68\\x65\\x6c\\x6c\\x6f\\x4e".unescape).to eq("hello\x4e")
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should unescape an octal String" do
|
151
|
-
"hello\012".unescape.
|
151
|
+
expect("hello\012".unescape).to eq("hello\n")
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should unescape control characters" do
|
155
|
-
"hello\\n".unescape.
|
155
|
+
expect("hello\\n".unescape).to eq("hello\n")
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should unescape normal characters" do
|
159
|
-
"hell\\o".unescape.
|
159
|
+
expect("hell\\o".unescape).to eq("hello")
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|