ronin-support 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) 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 +28 -0
  7. data/Gemfile +6 -7
  8. data/README.md +53 -32
  9. data/Rakefile +1 -2
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +5 -5
  12. data/lib/ronin/binary/hexdump.rb +5 -5
  13. data/lib/ronin/binary/hexdump/parser.rb +5 -5
  14. data/lib/ronin/binary/struct.rb +5 -5
  15. data/lib/ronin/binary/template.rb +7 -7
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +37 -31
  19. data/lib/ronin/extensions/ip_addr.rb +6 -7
  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 +5 -5
  23. data/lib/ronin/extensions/resolv.rb +5 -5
  24. data/lib/ronin/extensions/string.rb +5 -5
  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 +5 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
  32. data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
  33. data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
  35. data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
  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 +5 -5
  41. data/lib/ronin/formatting/extensions/html/string.rb +7 -7
  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 +15 -13
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +5 -5
  49. data/lib/ronin/formatting/extensions/text/string.rb +5 -5
  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 +5 -5
  57. data/lib/ronin/fuzzing/fuzzer.rb +5 -5
  58. data/lib/ronin/fuzzing/fuzzing.rb +7 -7
  59. data/lib/ronin/fuzzing/mutator.rb +5 -5
  60. data/lib/ronin/fuzzing/repeater.rb +5 -5
  61. data/lib/ronin/fuzzing/template.rb +5 -5
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +5 -5
  64. data/lib/ronin/network/dns.rb +5 -5
  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 +5 -5
  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 +52 -57
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +5 -5
  95. data/lib/ronin/network/mixins.rb +5 -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 +5 -5
  99. data/lib/ronin/network/mixins/http.rb +7 -7
  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 +5 -5
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +5 -5
  108. data/lib/ronin/network/mixins/unix.rb +5 -5
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +5 -5
  111. data/lib/ronin/network/proxy.rb +5 -5
  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 +5 -5
  115. data/lib/ronin/network/ssl.rb +7 -7
  116. data/lib/ronin/network/tcp.rb +5 -5
  117. data/lib/ronin/network/tcp/proxy.rb +5 -5
  118. data/lib/ronin/network/tcp/tcp.rb +32 -23
  119. data/lib/ronin/network/telnet.rb +7 -5
  120. data/lib/ronin/network/udp.rb +5 -5
  121. data/lib/ronin/network/udp/proxy.rb +5 -5
  122. data/lib/ronin/network/udp/udp.rb +28 -26
  123. data/lib/ronin/network/unix.rb +7 -7
  124. data/lib/ronin/path.rb +32 -36
  125. data/lib/ronin/spec/ui/output.rb +5 -5
  126. data/lib/ronin/support.rb +5 -5
  127. data/lib/ronin/support/inflector.rb +5 -5
  128. data/lib/ronin/support/support.rb +5 -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 +5 -5
  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 +5 -5
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +5 -5
  140. data/lib/ronin/wordlist.rb +7 -7
  141. data/ronin-support.gemspec +1 -0
  142. data/spec/binary/hexdump/parser_spec.rb +22 -22
  143. data/spec/binary/struct_spec.rb +56 -56
  144. data/spec/binary/template_spec.rb +106 -104
  145. data/spec/extensions/enumerable_spec.rb +4 -4
  146. data/spec/extensions/file_spec.rb +12 -14
  147. data/spec/extensions/ip_addr_spec.rb +30 -30
  148. data/spec/extensions/kernel_spec.rb +7 -7
  149. data/spec/extensions/regexp_spec.rb +69 -69
  150. data/spec/extensions/resolv_spec.rb +2 -2
  151. data/spec/extensions/string_spec.rb +30 -29
  152. data/spec/formatting/binary/array_spec.rb +2 -2
  153. data/spec/formatting/binary/base64_spec.rb +8 -8
  154. data/spec/formatting/binary/float_spec.rb +6 -4
  155. data/spec/formatting/binary/integer_spec.rb +25 -25
  156. data/spec/formatting/binary/string_spec.rb +32 -30
  157. data/spec/formatting/digest/string_spec.rb +5 -5
  158. data/spec/formatting/html/integer_spec.rb +6 -6
  159. data/spec/formatting/html/string_spec.rb +10 -10
  160. data/spec/formatting/http/integer_spec.rb +3 -3
  161. data/spec/formatting/http/string_spec.rb +5 -5
  162. data/spec/formatting/sql/string_spec.rb +21 -19
  163. data/spec/formatting/text/array_spec.rb +15 -15
  164. data/spec/formatting/text/string_spec.rb +33 -33
  165. data/spec/fuzzing/extensions/string_spec.rb +11 -11
  166. data/spec/fuzzing/fuzzer_spec.rb +15 -15
  167. data/spec/fuzzing/fuzzing_spec.rb +5 -5
  168. data/spec/fuzzing/mutator_spec.rb +15 -15
  169. data/spec/fuzzing/repeater_spec.rb +7 -7
  170. data/spec/fuzzing/template_spec.rb +11 -11
  171. data/spec/mixin_spec.rb +10 -12
  172. data/spec/network/dns_spec.rb +34 -32
  173. data/spec/network/ftp_spec.rb +9 -9
  174. data/spec/network/http/http_spec.rb +237 -144
  175. data/spec/network/http/proxy_spec.rb +37 -37
  176. data/spec/network/network_spec.rb +1 -1
  177. data/spec/network/proxy_spec.rb +19 -19
  178. data/spec/network/smtp/email_spec.rb +14 -14
  179. data/spec/network/ssl_spec.rb +9 -9
  180. data/spec/network/tcp/proxy_spec.rb +9 -7
  181. data/spec/network/tcp/tcp_spec.rb +161 -118
  182. data/spec/network/telnet_spec.rb +5 -5
  183. data/spec/network/udp/udp_spec.rb +123 -96
  184. data/spec/network/unix_spec.rb +24 -25
  185. data/spec/path_spec.rb +43 -18
  186. data/spec/spec_helper.rb +0 -1
  187. data/spec/support/inflector_spec.rb +4 -4
  188. data/spec/support_spec.rb +1 -1
  189. data/spec/templates/erb_spec.rb +3 -3
  190. data/spec/templates/template_spec.rb +10 -10
  191. data/spec/ui/shell_spec.rb +15 -15
  192. data/spec/wordlist_spec.rb +19 -19
  193. metadata +408 -366
  194. data/.gemtest +0 -0
