ronin-support 0.4.1 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/ChangeLog.md +75 -32
  2. data/Gemfile +17 -18
  3. data/README.md +9 -10
  4. data/Rakefile +10 -2
  5. data/gemspec.yml +1 -1
  6. data/lib/ronin/binary.rb +21 -0
  7. data/lib/ronin/binary/hexdump.rb +20 -0
  8. data/lib/ronin/binary/hexdump/parser.rb +411 -0
  9. data/lib/ronin/binary/struct.rb +579 -0
  10. data/lib/ronin/binary/template.rb +437 -0
  11. data/lib/ronin/extensions/ip_addr.rb +17 -13
  12. data/lib/ronin/extensions/regexp.rb +45 -0
  13. data/lib/ronin/extensions/string.rb +3 -3
  14. data/lib/ronin/formatting/extensions/binary.rb +1 -0
  15. data/lib/ronin/formatting/extensions/binary/array.rb +63 -0
  16. data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
  17. data/lib/ronin/formatting/extensions/binary/file.rb +39 -6
  18. data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
  19. data/lib/ronin/formatting/extensions/binary/integer.rb +56 -43
  20. data/lib/ronin/formatting/extensions/binary/string.rb +75 -187
  21. data/lib/ronin/formatting/extensions/text/string.rb +61 -0
  22. data/lib/ronin/fuzzing/extensions/string.rb +21 -8
  23. data/lib/ronin/fuzzing/fuzzing.rb +19 -17
  24. data/lib/ronin/network.rb +2 -1
  25. data/lib/ronin/network/dns.rb +57 -15
  26. data/lib/ronin/network/extensions.rb +0 -1
  27. data/lib/ronin/network/ftp.rb +145 -0
  28. data/lib/ronin/network/http/http.rb +13 -14
  29. data/lib/ronin/network/imap.rb +11 -10
  30. data/lib/ronin/network/mixins.rb +1 -0
  31. data/lib/ronin/network/mixins/ftp.rb +155 -0
  32. data/lib/ronin/network/mixins/ssl.rb +1 -1
  33. data/lib/ronin/network/mixins/tcp.rb +39 -6
  34. data/lib/ronin/network/mixins/udp.rb +121 -1
  35. data/lib/ronin/network/mixins/unix.rb +279 -0
  36. data/lib/ronin/network/pop3.rb +5 -5
  37. data/lib/ronin/network/proxy.rb +578 -0
  38. data/lib/ronin/network/smtp/email.rb +1 -1
  39. data/lib/ronin/network/smtp/smtp.rb +7 -8
  40. data/lib/ronin/network/ssl.rb +1 -6
  41. data/lib/ronin/network/tcp.rb +2 -305
  42. data/lib/ronin/network/tcp/proxy.rb +377 -0
  43. data/lib/ronin/network/tcp/tcp.rb +435 -0
  44. data/lib/ronin/network/telnet.rb +27 -23
  45. data/lib/ronin/network/udp.rb +2 -266
  46. data/lib/ronin/network/udp/proxy.rb +169 -0
  47. data/lib/ronin/network/udp/udp.rb +442 -0
  48. data/lib/ronin/network/unix.rb +287 -0
  49. data/lib/ronin/path.rb +2 -2
  50. data/lib/ronin/spec/ui/output.rb +1 -7
  51. data/lib/ronin/support.rb +1 -0
  52. data/lib/ronin/support/inflector.rb +3 -7
  53. data/lib/ronin/support/support.rb +2 -1
  54. data/lib/ronin/support/version.rb +1 -1
  55. data/lib/ronin/ui/output/helpers.rb +13 -15
  56. data/lib/ronin/ui/output/output.rb +2 -2
  57. data/lib/ronin/ui/output/terminal/color.rb +10 -4
  58. data/lib/ronin/wordlist.rb +92 -17
  59. data/ronin-support.gemspec +38 -109
  60. data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
  61. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
  62. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
  63. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
  64. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
  65. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
  66. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
  67. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
  68. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
  69. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
  70. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
  71. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
  72. data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
  73. data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
  74. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
  75. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
  76. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
  77. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
  78. data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
  79. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
  80. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
  81. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
  82. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
  83. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
  84. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
  85. data/spec/binary/hexdump/parser_spec.rb +302 -0
  86. data/spec/binary/struct_spec.rb +496 -0
  87. data/spec/binary/template_spec.rb +400 -0
  88. data/spec/extensions/ip_addr_spec.rb +58 -32
  89. data/spec/extensions/regexp_spec.rb +60 -0
  90. data/spec/extensions/string_spec.rb +1 -1
  91. data/spec/formatting/binary/array_spec.rb +22 -0
  92. data/spec/formatting/binary/base64_spec.rb +50 -0
  93. data/spec/formatting/binary/float_spec.rb +30 -0
  94. data/spec/formatting/binary/integer_spec.rb +54 -40
  95. data/spec/formatting/binary/string_spec.rb +69 -182
  96. data/spec/formatting/text/string_spec.rb +30 -0
  97. data/spec/network/dns_spec.rb +64 -0
  98. data/spec/network/ftp_spec.rb +65 -0
  99. data/spec/network/proxy_spec.rb +121 -0
  100. data/spec/network/shared/unix_server.rb +31 -0
  101. data/spec/network/tcp/proxy_spec.rb +116 -0
  102. data/spec/network/{tcp_spec.rb → tcp/tcp_spec.rb} +24 -1
  103. data/spec/network/telnet_spec.rb +67 -0
  104. data/spec/network/{udp_spec.rb → udp/udp_spec.rb} +24 -1
  105. data/spec/network/unix_spec.rb +183 -0
  106. data/spec/wordlist_spec.rb +74 -13
  107. metadata +129 -85
  108. data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
