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.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +28 -0
- data/Gemfile +6 -7
- data/README.md +53 -32
- data/Rakefile +1 -2
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +5 -5
- data/lib/ronin/binary/hexdump.rb +5 -5
- data/lib/ronin/binary/hexdump/parser.rb +5 -5
- data/lib/ronin/binary/struct.rb +5 -5
- data/lib/ronin/binary/template.rb +7 -7
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +37 -31
- data/lib/ronin/extensions/ip_addr.rb +6 -7
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +5 -5
- data/lib/ronin/extensions/resolv.rb +5 -5
- data/lib/ronin/extensions/string.rb +5 -5
- data/lib/ronin/formatting.rb +5 -5
- data/lib/ronin/formatting/binary.rb +5 -5
- data/lib/ronin/formatting/digest.rb +5 -5
- data/lib/ronin/formatting/extensions.rb +5 -5
- data/lib/ronin/formatting/extensions/binary.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/base64.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/file.rb +5 -5
- data/lib/ronin/formatting/extensions/binary/float.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/binary/string.rb +6 -6
- data/lib/ronin/formatting/extensions/digest.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
- data/lib/ronin/formatting/extensions/html.rb +5 -5
- data/lib/ronin/formatting/extensions/html/integer.rb +5 -5
- data/lib/ronin/formatting/extensions/html/string.rb +7 -7
- data/lib/ronin/formatting/extensions/http.rb +5 -5
- data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/http/string.rb +7 -7
- data/lib/ronin/formatting/extensions/sql.rb +5 -5
- data/lib/ronin/formatting/extensions/sql/string.rb +15 -13
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +5 -5
- data/lib/ronin/formatting/extensions/text/string.rb +5 -5
- data/lib/ronin/formatting/html.rb +5 -5
- data/lib/ronin/formatting/http.rb +5 -5
- data/lib/ronin/formatting/sql.rb +5 -5
- data/lib/ronin/formatting/text.rb +5 -5
- data/lib/ronin/fuzzing.rb +5 -5
- data/lib/ronin/fuzzing/extensions.rb +5 -5
- data/lib/ronin/fuzzing/extensions/string.rb +5 -5
- data/lib/ronin/fuzzing/fuzzer.rb +5 -5
- data/lib/ronin/fuzzing/fuzzing.rb +7 -7
- data/lib/ronin/fuzzing/mutator.rb +5 -5
- data/lib/ronin/fuzzing/repeater.rb +5 -5
- data/lib/ronin/fuzzing/template.rb +5 -5
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +5 -5
- data/lib/ronin/network/dns.rb +5 -5
- data/lib/ronin/network/esmtp.rb +5 -5
- data/lib/ronin/network/extensions.rb +5 -5
- data/lib/ronin/network/extensions/dns.rb +5 -5
- data/lib/ronin/network/extensions/dns/net.rb +5 -5
- data/lib/ronin/network/extensions/esmtp.rb +5 -5
- data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
- data/lib/ronin/network/extensions/http.rb +5 -5
- data/lib/ronin/network/extensions/http/net.rb +5 -5
- data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
- data/lib/ronin/network/extensions/imap.rb +5 -5
- data/lib/ronin/network/extensions/imap/net.rb +5 -5
- data/lib/ronin/network/extensions/pop3.rb +5 -5
- data/lib/ronin/network/extensions/pop3/net.rb +5 -5
- data/lib/ronin/network/extensions/smtp.rb +5 -5
- data/lib/ronin/network/extensions/smtp/net.rb +5 -5
- data/lib/ronin/network/extensions/ssl.rb +5 -5
- data/lib/ronin/network/extensions/ssl/net.rb +5 -5
- data/lib/ronin/network/extensions/tcp.rb +5 -5
- data/lib/ronin/network/extensions/tcp/net.rb +5 -5
- data/lib/ronin/network/extensions/telnet.rb +5 -5
- data/lib/ronin/network/extensions/telnet/net.rb +5 -5
- data/lib/ronin/network/extensions/udp.rb +5 -5
- data/lib/ronin/network/extensions/udp/net.rb +5 -5
- data/lib/ronin/network/ftp.rb +5 -5
- data/lib/ronin/network/http.rb +5 -5
- data/lib/ronin/network/http/exceptions.rb +5 -5
- data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
- data/lib/ronin/network/http/http.rb +52 -57
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +5 -5
- data/lib/ronin/network/mixins.rb +5 -5
- data/lib/ronin/network/mixins/dns.rb +5 -5
- data/lib/ronin/network/mixins/esmtp.rb +5 -5
- data/lib/ronin/network/mixins/ftp.rb +5 -5
- data/lib/ronin/network/mixins/http.rb +7 -7
- data/lib/ronin/network/mixins/imap.rb +5 -5
- data/lib/ronin/network/mixins/mixin.rb +5 -5
- data/lib/ronin/network/mixins/pop3.rb +5 -5
- data/lib/ronin/network/mixins/smtp.rb +5 -5
- data/lib/ronin/network/mixins/ssl.rb +5 -5
- data/lib/ronin/network/mixins/tcp.rb +5 -5
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +5 -5
- data/lib/ronin/network/mixins/unix.rb +5 -5
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +5 -5
- data/lib/ronin/network/proxy.rb +5 -5
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +5 -5
- data/lib/ronin/network/ssl.rb +7 -7
- data/lib/ronin/network/tcp.rb +5 -5
- data/lib/ronin/network/tcp/proxy.rb +5 -5
- data/lib/ronin/network/tcp/tcp.rb +32 -23
- data/lib/ronin/network/telnet.rb +7 -5
- data/lib/ronin/network/udp.rb +5 -5
- data/lib/ronin/network/udp/proxy.rb +5 -5
- data/lib/ronin/network/udp/udp.rb +28 -26
- data/lib/ronin/network/unix.rb +7 -7
- data/lib/ronin/path.rb +32 -36
- data/lib/ronin/spec/ui/output.rb +5 -5
- data/lib/ronin/support.rb +5 -5
- data/lib/ronin/support/inflector.rb +5 -5
- data/lib/ronin/support/support.rb +5 -5
- data/lib/ronin/support/version.rb +6 -6
- data/lib/ronin/templates.rb +5 -5
- data/lib/ronin/templates/erb.rb +5 -5
- data/lib/ronin/templates/template.rb +5 -5
- data/lib/ronin/ui/output.rb +5 -5
- data/lib/ronin/ui/output/helpers.rb +5 -5
- data/lib/ronin/ui/output/output.rb +17 -21
- data/lib/ronin/ui/output/terminal.rb +5 -5
- data/lib/ronin/ui/output/terminal/color.rb +5 -5
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +5 -5
- data/lib/ronin/wordlist.rb +7 -7
- data/ronin-support.gemspec +1 -0
- data/spec/binary/hexdump/parser_spec.rb +22 -22
- data/spec/binary/struct_spec.rb +56 -56
- data/spec/binary/template_spec.rb +106 -104
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +30 -30
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +69 -69
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +30 -29
- data/spec/formatting/binary/array_spec.rb +2 -2
- data/spec/formatting/binary/base64_spec.rb +8 -8
- data/spec/formatting/binary/float_spec.rb +6 -4
- data/spec/formatting/binary/integer_spec.rb +25 -25
- data/spec/formatting/binary/string_spec.rb +32 -30
- data/spec/formatting/digest/string_spec.rb +5 -5
- data/spec/formatting/html/integer_spec.rb +6 -6
- data/spec/formatting/html/string_spec.rb +10 -10
- data/spec/formatting/http/integer_spec.rb +3 -3
- data/spec/formatting/http/string_spec.rb +5 -5
- data/spec/formatting/sql/string_spec.rb +21 -19
- data/spec/formatting/text/array_spec.rb +15 -15
- data/spec/formatting/text/string_spec.rb +33 -33
- data/spec/fuzzing/extensions/string_spec.rb +11 -11
- data/spec/fuzzing/fuzzer_spec.rb +15 -15
- data/spec/fuzzing/fuzzing_spec.rb +5 -5
- data/spec/fuzzing/mutator_spec.rb +15 -15
- data/spec/fuzzing/repeater_spec.rb +7 -7
- data/spec/fuzzing/template_spec.rb +11 -11
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +34 -32
- data/spec/network/ftp_spec.rb +9 -9
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +1 -1
- data/spec/network/proxy_spec.rb +19 -19
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +9 -9
- data/spec/network/tcp/proxy_spec.rb +9 -7
- data/spec/network/tcp/tcp_spec.rb +161 -118
- data/spec/network/telnet_spec.rb +5 -5
- data/spec/network/udp/udp_spec.rb +123 -96
- data/spec/network/unix_spec.rb +24 -25
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +0 -1
- data/spec/support/inflector_spec.rb +4 -4
- data/spec/support_spec.rb +1 -1
- data/spec/templates/erb_spec.rb +3 -3
- data/spec/templates/template_spec.rb +10 -10
- data/spec/ui/shell_spec.rb +15 -15
- data/spec/wordlist_spec.rb +19 -19
- metadata +408 -366
- data/.gemtest +0 -0
@@ -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) {
|
22
|
-
let(:port) {
|
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).
|
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?(
|
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.
|
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.
|
50
|
-
socket.
|
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
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
72
|
+
expect(bound_port).to eq(local_port)
|
60
73
|
|
61
|
-
|
74
|
+
socket.close
|
75
|
+
end
|
62
76
|
end
|
63
77
|
|
64
|
-
|
65
|
-
|
78
|
+
context "when given a block" do
|
79
|
+
it "should yield the new UDPSocket" do
|
80
|
+
socket = nil
|
66
81
|
|
67
|
-
|
68
|
-
|
69
|
-
|
82
|
+
subject.udp_connect(host,port) do |yielded_socket|
|
83
|
+
socket = yielded_socket
|
84
|
+
end
|
70
85
|
|
71
|
-
|
72
|
-
|
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').
|
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.
|
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').
|
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.
|
126
|
-
socket.
|
141
|
+
expect(socket).to be_kind_of(UDPSocket)
|
142
|
+
expect(socket).to be_closed
|
127
143
|
end
|
128
144
|
|
129
|
-
|
130
|
-
|
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
|
-
|
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').
|
168
|
+
expect(banner.start_with?('220')).to be_true
|
151
169
|
end
|
152
170
|
|
153
|
-
|
154
|
-
|
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
|
-
|
175
|
+
expect(banner.start_with?('220')).to be_true
|
176
|
+
end
|
157
177
|
end
|
158
178
|
|
159
|
-
|
160
|
-
banner
|
179
|
+
context "when given a block" do
|
180
|
+
it "should yield the banner" do
|
181
|
+
banner = nil
|
161
182
|
|
162
|
-
|
163
|
-
|
164
|
-
|
183
|
+
subject.udp_banner(host,port) do |yielded_banner|
|
184
|
+
banner = yielded_banner
|
185
|
+
end
|
165
186
|
|
166
|
-
|
187
|
+
expect(banner.start_with?('220')).to be_true
|
188
|
+
end
|
167
189
|
end
|
168
190
|
end
|
169
191
|
end
|
170
192
|
|
171
|
-
|
172
|
-
|
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
|
-
|
180
|
-
|
196
|
+
describe "#udp_send" do
|
197
|
+
include_context "UDP Server"
|
181
198
|
|
182
|
-
|
199
|
+
let(:data) { "hello\n" }
|
183
200
|
|
184
201
|
it "should send data to a service" do
|
185
|
-
subject.udp_send(data,
|
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].
|
206
|
+
expect(mesg[0]).to eq(data)
|
190
207
|
end
|
191
208
|
|
192
|
-
|
193
|
-
|
209
|
+
context "when given a local host and port" do
|
210
|
+
let(:local_port) { 1024 + rand(65535 - 1024) }
|
194
211
|
|
195
|
-
|
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
|
-
|
198
|
-
|
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.
|
209
|
-
server.
|
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
|
-
|
215
|
-
|
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
|
-
|
220
|
-
|
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
|
-
|
223
|
-
|
241
|
+
expect(bound_host).to eq(local_ip)
|
242
|
+
expect(bound_port).to eq(local_port)
|
224
243
|
|
225
|
-
|
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
|
-
|
233
|
-
|
248
|
+
context "when a block is given" do
|
249
|
+
it "should yield the new UDPSocket" do
|
250
|
+
server = nil
|
234
251
|
|
235
|
-
|
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.
|
250
|
-
server.
|
272
|
+
expect(server).to be_kind_of(UDPSocket)
|
273
|
+
expect(server).to be_closed
|
251
274
|
end
|
252
275
|
|
253
|
-
|
254
|
-
|
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
|
-
|
263
|
-
|
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
|
|
data/spec/network/unix_spec.rb
CHANGED
@@ -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).
|
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
|
-
|
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
|
-
|
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.
|
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.
|
51
|
-
socket.
|
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.
|
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.
|
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.
|
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.
|
106
|
-
socket.
|
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.
|
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.
|
141
|
-
server.
|
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.
|
154
|
-
server.
|
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.
|
173
|
-
server.
|
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) }
|