@@ -8,25 +8,37 @@ describe Network::UDP do
8
8
  let(:host) { 'scanme.nmap.org' }
9
9
  let(:port) { 123 }
10
10
 
11
- let(:server_host) { 'localhost' }
12
- let(:server_ip) { Resolv.getaddress(server_host) }
13
-
14
11
  subject do
15
12
  obj = Object.new
16
13
  obj.extend described_class
17
14
  obj
18
15
  end
19
16
 
17
+ shared_examples "UDP Server" do
18
+ let(:server_host) { local_host }
19
+ let(:server_port) { 1024 + rand(65535 - 1024) }
20
+ let(:server) { UDPSocket.new }
21
+ let(:server_bind_ip) { server.addr[3] }
22
+ let(:server_bind_port) { server.addr[1] }
23
+
24
+ before(:each) { server.bind(server_host,server_port) }
25
+ after(:each) { server.close }
26
+ end
27
+
20
28
  describe "#udp_open?" do
21
- let(:host) { '4.2.2.1' }
22
- let(:port) { 53 }
29
+ let(:host) { server_bind_ip }
30
+ let(:port) { server_bind_port }
31
+
32
+ include_context "UDP Server"
23
33
 
24
34
  it "should return true for open ports" do
25
- subject.udp_open?(host,port).should == true
35
+ expect(subject.udp_open?(host,port)).to be(true)
26
36
  end
27
37
 