@@ -2,6 +2,38 @@ require 'spec_helper'
2
2
  require 'ronin/extensions/regexp'
3
3
 
4
4
  describe Regexp do
5
+ describe "WORD" do
6
+ let(:word) { 'dog' }
7
+
8
+ subject { Regexp::WORD }
9
+
10
+ it "should not match single letters" do
11
+ subject.match('A').should be_nil
12
+ end
13
+
14
+ it "should not match numeric letters" do
15
+ subject.match("123#{word}123")[0].should == word
16
+ end
17
+
18
+ it "should not include ending periods" do
19
+ subject.match("#{word}.")[0].should == word
20
+ end
21
+
22
+ it "should not include leading punctuation" do
23
+ subject.match("'#{word}")[0].should == word
24
+ end
25
+
26
+ it "should not include tailing punctuation" do
27
+ subject.match("#{word}'")[0].should == word
28
+ end
29
+
30
+ it "should include punctuation in the middle of the word" do
31
+ name = "O'Brian"
32
+
33
+ subject.match(name)[0].should == name
34
+ end
35
+ end
36
+
5
37
  describe "OCTET" do
6
38
  subject { Regexp::OCTET }
7
39
 
@@ -172,6 +204,34 @@ describe Regexp do
172
204
  end
173
205
  end
174
206
 
207
+ describe "PHONE_NUMBER" do
208
+ subject { Regexp::PHONE_NUMBER }
209
+
210
+ it "should match 111-2222" do
211
+ number = '111-2222'
212
+
213
+ subject.match(number)[0].should == number
214
+ end
215
+
216
+ it "should match 111-2222x9" do
217
+ number = '111-2222x9'
218
+
219
+ subject.match(number)[0].should == number
220
+ end
221
+
222
+ it "should match 800-111-2222" do
223
+ number = '800-111-2222'
224
+
225
+ subject.match(number)[0].should == number
226
+ end
227
+
228
+ it "should match 1-800-111-2222" do
229
+ number = '1-800-111-2222'
230
+
231
+ subject.match(number)[0].should == number
232
+ end
233
+ end
234
+
175
235
  describe "IDENTIFIER" do
176
236
  subject { Regexp::IDENTIFIER }
177
237
 
@@ -157,7 +157,7 @@ describe String do
157
157
  end
158
158
  end
159
159
 
160
- if RUBY_VERSION < '1.9'
160
+ if RUBY_VERSION < '1.9.'
161
161
  describe "#dump" do
162
162
  it "should dump printable strings" do
