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.
Files changed (224) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -1
  6. data/ChangeLog.md +121 -33
  7. data/Gemfile +17 -18
  8. data/README.md +57 -33
  9. data/Rakefile +10 -3
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +21 -0
  12. data/lib/ronin/binary/hexdump.rb +20 -0
  13. data/lib/ronin/binary/hexdump/parser.rb +403 -0
  14. data/lib/ronin/binary/struct.rb +567 -0
  15. data/lib/ronin/binary/template.rb +454 -0
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +39 -33
  19. data/lib/ronin/extensions/ip_addr.rb +29 -31
  20. data/lib/ronin/extensions/kernel.rb +5 -5
  21. data/lib/ronin/extensions/meta.rb +5 -5
  22. data/lib/ronin/extensions/regexp.rb +50 -5
  23. data/lib/ronin/extensions/resolv.rb +7 -9
  24. data/lib/ronin/extensions/string.rb +10 -10
  25. data/lib/ronin/formatting.rb +5 -5
  26. data/lib/ronin/formatting/binary.rb +5 -5
  27. data/lib/ronin/formatting/digest.rb +5 -5
  28. data/lib/ronin/formatting/extensions.rb +5 -5
  29. data/lib/ronin/formatting/extensions/binary.rb +7 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +61 -0
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
  32. data/lib/ronin/formatting/extensions/binary/file.rb +44 -11
  33. data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +66 -50
  35. data/lib/ronin/formatting/extensions/binary/string.rb +81 -205
  36. data/lib/ronin/formatting/extensions/digest.rb +5 -5
  37. data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
  38. data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
  39. data/lib/ronin/formatting/extensions/html.rb +5 -5
  40. data/lib/ronin/formatting/extensions/html/integer.rb +9 -13
  41. data/lib/ronin/formatting/extensions/html/string.rb +31 -39
  42. data/lib/ronin/formatting/extensions/http.rb +5 -5
  43. data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
  44. data/lib/ronin/formatting/extensions/http/string.rb +7 -7
  45. data/lib/ronin/formatting/extensions/sql.rb +5 -5
  46. data/lib/ronin/formatting/extensions/sql/string.rb +22 -24
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +13 -11
  49. data/lib/ronin/formatting/extensions/text/string.rb +70 -13
  50. data/lib/ronin/formatting/html.rb +5 -5
  51. data/lib/ronin/formatting/http.rb +5 -5
  52. data/lib/ronin/formatting/sql.rb +5 -5
  53. data/lib/ronin/formatting/text.rb +5 -5
  54. data/lib/ronin/fuzzing.rb +5 -5
  55. data/lib/ronin/fuzzing/extensions.rb +5 -5
  56. data/lib/ronin/fuzzing/extensions/string.rb +42 -213
  57. data/lib/ronin/fuzzing/fuzzer.rb +110 -0
  58. data/lib/ronin/fuzzing/fuzzing.rb +33 -26
  59. data/lib/ronin/fuzzing/mutator.rb +161 -0
  60. data/lib/ronin/fuzzing/repeater.rb +81 -0
  61. data/lib/ronin/fuzzing/template.rb +133 -0
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +7 -5
  64. data/lib/ronin/network/dns.rb +64 -24
  65. data/lib/ronin/network/esmtp.rb +5 -5
  66. data/lib/ronin/network/extensions.rb +5 -5
  67. data/lib/ronin/network/extensions/dns.rb +5 -5
  68. data/lib/ronin/network/extensions/dns/net.rb +5 -5
  69. data/lib/ronin/network/extensions/esmtp.rb +5 -5
  70. data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
  71. data/lib/ronin/network/extensions/http.rb +5 -5
  72. data/lib/ronin/network/extensions/http/net.rb +5 -5
  73. data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
  74. data/lib/ronin/network/extensions/imap.rb +5 -5
  75. data/lib/ronin/network/extensions/imap/net.rb +5 -5
  76. data/lib/ronin/network/extensions/pop3.rb +5 -5
  77. data/lib/ronin/network/extensions/pop3/net.rb +5 -5
  78. data/lib/ronin/network/extensions/smtp.rb +5 -5
  79. data/lib/ronin/network/extensions/smtp/net.rb +5 -5
  80. data/lib/ronin/network/extensions/ssl.rb +5 -5
  81. data/lib/ronin/network/extensions/ssl/net.rb +5 -5
  82. data/lib/ronin/network/extensions/tcp.rb +5 -5
  83. data/lib/ronin/network/extensions/tcp/net.rb +5 -5
  84. data/lib/ronin/network/extensions/telnet.rb +5 -5
  85. data/lib/ronin/network/extensions/telnet/net.rb +5 -5
  86. data/lib/ronin/network/extensions/udp.rb +5 -5
  87. data/lib/ronin/network/extensions/udp/net.rb +5 -5
  88. data/lib/ronin/network/ftp.rb +149 -0
  89. data/lib/ronin/network/http.rb +5 -5
  90. data/lib/ronin/network/http/exceptions.rb +5 -5
  91. data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
  92. data/lib/ronin/network/http/http.rb +65 -70
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +16 -15
  95. data/lib/ronin/network/mixins.rb +6 -5
  96. data/lib/ronin/network/mixins/dns.rb +5 -5
  97. data/lib/ronin/network/mixins/esmtp.rb +5 -5
  98. data/lib/ronin/network/mixins/ftp.rb +155 -0
  99. data/lib/ronin/network/mixins/http.rb +58 -587
  100. data/lib/ronin/network/mixins/imap.rb +5 -5
  101. data/lib/ronin/network/mixins/mixin.rb +5 -5
  102. data/lib/ronin/network/mixins/pop3.rb +5 -5
  103. data/lib/ronin/network/mixins/smtp.rb +5 -5
  104. data/lib/ronin/network/mixins/ssl.rb +5 -5
  105. data/lib/ronin/network/mixins/tcp.rb +43 -10
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +126 -6
  108. data/lib/ronin/network/mixins/unix.rb +279 -0
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +10 -10
  111. data/lib/ronin/network/proxy.rb +578 -0
  112. data/lib/ronin/network/smtp.rb +5 -5
  113. data/lib/ronin/network/smtp/email.rb +6 -6
  114. data/lib/ronin/network/smtp/smtp.rb +12 -13
  115. data/lib/ronin/network/ssl.rb +16 -17
  116. data/lib/ronin/network/tcp.rb +7 -310
  117. data/lib/ronin/network/tcp/proxy.rb +417 -0
  118. data/lib/ronin/network/tcp/tcp.rb +452 -0
  119. data/lib/ronin/network/telnet.rb +34 -28
  120. data/lib/ronin/network/udp.rb +7 -271
  121. data/lib/ronin/network/udp/proxy.rb +191 -0
  122. data/lib/ronin/network/udp/udp.rb +452 -0
  123. data/lib/ronin/network/unix.rb +286 -0
  124. data/lib/ronin/path.rb +35 -39
  125. data/lib/ronin/spec/ui/output.rb +6 -12
  126. data/lib/ronin/support.rb +6 -5
  127. data/lib/ronin/support/inflector.rb +8 -12
  128. data/lib/ronin/support/support.rb +7 -5
  129. data/lib/ronin/support/version.rb +6 -6
  130. data/lib/ronin/templates.rb +5 -5
  131. data/lib/ronin/templates/erb.rb +5 -5
  132. data/lib/ronin/templates/template.rb +5 -5
  133. data/lib/ronin/ui/output.rb +5 -5
  134. data/lib/ronin/ui/output/helpers.rb +42 -28
  135. data/lib/ronin/ui/output/output.rb +17 -21
  136. data/lib/ronin/ui/output/terminal.rb +5 -5
  137. data/lib/ronin/ui/output/terminal/color.rb +15 -9
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +8 -11
  140. data/lib/ronin/wordlist.rb +110 -30
  141. data/ronin-support.gemspec +39 -109
  142. data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
  143. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
  144. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
  145. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
  146. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
  147. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
  148. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
  149. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
  150. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
  151. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
  152. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
  153. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
  154. data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
  155. data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
  156. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
  157. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
  158. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
  159. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
  160. data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
  161. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
  162. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
  163. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
  164. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
  165. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
  166. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
  167. data/spec/binary/hexdump/parser_spec.rb +302 -0
  168. data/spec/binary/struct_spec.rb +496 -0
  169. data/spec/binary/template_spec.rb +416 -0
  170. data/spec/extensions/enumerable_spec.rb +4 -4
  171. data/spec/extensions/file_spec.rb +12 -14
  172. data/spec/extensions/ip_addr_spec.rb +76 -50
  173. data/spec/extensions/kernel_spec.rb +7 -7
  174. data/spec/extensions/regexp_spec.rb +119 -59
  175. data/spec/extensions/resolv_spec.rb +2 -2
  176. data/spec/extensions/string_spec.rb +31 -30
  177. data/spec/formatting/binary/array_spec.rb +26 -0
  178. data/spec/formatting/binary/base64_spec.rb +50 -0
  179. data/spec/formatting/binary/float_spec.rb +36 -0
  180. data/spec/formatting/binary/integer_spec.rb +76 -50
  181. data/spec/formatting/binary/string_spec.rb +91 -198
  182. data/spec/formatting/digest/string_spec.rb +5 -5
  183. data/spec/formatting/html/integer_spec.rb +6 -6
  184. data/spec/formatting/html/string_spec.rb +10 -10
  185. data/spec/formatting/http/integer_spec.rb +3 -3
  186. data/spec/formatting/http/string_spec.rb +5 -5
  187. data/spec/formatting/sql/string_spec.rb +21 -19
  188. data/spec/formatting/text/array_spec.rb +15 -15
  189. data/spec/formatting/text/string_spec.rb +58 -28
  190. data/spec/fuzzing/extensions/string_spec.rb +87 -0
  191. data/spec/fuzzing/fuzzer_spec.rb +109 -0
  192. data/spec/fuzzing/fuzzing_spec.rb +24 -0
  193. data/spec/fuzzing/mutator_spec.rb +112 -0
  194. data/spec/fuzzing/repeater_spec.rb +57 -0
  195. data/spec/fuzzing/template_spec.rb +54 -0
  196. data/spec/mixin_spec.rb +10 -12
  197. data/spec/network/dns_spec.rb +89 -23
  198. data/spec/network/ftp_spec.rb +81 -0
  199. data/spec/network/http/http_spec.rb +237 -144
  200. data/spec/network/http/proxy_spec.rb +37 -37
  201. data/spec/network/network_spec.rb +2 -2
  202. data/spec/network/proxy_spec.rb +121 -0
  203. data/spec/network/shared/unix_server.rb +31 -0
  204. data/spec/network/smtp/email_spec.rb +14 -14
  205. data/spec/network/ssl_spec.rb +53 -3
  206. data/spec/network/tcp/proxy_spec.rb +118 -0
  207. data/spec/network/tcp/tcp_spec.rb +316 -0
  208. data/spec/network/telnet_spec.rb +67 -0
  209. data/spec/network/udp/udp_spec.rb +298 -0
  210. data/spec/network/unix_spec.rb +182 -0
  211. data/spec/path_spec.rb +43 -18
  212. data/spec/spec_helper.rb +2 -3
  213. data/spec/support/inflector_spec.rb +4 -4
  214. data/spec/support_spec.rb +1 -1
  215. data/spec/templates/erb_spec.rb +3 -3
  216. data/spec/templates/template_spec.rb +10 -10
  217. data/spec/ui/shell_spec.rb +15 -15
  218. data/spec/wordlist_spec.rb +80 -19
  219. metadata +176 -121
  220. data/.gemtest +0 -0
  221. data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
  222. data/spec/fuzzing/string_spec.rb +0 -158
  223. data/spec/network/tcp_spec.rb +0 -247
  224. 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