38
+ let(:closed_port) { port + 1 }
39
+
28
40
  it "should return false for closed ports" do
29
- subject.udp_open?('localhost',rand(1024) + 1).should == false
41
+ expect(subject.udp_open?(host,closed_port)).to be(false)
30
42
  end
31
43
 
32
44
  it "should have a timeout for firewalled ports" do
@@ -36,40 +48,44 @@ describe Network::UDP do
36
48
  subject.udp_open?(host,1337,nil,nil,timeout)
37
49
  t2 = Time.now
38
50
 
39
- (t2 - t1).to_i.should <= timeout
51
+ expect((t2 - t1).to_i).to be <= timeout
40
52
  end
41
53
  end
42
54
 
43
55
  describe "#udp_connect" do
44
- let(:local_port) { 1024 + rand(65535 - 1024) }
45
-
46
56
  it "should open a UDPSocket" do
47
57
  socket = subject.udp_connect(host,port)
48
58
 
49
- socket.should be_kind_of(UDPSocket)
50
- socket.should_not be_closed
59
+ expect(socket).to be_kind_of(UDPSocket)
60
+ expect(socket).not_to be_closed
51
61
 
52
62
  socket.close
53
63
  end
54
64
 
55
- it "should bind to a local port" do
56
- socket = subject.udp_connect(host,port,nil,local_port)
57
- bound_port = socket.addr[1]
65
+ context "when given a local port" do
66
+ let(:local_port) { 1024 + rand(65535 - 1024) }
67
+
68
+ it "should bind to a local port" do
69
+ socket = subject.udp_connect(host,port,nil,local_port)
70
+ bound_port = socket.addr[1]
58
71
 
59
- bound_port.should == local_port
72
+ expect(bound_port).to eq(local_port)
60
73
 
61
- socket.close
74
+ socket.close
75
+ end
62
76
  end
63
77
 
64
- it "should yield the new UDPSocket" do
65
- socket = nil
78
+ context "when given a block" do
79
+ it "should yield the new UDPSocket" do
80
+ socket = nil
66
81
 
67
- subject.udp_connect(host,port) do |yielded_socket|
68
- socket = yielded_socket
69
- end
82
+ subject.udp_connect(host,port) do |yielded_socket|
83
+ socket = yielded_socket
84
+ end
70
85
 
71
- socket.should_not be_closed
72
- socket.close
86
+ expect(socket).not_to be_closed
87
+ socket.close
88
+ end
73
89
  end
74
90
  end
75
91
 
@@ -83,7 +99,7 @@ describe Network::UDP do
83
99
  banner = socket.readline
84
100
  response = socket.readline
85
101
 
86
- response.start_with?('250').should be_true
102
+ expect(response.start_with?('250')).to be_true
87
103
 
88
104
  socket.close
89
105
  end
@@ -92,7 +108,7 @@ describe Network::UDP do
92
108
  socket = subject.udp_connect_and_send(data,host,port,nil,local_port)
93
109
  bound_port = socket.addr[1]
94
110
 
95
- bound_port.should == local_port
111
+ expect(bound_port).to eq(local_port)
96
112
 
97
113
  socket.close
98
114
  end
@@ -105,7 +121,7 @@ describe Network::UDP do
105
121
  response = socket.readline
106
122
  end
107
123
 
108
- response.start_with?('250').should be_true
124
+ expect(response.start_with?('250')).to be_true
109
125
 
110
126
  socket.close
111
127
  end
@@ -122,18 +138,20 @@ describe Network::UDP do
122
138
  socket = yielded_socket
123
139
  end
124
140
 
125
- socket.should be_kind_of(UDPSocket)
126
- socket.should be_closed
141
+ expect(socket).to be_kind_of(UDPSocket)
142
+ expect(socket).to be_closed
127
143
  end
128
144
 
129
- it "should bind to a local host and port" do
130
- bound_port = nil
145
+ context "when given a local host and port" do
146
+ it "should bind to a local host and port" do
147
+ bound_port = nil
148
+
149
+ subject.udp_session(host,port,nil,local_port) do |socket|
150
+ bound_port = socket.addr[1]
151
+ end
131
152
 