163
163
  "hello".dump.should == '"hello"'
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/extensions/binary/array'
3
+
4
+ describe Array do
5
+ subject { [0x1234, "hello"] }
6
+
7
+ it "should provide Array#pack" do
8
+ should respond_to(:pack)
9
+ end
10
+
11
+ describe "#pack" do
12
+ let(:packed) { "\x34\x12hello\0" }
13
+
14
+ it "should pack elements using Array#pack codes" do
15
+ subject.pack('vZ*').should == packed
16
+ end
17
+
18
+ it "should pack elements using Binary::Template types" do
19
+ subject.pack(:uint16_le, :string).should == packed
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/extensions/binary/base64'
3
+
4
+ describe Base64 do
5
+ subject { described_class }
6
+
7
+ if RUBY_VERSION < '1.9.'
8
+ let(:string) { '>' * 64 }
9
+
10
+ let(:base64) { "Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+\nPj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pg==\n" }
11
+ let(:strict_base64) { "Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pg==" }
12
+ let(:urlsafe_base64) { "Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pj4-Pg==" }
13
+
14
+ describe "strict_encode64" do
15
+ it "should strictly encode a String" do
16
+ subject.strict_encode64(string).should == strict_base64
17
+ end
18
+ end
19
+
20
+ describe "strict_decode64" do
21
+ it "should strict decode an encoded Base64 String" do
22
+ subject.strict_decode64(strict_base64).should == string
23
+ end
24
+
25
+ it "should raise an ArgumentError for non-strictly encoded Base64" do
26
+ lambda {
27
+ subject.strict_decode64(base64)
28
+ }.should raise_error(ArgumentError)
29
+ end
30
+ end
31
+
32
+ describe "urlsafe_encode64" do
33
+ it "should encode URL-safe Base64 Strings" do
34
+ subject.urlsafe_encode64(string).should == urlsafe_base64
35
+ end
36
+ end
37
+
38
+ describe "urlsafe_decode64" do
39
+ it "should decode URL-safe Base64 String" do
40
+ subject.urlsafe_decode64(urlsafe_base64).should == string
41
+ end
42
+
43
+ it "should raise an ArgumentError for non-strictly encoded Base64" do
44
+ lambda {
45
+ subject.urlsafe_decode64(base64)
46
+ }.should raise_error(ArgumentError)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'ronin/formatting/extensions/binary/float'
3
+
4
+ describe Float do
5
+ subject { 0.42 }
6
+
7
+ it "should provide Float#pack" do
8
+ should respond_to(:pack)
9
+ end
10
+
11
+ describe "#pack" do
12
+ let(:packed) { "\xE1z\x14\xAEG\xE1\xDA?" }
13
+
14
+ it "should unpack Strings using String#unpack template Strings" do
15
+ subject.pack('E').should == packed
16
+ end
17
+
18
+ it "should unpack Strings using a Binary::Template" do
19
+ subject.pack(:double_le).should == packed
20
+ end
21
+
22
+ context "when given non-Float Binary::Template types" do
23
+ it "should raise an ArgumentError" do
24
+ lambda {
25
+ subject.pack(:int)
26
+ }.should raise_error(ArgumentError)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require 'ronin/formatting/binary'
2
+ require 'ronin/formatting/extensions/binary/integer'
3
3
 
4
4
  require 'ostruct'
5
5
 
@@ -81,60 +81,74 @@ describe Integer do
81
81
  end
82
82
 
83
83
  describe "#pack" do
84
- let(:i386) do
85
- OpenStruct.new(:endian => :little, :address_length => 4)
84
+ subject { 0x1337 }
85
+
86
+ let(:packed) { "7\023\000\000" }
87
+
88
+ it "should pack Integers using Array#pack codes" do
89
+ subject.pack('V').should == packed
86
90
  end
87
91
 
88
- let(:ppc) do
89
- OpenStruct.new(:endian => :big, :address_length => 4)
92
+ it "should pack Integers using Binary::Template types" do
93
+ subject.pack(:uint32_le).should == packed
90
94
  end
91
95
 
92
- subject { 0x1337 }
96
+ context "when given non-Integer Binary::Template types" do
97
+ it "should raise an ArgumentError" do
98
+ lambda {
99
+ subject.pack(:float)
100
+ }.should raise_error(ArgumentError)
101
+ end
102
+ end
93
103
 
94
- let(:i386_packed_int) { "7\023\000\000" }
95
- let(:i386_packed_short) { "7\023" }
96
- let(:i386_packed_long) { "7\023\000\000" }
97
- let(:i386_packed_quad) { "7\023\000\000\000\000\000\000" }
104
+ context "deprecated" do
105
+ let(:uint16_le) { "7\023" }
106
+ let(:uint32_le) { "7\023\000\000" }
107
+ let(:uint64_le) { "7\023\000\000\000\000\000\000" }
98
108
 
