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,91 +1,120 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
|
-
require 'ronin/formatting/binary'
|
4
|
+
require 'ronin/formatting/extensions/binary/string'
|
3
5
|
|
4
|
-
require 'formatting/binary/helpers/hexdumps'
|
5
6
|
require 'ostruct'
|
6
7
|
|
7
8
|
describe String do
|
8
9
|
subject { "hello" }
|
9
10
|
|
11
|
+
it "should provide String#unpack_original" do
|
12
|
+
expect(subject).to respond_to(:unpack_original)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should provide String#unpack" do
|
16
|
+
expect(subject).to respond_to(:unpack)
|
17
|
+
end
|
18
|
+
|
10
19
|
it "should provide String#depack" do
|
11
|
-
|
20
|
+
expect(subject).to respond_to(:depack)
|
12
21
|
end
|
13
22
|
|
14
23
|
it "should provide String#zlib_inflate" do
|
15
|
-
|
24
|
+
expect(subject).to respond_to(:zlib_inflate)
|
16
25
|
end
|
17
26
|
|
18
27
|
it "should provide String#zlib_deflate" do
|
19
|
-
|
28
|
+
expect(subject).to respond_to(:zlib_deflate)
|
20
29
|
end
|
21
30
|
|
22
31
|
it "should provide String#hex_unescape" do
|
23
|
-
|
32
|
+
expect(subject).to respond_to(:hex_unescape)
|
24
33
|
end
|
25
34
|
|
26
35
|
it "should provide String#xor" do
|
27
|
-
|
36
|
+
expect(subject).to respond_to(:xor)
|
28
37
|
end
|
29
38
|
|
30
39
|
it "should provide String#unhexdump" do
|
31
|
-
|
40
|
+
expect(subject).to respond_to(:unhexdump)
|
32
41
|
end
|
33
42
|
|
34
|
-
describe "#
|
35
|
-
subject {
|
43
|
+
describe "#unpack" do
|
44
|
+
subject { "\x34\x12\x00\x00hello\0" }
|
45
|
+
|
46
|
+
let(:data) { [0x1234, "hello"] }
|
36
47
|
|
37
|
-
|
38
|
-
|
48
|
+
context "when given only a String" do
|
49
|
+
it "should unpack Strings using String#unpack template Strings" do
|
50
|
+
expect(subject.unpack('VZ*')).to eq(data)
|
51
|
+
end
|
39
52
|
end
|
40
53
|
|
41
|
-
|
42
|
-
|
54
|
+
context "otherwise" do
|
55
|
+
it "should unpack Strings using Binary::Template" do
|
56
|
+
expect(subject.unpack(:uint32_le, :string)).to eq(data)
|
57
|
+
end
|
43
58
|
end
|
59
|
+
end
|
44
60
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
let(:i386_packed_quad) { "7\023\000\000\000\000\000\000" }
|
61
|
+
context "deprecated" do
|
62
|
+
describe "#depack" do
|
63
|
+
subject { 0x1337 }
|
49
64
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
let(:ppc_packed_quad) { "\000\000\000\000\000\000\0237" }
|
65
|
+
let(:i386) do
|
66
|
+
OpenStruct.new(:endian => :little, :address_length => 4)
|
67
|
+
end
|
54
68
|
|
55
|
-
|
56
|
-
|
57
|
-
|
69
|
+
let(:ppc) do
|
70
|
+
OpenStruct.new(:endian => :big, :address_length => 4)
|
71
|
+
end
|
58
72
|
|
59
|
-
|
60
|
-
i386_packed_short
|
61
|
-
|
73
|
+
let(:i386_packed_int) { "7\023\000\000" }
|
74
|
+
let(:i386_packed_short) { "7\023" }
|
75
|
+
let(:i386_packed_long) { "7\023\000\000" }
|
76
|
+
let(:i386_packed_quad) { "7\023\000\000\000\000\000\000" }
|
62
77
|
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
let(:ppc_packed_int) { "\000\000\0237" }
|
79
|
+
let(:ppc_packed_short) { "\0237" }
|
80
|
+
let(:ppc_packed_long) { "\000\000\0237" }
|
81
|
+
let(:ppc_packed_quad) { "\000\000\000\000\000\000\0237" }
|
66
82
|
|
67
|
-
|
68
|
-
|
69
|
-
|
83
|
+
it "should depack itself for a little-endian architecture" do
|
84
|
+
expect(i386_packed_int.depack(i386)).to eq(subject)
|
85
|
+
end
|
70
86
|
|
71
|
-
|
72
|
-
|
73
|
-
|
87
|
+
it "should depack itself as a short for a little-endian architecture" do
|
88
|
+
expect(i386_packed_short.depack(i386,2)).to eq(subject)
|
89
|
+
end
|
74
90
|
|
75
|
-
|
76
|
-
|
77
|
-
|
91
|
+
it "should depack itself as a long for a little-endian architecture" do
|
92
|
+
expect(i386_packed_long.depack(i386,4)).to eq(subject)
|
93
|
+
end
|
78
94
|
|
79
|
-
|
80
|
-
|
81
|
-
|
95
|
+
it "should depack itself as a quad for a little-endian architecture" do
|
96
|
+
expect(i386_packed_quad.depack(i386,8)).to eq(subject)
|
97
|
+
end
|
82
98
|
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
it "should depack itself for a big-endian architecture" do
|
100
|
+
expect(ppc_packed_int.depack(ppc)).to eq(subject)
|
101
|
+
end
|
86
102
|
|
87
|
-
|
88
|
-
|
103
|
+
it "should depack itself as a short for a big-endian architecture" do
|
104
|
+
expect(ppc_packed_short.depack(ppc,2)).to eq(subject)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should depack itself as a long for a big-endian architecture" do
|
108
|
+
expect(ppc_packed_long.depack(ppc,4)).to eq(subject)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should depack itself as a quad for a big-endian architecture" do
|
112
|
+
expect(ppc_packed_quad.depack(ppc,8)).to eq(subject)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should accept String#unpack template strings" do
|
116
|
+
expect(i386_packed_long.depack('V')).to eq([subject])
|
117
|
+
end
|
89
118
|
end
|
90
119
|
end
|
91
120
|
|
@@ -93,7 +122,7 @@ describe String do
|
|
93
122
|
subject { "hello\0" }
|
94
123
|
|
95
124
|
it "should base64 encode a String" do
|
96
|
-
subject.base64_encode.
|
125
|
+
expect(subject.base64_encode).to eq("aGVsbG8A\n")
|
97
126
|
end
|
98
127
|
end
|
99
128
|
|
@@ -101,7 +130,7 @@ describe String do
|
|
101
130
|
subject { "aGVsbG8A\n" }
|
102
131
|
|
103
132
|
it "should base64 decode a String" do
|
104
|
-
subject.base64_decode.
|
133
|
+
expect(subject.base64_decode).to eq("hello\0")
|
105
134
|
end
|
106
135
|
end
|
107
136
|
|
@@ -111,7 +140,7 @@ describe String do
|
|
111
140
|
end
|
112
141
|
|
113
142
|
it "should inflate a zlib deflated String" do
|
114
|
-
subject.zlib_inflate.
|
143
|
+
expect(subject.zlib_inflate).to eq("0f8f5ec6-14dc-46e7-a63a-f89b7d11265b\0")
|
115
144
|
end
|
116
145
|
end
|
117
146
|
|
@@ -119,7 +148,7 @@ describe String do
|
|
119
148
|
subject { "hello" }
|
120
149
|
|
121
150
|
it "should zlib deflate a String" do
|
122
|
-
subject.zlib_deflate.
|
151
|
+
expect(subject.zlib_deflate).to eq("x\x9c\xcbH\xcd\xc9\xc9\a\0\x06,\x02\x15")
|
123
152
|
end
|
124
153
|
end
|
125
154
|
|
@@ -127,25 +156,7 @@ describe String do
|
|
127
156
|
subject { "hello\x4e" }
|
128
157
|
|
129
158
|
it "should hex escape a String" do
|
130
|
-
subject.hex_escape.
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "#hex_unescape" do
|
135
|
-
it "should unescape a normal String" do
|
136
|
-
"hello".hex_unescape.should == "hello"
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should unescape a hex String" do
|
140
|
-
"\\x68\\x65\\x6c\\x6c\\x6f\\x4e".hex_unescape.should == "hello\x4e"
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should unescape an octal String" do
|
144
|
-
"hello\012".hex_unescape.should == "hello\n"
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should unescape control characters" do
|
148
|
-
"hello\\n".hex_unescape.should == "hello\n"
|
159
|
+
expect(subject.hex_escape).to eq("\\x68\\x65\\x6c\\x6c\\x6f\\x4e")
|
149
160
|
end
|
150
161
|
end
|
151
162
|
|
@@ -156,151 +167,33 @@ describe String do
|
|
156
167
|
let(:keys) { [0x50, 0x55] }
|
157
168
|
|
158
169
|
it "should not contain the key used in the xor" do
|
159
|
-
|
170
|
+
expect(subject).to_not include(key.chr)
|
160
171
|
end
|
161
172
|
|
162
173
|
it "should not equal the original string" do
|
163
|
-
subject.xor(key).
|
174
|
+
expect(subject.xor(key)).to_not be == subject
|
164
175
|
end
|
165
176
|
|
166
177
|
it "should be able to be decoded with another xor" do
|
167
|
-
subject.xor(key).xor(key).
|
178
|
+
expect(subject.xor(key).xor(key)).to eq(subject)
|
168
179
|
end
|
169
180
|
|
170
181
|
it "should allow xoring against a single key" do
|
171
|
-
subject.xor(key).
|
182
|
+
expect(subject.xor(key)).to eq("85<<?")
|
172
183
|
end
|
173
184
|
|
174
185
|
it "should allow xoring against multiple keys" do
|
175
|
-
subject.xor(keys).
|
186
|
+
expect(subject.xor(keys)).to eq("80<9?")
|
176
187
|
end
|
177
188
|
end
|
178
189
|
|
179
190
|
describe "#unhexdump" do
|
180
|
-
|
181
|
-
|
182
|
-
context "GNU hexdump" do
|
183
|
-
let(:ascii) { load_binary_data('ascii') }
|
184
|
-
let(:repeated) { load_binary_data('repeated') }
|
185
|
-
|
186
|
-
it "should unhexdump octal-byte hexdump output" do
|
187
|
-
hexdump = load_hexdump('hexdump_octal_bytes')
|
188
|
-
|
189
|
-
hexdump.unhexdump(:format => :hexdump, :encoding => :octal_bytes).should == ascii
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should unhexdump hex-byte hexdump output" do
|
193
|
-
hexdump = load_hexdump('hexdump_hex_bytes')
|
194
|
-
|
195
|
-
hexdump.unhexdump(:format => :hexdump, :encoding => :hex_bytes).should == ascii
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should unhexdump decimal-short hexdump output" do
|
199
|
-
hexdump = load_hexdump('hexdump_decimal_shorts')
|
200
|
-
|
201
|
-
hexdump.unhexdump(:format => :hexdump, :encoding => :decimal_shorts).should == ascii
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should unhexdump octal-short hexdump output" do
|
205
|
-
hexdump = load_hexdump('hexdump_octal_shorts')
|
206
|
-
|
207
|
-
hexdump.unhexdump(:format => :hexdump, :encoding => :octal_shorts).should == ascii
|
208
|
-
end
|
209
|
-
|
210
|
-
it "should unhexdump hex-short hexdump output" do
|
211
|
-
hexdump = load_hexdump('hexdump_hex_shorts')
|
212
|
-
|
213
|
-
hexdump.unhexdump(:format => :hexdump, :encoding => :hex_shorts).should == ascii
|
214
|
-
end
|
191
|
+
subject { "00000000 23 20 52 6f 6e 69 6e 20 53 75 70 70 6f 72 74 0a |# Ronin Support.|\n00000010\n" }
|
215
192
|
|
216
|
-
|
217
|
-
hexdump = load_hexdump('hexdump_repeated')
|
193
|
+
let(:raw) { "# Ronin Support\n" }
|
218
194
|
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
context "od" do
|
224
|
-
let(:ascii) { load_binary_data('ascii') }
|
225
|
-
let(:repeated) { load_binary_data('repeated') }
|
226
|
-
|
227
|
-
it "should unhexdump octal-byte hexdump output" do
|
228
|
-
hexdump = load_hexdump('od_octal_bytes')
|
229
|
-
|
230
|
-
hexdump.unhexdump(:format => :od, :encoding => :octal_bytes).should == ascii
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should unhexdump octal-shorts hexdump output" do
|
234
|
-
hexdump = load_hexdump('od_octal_shorts')
|
235
|
-
|
236
|
-
hexdump.unhexdump(:format => :od, :encoding => :octal_shorts).should == ascii
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should unhexdump octal-ints hexdump output" do
|
240
|
-
hexdump = load_hexdump('od_octal_ints')
|
241
|
-
|
242
|
-
hexdump.unhexdump(:format => :od, :encoding => :octal_ints).should == ascii
|
243
|
-
end
|
244
|
-
|
245
|
-
it "should unhexdump octal-quads hexdump output" do
|
246
|
-
hexdump = load_hexdump('od_octal_quads')
|
247
|
-
|
248
|
-
hexdump.unhexdump(:format => :od, :encoding => :octal_quads).should == ascii
|
249
|
-
end
|
250
|
-
|
251
|
-
it "should unhexdump decimal-byte hexdump output" do
|
252
|
-
hexdump = load_hexdump('od_decimal_bytes')
|
253
|
-
|
254
|
-
hexdump.unhexdump(:format => :od, :encoding => :decimal_bytes).should == ascii
|
255
|
-
end
|
256
|
-
|
257
|
-
it "should unhexdump decimal-shorts hexdump output" do
|
258
|
-
hexdump = load_hexdump('od_decimal_shorts')
|
259
|
-
|
260
|
-
hexdump.unhexdump(:format => :od, :encoding => :decimal_shorts).should == ascii
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should unhexdump decimal-ints hexdump output" do
|
264
|
-
hexdump = load_hexdump('od_decimal_ints')
|
265
|
-
|
266
|
-
hexdump.unhexdump(:format => :od, :encoding => :decimal_ints).should == ascii
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should unhexdump decimal-quads hexdump output" do
|
270
|
-
hexdump = load_hexdump('od_decimal_quads')
|
271
|
-
|
272
|
-
hexdump.unhexdump(:format => :od, :encoding => :decimal_quads).should == ascii
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should unhexdump hex-byte hexdump output" do
|
276
|
-
hexdump = load_hexdump('od_hex_bytes')
|
277
|
-
|
278
|
-
hexdump.unhexdump(:format => :od, :encoding => :hex_bytes).should == ascii
|
279
|
-
end
|
280
|
-
|
281
|
-
it "should unhexdump hex-shorts hexdump output" do
|
282
|
-
hexdump = load_hexdump('od_hex_shorts')
|
283
|
-
|
284
|
-
hexdump.unhexdump(:format => :od, :encoding => :hex_shorts).should == ascii
|
285
|
-
end
|
286
|
-
|
287
|
-
it "should unhexdump hex-ints hexdump output" do
|
288
|
-
hexdump = load_hexdump('od_hex_ints')
|
289
|
-
|
290
|
-
hexdump.unhexdump(:format => :od, :encoding => :hex_ints).should == ascii
|
291
|
-
end
|
292
|
-
|
293
|
-
it "should unhexdump hex-quads hexdump output" do
|
294
|
-
hexdump = load_hexdump('od_hex_quads')
|
295
|
-
|
296
|
-
hexdump.unhexdump(:format => :od, :encoding => :hex_quads).should == ascii
|
297
|
-
end
|
298
|
-
|
299
|
-
it "should unhexdump repeated hexdump output" do
|
300
|
-
hexdump = load_hexdump('od_repeated')
|
301
|
-
|
302
|
-
hexdump.unhexdump(:format => :od, :encoding => :octal_shorts).should == repeated
|
303
|
-
end
|
195
|
+
it "should unhexdump a String" do
|
196
|
+
expect(subject.unhexdump).to eq(raw)
|
304
197
|
end
|
305
198
|
end
|
306
199
|
end
|
@@ -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
|