132
- subject.udp_session(host,port,nil,local_port) do |socket|
133
- bound_port = socket.addr[1]
153
+ expect(bound_port).to eq(local_port)
134
154
  end
135
-
136
- bound_port.should == local_port
137
155
  end
138
156
  end
139
157
 
@@ -147,98 +165,103 @@ describe Network::UDP do
147
165
  it "should read the service banner" do
148
166
  banner = subject.udp_banner(host,port)
149
167
 
150
- banner.start_with?('220').should be_true
168
+ expect(banner.start_with?('220')).to be_true
151
169
  end
152
170
 
153
- it "should bind to a local host and port" do
154
- banner = subject.udp_banner(host,port,nil,local_port)
171
+ context "when given a local host and port" do
172
+ it "should bind to a local host and port" do
173
+ banner = subject.udp_banner(host,port,nil,local_port)
155
174
 
156
- banner.start_with?('220').should be_true
175
+ expect(banner.start_with?('220')).to be_true
176
+ end
157
177
  end
158
178
 
159
- it "should yield the banner" do
160
- banner = nil
179
+ context "when given a block" do
180
+ it "should yield the banner" do
181
+ banner = nil
161
182
 
162
- subject.udp_banner(host,port) do |yielded_banner|
163
- banner = yielded_banner
164
- end
183
+ subject.udp_banner(host,port) do |yielded_banner|
184
+ banner = yielded_banner
185
+ end
165
186
 
166
- banner.start_with?('220').should be_true
187
+ expect(banner.start_with?('220')).to be_true
188
+ end
167
189
  end
168
190
  end
169
191
  end
170
192
 
171
- describe "#udp_send" do
172
- let(:server) do
173
- socket = UDPSocket.new
174
- socket.bind(server_host,0)
175
- socket
176
- end
177
- let(:server_port) { server.addr[1] }
193
+ let(:local_host) { 'localhost' }
194
+ let(:local_ip) { '127.0.0.1' } # XXX: UPDSocket defaults to using IPv4
178
195
 
179
- let(:data) { "hello\n" }
180
- let(:local_port) { 1024 + rand(65535 - 1024) }
196
+ describe "#udp_send" do
197
+ include_context "UDP Server"
181
198
 
182
- after(:all) { server.close }
199
+ let(:data) { "hello\n" }
183
200
 
184
201
  it "should send data to a service" do
185
- subject.udp_send(data,server_host,server_port)
202
+ subject.udp_send(data,server_bind_ip,server_bind_port)
186
203
 
187
204
  mesg = server.recvfrom(data.length)
188
205
 
189
- mesg[0].should == data
206
+ expect(mesg[0]).to eq(data)
190
207
  end
191
208
 
192
- it "should bind to a local host and port" do
193
- subject.udp_send(data,server_host,server_port,nil,local_port)
209
+ context "when given a local host and port" do
210
+ let(:local_port) { 1024 + rand(65535 - 1024) }
194
211
 
195
- mesg = server.recvfrom(data.length)
212
+ it "should bind to a local host and port" do
213
+ subject.udp_send(data,server_bind_ip,server_bind_port,server_bind_ip,local_port)
214
+
215
+ mesg = server.recvfrom(data.length)
196
216
 
197
- client_address = mesg[1]
198
- client_address[1].should == local_port
217
+ client_address = mesg[1]
218
+ expect(client_address[1]).to eq(local_port)
219
+ end
199
220
  end
200
221
  end
201
222
 
202
223
  describe "#udp_server" do
203
- let(:server_port) { 1024 + rand(65535 - 1024) }
204
-
205
224
  it "should create a new UDPSocket" do
206
225
  server = subject.udp_server
207
226
 
208
- server.should be_kind_of(UDPSocket)
209
- server.should_not be_closed
227
+ expect(server).to be_kind_of(UDPSocket)
228
+ expect(server).not_to be_closed
210
229
 