99
- let(:ppc_packed_int) { "\000\000\0237" }
100
- let(:ppc_packed_short) { "\0237" }
101
- let(:ppc_packed_long) { "\000\000\0237" }
102
- let(:ppc_packed_quad) { "\000\000\000\000\000\000\0237" }
109
+ let(:uint16_be) { "\0237" }
110
+ let(:uint32_be) { "\000\000\0237" }
111
+ let(:uint64_be) { "\000\000\000\000\000\000\0237" }
103
112
 
104
- it "should pack itself for a little-endian architecture by default" do
105
- subject.pack(i386).should == i386_packed_int
106
- end
113
+ let(:i386) do
114
+ OpenStruct.new(:endian => :little, :address_length => 4)
115
+ end
107
116
 
108
- it "should pack itself as a short for a little-endian architecture" do
109
- subject.pack(i386,2).should == i386_packed_short
110
- end
117
+ let(:ppc) do
118
+ OpenStruct.new(:endian => :big, :address_length => 4)
119
+ end
111
120
 
112
- it "should pack itself as a long for a little-endian architecture" do
113
- subject.pack(i386,4).should == i386_packed_long
114
- end
121
+ it "should pack itself for a little-endian architecture by default" do
122
+ subject.pack(i386).should == uint32_le
123
+ end
115
124
 
116
- it "should pack itself as a quad for a little-endian architecture" do
117
- subject.pack(i386,8).should == i386_packed_quad
118
- end
125
+ it "should pack itself as a short for a little-endian architecture" do
126
+ subject.pack(i386,2).should == uint16_le
127
+ end
119
128
 
120
- it "should pack itself for a big-endian architecture" do
121
- subject.pack(ppc).should == ppc_packed_int
122
- end
129
+ it "should pack itself as a long for a little-endian architecture" do
130
+ subject.pack(i386,4).should == uint32_le
131
+ end
123
132
 
124
- it "should pack itself as a short for a big-endian architecture" do
125
- subject.pack(ppc,2).should == ppc_packed_short
126
- end
133
+ it "should pack itself as a quad for a little-endian architecture" do
134
+ subject.pack(i386,8).should == uint64_le
135
+ end
127
136
 
128
- it "should pack itself as a long for a big-endian architecture" do
129
- subject.pack(ppc,4).should == ppc_packed_long
130
- end
137
+ it "should pack itself for a big-endian architecture" do
138
+ subject.pack(ppc).should == uint32_be
139
+ end
131
140
 
132
- it "should pack itself as a quad for a big-endian architecture" do
133
- subject.pack(ppc,8).should == ppc_packed_quad
134
- end
141
+ it "should pack itself as a short for a big-endian architecture" do
142
+ subject.pack(ppc,2).should == uint16_be
143
+ end
144
+
145
+ it "should pack itself as a long for a big-endian architecture" do
146
+ subject.pack(ppc,4).should == uint32_be
147
+ end
135
148
 
136
- it "should accept Array#pack template strings" do
137
- subject.pack('L').should == i386_packed_long
149
+ it "should pack itself as a quad for a big-endian architecture" do
150
+ subject.pack(ppc,8).should == uint64_be
151
+ end
138
152
  end
139
153
  end
140
154
  end
@@ -1,12 +1,19 @@
1
1
  require 'spec_helper'
2
- require 'ronin/formatting/binary'
2
+ require 'ronin/formatting/extensions/binary/string'
3
3
 
4
- require 'formatting/binary/helpers/hexdumps'
5
4
  require 'ostruct'
6
5
 
7
6
  describe String do
8
7
  subject { "hello" }
9
8
 
9
+ it "should provide String#unpack_original" do
10
+ should respond_to(:unpack_original)
11
+ end
12
+
13
+ it "should provide String#unpack" do
14
+ should respond_to(:unpack)
15
+ end
16
+
10
17
  it "should provide String#depack" do
11
18
  should respond_to(:depack)
12
19
  end
@@ -31,61 +38,77 @@ describe String do
31
38
  should respond_to(:unhexdump)
32
39
  end
33
40
 
34
- describe "#depack" do
35
- subject { 0x1337 }
41
+ describe "#unpack" do
42
+ subject { "\x34\x12\x00\x00hello\0" }
43
+
44
+ let(:data) { [0x1234, "hello"] }
36
45
 