- should respond_to(:depack)
20
+ expect(subject).to respond_to(:depack)
12
21
  end
13
22
 
14
23
  it "should provide String#zlib_inflate" do
15
- should respond_to(:zlib_inflate)
24
+ expect(subject).to respond_to(:zlib_inflate)
16
25
  end
17
26
 
18
27
  it "should provide String#zlib_deflate" do
19
- should respond_to(:zlib_deflate)
28
+ expect(subject).to respond_to(:zlib_deflate)
20
29
  end
21
30
 
22
31
  it "should provide String#hex_unescape" do
23
- should respond_to(:hex_unescape)
32
+ expect(subject).to respond_to(:hex_unescape)
24
33
  end
25
34
 
26
35
  it "should provide String#xor" do
27
- should respond_to(:xor)
36
+ expect(subject).to respond_to(:xor)
28
37
  end
29
38
 
30
39
  it "should provide String#unhexdump" do
31
- should respond_to(:unhexdump)
40
+ expect(subject).to respond_to(:unhexdump)
32
41
  end
33
42
 
34
- describe "#depack" do
35
- subject { 0x1337 }
43
+ describe "#unpack" do
44
+ subject { "\x34\x12\x00\x00hello\0" }
45
+
46
+ let(:data) { [0x1234, "hello"] }
36
47
 