211
230
  server.close
212
231
  end
213
232
 
214
- it "should bind to a specific port and host" do
215
- server = subject.udp_server(server_port,server_host)
216
- bound_host = server.addr[3]
217
- bound_port = server.addr[1]
233
+ context "when given a port and host" do
234
+ let(:local_port) { 1024 + rand(65535 - 1024) }
218
235
 
219
- bound_host.should == server_ip
220
- bound_port.should == server_port
236
+ it "should bind to a specific port and host" do
237
+ server = subject.udp_server(local_port,local_host)
238
+ bound_host = server.addr[3]
239
+ bound_port = server.addr[1]
221
240
 
222
- server.close
223
- end
241
+ expect(bound_host).to eq(local_ip)
242
+ expect(bound_port).to eq(local_port)
224
243
 
225
- it "should yield the new UDPSocket" do
226
- server = nil
227
-
228
- subject.udp_server do |yielded_server|
229
- server = yielded_server
244
+ server.close
230
245
  end
246
+ end
231
247
 
232
- server.should be_kind_of(UDPSocket)
233
- server.should_not be_closed
248
+ context "when a block is given" do
249
+ it "should yield the new UDPSocket" do
250
+ server = nil
234
251
 
235
- server.close
252
+ subject.udp_server do |yielded_server|
253
+ server = yielded_server
254
+ end
255
+
256
+ expect(server).to be_kind_of(UDPSocket)
257
+ expect(server).not_to be_closed
258
+
259
+ server.close
260
+ end
236
261
  end
237
262
  end
238
263
 
239
264
  describe "#udp_server_session" do
240
- let(:server_port) { 1024 + rand(65535 - 1024) }
241
-
242
265
  it "should create a temporary UDPSocket" do
243
266
  server = nil
244
267
 
@@ -246,21 +269,25 @@ describe Network::UDP do
246
269
  server = yielded_server
247
270
  end
248
271
 
249
- server.should be_kind_of(UDPSocket)
250
- server.should be_closed
272
+ expect(server).to be_kind_of(UDPSocket)
273
+ expect(server).to be_closed
251
274
  end
252
275
 
253
- it "should bind to a specific port and host" do
254
- bound_host = nil
255
- bound_port = nil
256
-
257
- subject.udp_server_session(server_port,server_host) do |yielded_server|
258
- bound_host = yielded_server.addr[3]
259
- bound_port = yielded_server.addr[1]
260
- end
276
+ context "when given a port and a host" do
277
+ let(:local_port) { 1024 + rand(65535 - 1024) }
261
278
 
262
- bound_host.should == server_ip
263
- bound_port.should == server_port
279
+ it "should bind to a specific port and host" do
280
+ bound_host = nil
281
+ bound_port = nil
282
+
283
+ subject.udp_server_session(local_port,local_host) do |new_server|
284
+ bound_host = new_server.addr[3]
285
+ bound_port = new_server.addr[1]
286
+ end
287
+
288
+ expect(bound_host).to eq(local_ip)
289
+ expect(bound_port).to eq(local_port)
290
+ end
264
291
  end
265
292
  end
266
293
 
@@ -15,30 +15,29 @@ describe Network::UNIX do
15
15
  describe "#unix_open?" do
16
16
  include_context "UNIX Server"
17
17
 
18
- let(:old_path) { socket_path('ronin_old_unix_socket') }
19
- let(:bad_path) { socket_path('ronin_bad_unix_socket') }
20
-
21
- before(:all) { UNIXServer.new(old_path).close }
22
-
23
18
  it "should return true for listening UNIX sockets" do
24
- subject.unix_open?(path).should == true
19
+ expect(subject.unix_open?(path)).to be(true)
25
20
  end
26
21
 
27
22
  it "should return false for closed UNIX sockets" do