37
- let(:i386) do
38
- OpenStruct.new(:endian => :little, :address_length => 4)
46
+ it "should unpack Strings using String#unpack template Strings" do
47
+ subject.unpack('VZ*').should == data
39
48
  end
40
49
 
41
- let(:ppc) do
42
- OpenStruct.new(:endian => :big, :address_length => 4)
50
+ it "should unpack Strings using a Binary::Template" do
51
+ subject.unpack(:uint32_le, :string).should == data
43
52
  end
53
+ end
44
54
 
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" }
55
+ context "deprecated" do
56
+ describe "#depack" do
57
+ subject { 0x1337 }
49
58
 
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" }
59
+ let(:i386) do
60
+ OpenStruct.new(:endian => :little, :address_length => 4)
61
+ end
54
62
 
55
- it "should depack itself for a little-endian architecture" do
56
- i386_packed_int.depack(i386).should == subject
57
- end
63
+ let(:ppc) do
64
+ OpenStruct.new(:endian => :big, :address_length => 4)
65
+ end
58
66
 
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
67
+ let(:i386_packed_int) { "7\023\000\000" }
68
+ let(:i386_packed_short) { "7\023" }
69
+ let(:i386_packed_long) { "7\023\000\000" }
70
+ let(:i386_packed_quad) { "7\023\000\000\000\000\000\000" }
62
71
 
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
72
+ let(:ppc_packed_int) { "\000\000\0237" }
73
+ let(:ppc_packed_short) { "\0237" }
74
+ let(:ppc_packed_long) { "\000\000\0237" }
75
+ let(:ppc_packed_quad) { "\000\000\000\000\000\000\0237" }
66
76
 
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
77
+ it "should depack itself for a little-endian architecture" do
78
+ i386_packed_int.depack(i386).should == subject
79
+ end
70
80
 
71
- it "should depack itself for a big-endian architecture" do
72
- ppc_packed_int.depack(ppc).should == subject
73
- end
81
+ it "should depack itself as a short for a little-endian architecture" do
82
+ i386_packed_short.depack(i386,2).should == subject
83
+ end
74
84
 
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
85
+ it "should depack itself as a long for a little-endian architecture" do
86
+ i386_packed_long.depack(i386,4).should == subject
87
+ end
78
88
 
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
89
+ it "should depack itself as a quad for a little-endian architecture" do
90
+ i386_packed_quad.depack(i386,8).should == subject
91
+ end
82
92
 
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
93
+ it "should depack itself for a big-endian architecture" do
94
+ ppc_packed_int.depack(ppc).should == subject
95
+ end
96
+
97
+ it "should depack itself as a short for a big-endian architecture" do
98
+ ppc_packed_short.depack(ppc,2).should == subject
99
+ end
100
+
101
+ it "should depack itself as a long for a big-endian architecture" do
102
+ ppc_packed_long.depack(ppc,4).should == subject
103
+ end
104
+
105
+ it "should depack itself as a quad for a big-endian architecture" do
106
+ ppc_packed_quad.depack(ppc,8).should == subject
107
+ end
86
108
 
87
- it "should accept String#unpack template strings" do
88
- i386_packed_long.depack('L').should == [subject]
109
+ it "should accept String#unpack template strings" do
110
+ i386_packed_long.depack('V').should == [subject]
111
+ end
89
112
  end
90
113
  end
91
114
 
@@ -131,24 +154,6 @@ describe String do
131
154
  end
132
155
  end
133
156
 
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"
149
- end
150
- end
151
-
152
157
  describe "#xor" do
153
158
  subject { 'hello' }
154
159
 
@@ -177,130 +182,12 @@ describe String do
177
182
  end
178
183
 
179
184
  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')
185
+ subject { "00000000 23 20 52 6f 6e 69 6e 20 53 75 70 70 6f 72 74 0a |# Ronin Support.|\n00000010\n" }
194
186
 
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')
187
+ let(:raw) { "# Ronin Support\n" }
206
188
 
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
215
-
216
- it "should unhexdump repeated hexdump output" do
217
- hexdump = load_hexdump('hexdump_repeated')
218
-
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
189
+ it "should unhexdump a String" do
190
+ subject.unhexdump.should == raw
304
191
  end
305
192
  end
306
193
  end