37
- let(:i386) do
38
- OpenStruct.new(:endian => :little, :address_length => 4)
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
- let(:ppc) do
42
- OpenStruct.new(:endian => :big, :address_length => 4)
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
- let(:i386_packed_int) { "7\023\000\000" }
46
- let(:i386_packed_short) { "7\023" }
47
- let(:i386_packed_long) { "7\023\000\000" }
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
- let(:ppc_packed_int) { "\000\000\0237" }
51
- let(:ppc_packed_short) { "\0237" }
52
- let(:ppc_packed_long) { "\000\000\0237" }
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
- it "should depack itself for a little-endian architecture" do
56
- i386_packed_int.depack(i386).should == subject
57
- end
69
+ let(:ppc) do
70
+ OpenStruct.new(:endian => :big, :address_length => 4)
71
+ end
58
72
 
59
- it "should depack itself as a short for a little-endian architecture" do
60
- i386_packed_short.depack(i386,2).should == subject
61
- end
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
- it "should depack itself as a long for a little-endian architecture" do
64
- i386_packed_long.depack(i386,4).should == subject
65
- end
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
- it "should depack itself as a quad for a little-endian architecture" do
68
- i386_packed_quad.depack(i386,8).should == subject
69
- end
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
- it "should depack itself for a big-endian architecture" do
72
- ppc_packed_int.depack(ppc).should == subject
73
- end
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
- it "should depack itself as a short for a big-endian architecture" do
76
- ppc_packed_short.depack(ppc,2).should == subject
77
- end
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
- it "should depack itself as a long for a big-endian architecture" do
80
- ppc_packed_long.depack(ppc,4).should == subject
81
- end
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
- it "should depack itself as a quad for a big-endian architecture" do
84
- ppc_packed_quad.depack(ppc,8).should == subject
85
- end
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
- it "should accept String#unpack template strings" do
88
- i386_packed_long.depack('L').should == [subject]
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.should == "aGVsbG8A\n"
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.should == "hello\0"
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.should == "0f8f5ec6-14dc-46e7-a63a-f89b7d11265b\0"
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.should == "x\x9c\xcbH\xcd\xc9\xc9\a\0\x06,\x02\x15"
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.should == "\\x68\\x65\\x6c\\x6c\\x6f\\x4e"
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
- should_not include(key.chr)
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).should_not == subject
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).should == subject
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).should == "85<<?"
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).should == "80<9?"
186
+ expect(subject.xor(keys)).to eq("80<9?")
176
187
  end
177
188
  end
178
189
 
179
190
  describe "#unhexdump" do
180
- include Helpers
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
- it "should unhexdump repeated hexdump output" do
217
- hexdump = load_hexdump('hexdump_repeated')
193
+ let(:raw) { "# Ronin Support\n" }
218
194
 
219
- hexdump.unhexdump(:format => :hexdump, :encoding => :hex_bytes).should == repeated
220
- end
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.should == digest_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.should == digest_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.should == digest_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.should == digest_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.should == digest_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) { "&amp;" }
25
25
 
26
26
  it "should HTML escape itself" do
27
- subject.html_escape.should == html_escaped
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) { "&#38;" }
33
33
 
34
34
  it "should HTML format all chars" do
35
- subject.format_html.should == formatted_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.should == escaped_special_byte
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.should == normal_char
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.should == js_escaped
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.should == '\uD556'
63
+ expect(0xd556.format_js).to eq('\uD556')
64
64
  end
65
65
  end
66
66
  end