28
- subject.unix_open?(old_path).should == false
23
+ old_path = socket_path('ronin_old_unix_socket')
24
+ UNIXServer.new(old_path).close
25
+
26
+ expect(subject.unix_open?(old_path)).to be(false)
27
+
28
+ FileUtils.rm(old_path)
29
29
  end
30
30
 
31
31
  it "should have a timeout for non-existent UNIX sockets" do
32
- timeout = 2
32
+ bad_path = socket_path('ronin_bad_unix_socket')
33
+ timeout = 2
33
34
 
34
35
  t1 = Time.now
35
36
  subject.unix_open?(bad_path,timeout)
36
37
  t2 = Time.now
37
38
 
38
- (t2 - t1).to_i.should <= timeout
39
+ expect((t2 - t1).to_i).to be <= timeout
39
40
  end
40
-
41
- after(:all) { FileUtils.rm(old_path) }
42
41
  end
43
42
 
44
43
  describe "#unix_connect" do
@@ -47,8 +46,8 @@ describe Network::UNIX do
47
46
  it "should open a UNIXSocket" do
48
47
  socket = subject.unix_connect(path)
49
48
 
50
- socket.should be_kind_of(UNIXSocket)
51
- socket.should_not be_closed
49
+ expect(socket).to be_kind_of(UNIXSocket)
50
+ expect(socket).not_to be_closed
52
51
 
53
52
  socket.close
54
53
  end
@@ -60,7 +59,7 @@ describe Network::UNIX do
60
59
  socket = yielded_socket
61
60
  end
62
61
 
63
- socket.should_not be_closed
62
+ expect(socket).not_to be_closed
64
63
  socket.close
65
64
  end
66
65
  end
@@ -74,7 +73,7 @@ describe Network::UNIX do
74
73
  socket = subject.unix_connect_and_send(data,path)
75
74
  response = socket.readline
76
75
 
77
- response.should == data
76
+ expect(response).to eq(data)
78
77
 
79
78
  socket.close
80
79
  end
@@ -86,7 +85,7 @@ describe Network::UNIX do
86
85
  response = socket.readline
87
86
  end
88
87
 
89
- response.should == data
88
+ expect(response).to eq(data)
90
89
 
91
90
  socket.close
92
91
  end
@@ -102,8 +101,8 @@ describe Network::UNIX do
102
101
  socket = yielded_socket
103
102
  end
104
103
 
105
- socket.should be_kind_of(UNIXSocket)
106
- socket.should be_closed
104
+ expect(socket).to be_kind_of(UNIXSocket)
105
+ expect(socket).to be_closed
107
106
  end
108
107
  end
109
108
 
@@ -121,7 +120,7 @@ describe Network::UNIX do
121
120
 
122
121
  client.close
123
122
 
124
- sent.should == data
123
+ expect(sent).to eq(data)
125
124
  end
126
125
 
127
126
  after(:each) do
@@ -137,8 +136,8 @@ describe Network::UNIX do
137
136
  it "should create a new UNIXServer" do
138
137
  server = subject.unix_server(server_path)
139
138
 
140
- server.should be_kind_of(UNIXServer)
141
- server.should_not be_closed
139
+ expect(server).to be_kind_of(UNIXServer)
140
+ expect(server).not_to be_closed
142
141
 
143
142
  server.close
144
143
  end
@@ -150,8 +149,8 @@ describe Network::UNIX do
150
149
  server = yielded_server
151
150
  end
152
151
 
153
- server.should be_kind_of(UNIXServer)
154
- server.should_not be_closed
152
+ expect(server).to be_kind_of(UNIXServer)
153
+ expect(server).not_to be_closed
155
154
 
156
155
  server.close
157
156
  end
@@ -169,8 +168,8 @@ describe Network::UNIX do
169
168
  server = yielded_server
170
169
  end
171
170
 
172
- server.should be_kind_of(UNIXServer)
173
- server.should be_closed
171
+ expect(server).to be_kind_of(UNIXServer)
172
+ expect(server).to be_closed
174
173
  end
175
174
 
176
175
  after(:each) { FileUtils.rm(server_path) }