ronin-support 0.4.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +11 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +121 -33
- data/Gemfile +17 -18
- data/README.md +57 -33
- data/Rakefile +10 -3
- data/gemspec.yml +16 -7
- data/lib/ronin/binary.rb +21 -0
- data/lib/ronin/binary/hexdump.rb +20 -0
- data/lib/ronin/binary/hexdump/parser.rb +403 -0
- data/lib/ronin/binary/struct.rb +567 -0
- data/lib/ronin/binary/template.rb +454 -0
- data/lib/ronin/extensions.rb +5 -5
- data/lib/ronin/extensions/enumerable.rb +5 -5
- data/lib/ronin/extensions/file.rb +39 -33
- data/lib/ronin/extensions/ip_addr.rb +29 -31
- data/lib/ronin/extensions/kernel.rb +5 -5
- data/lib/ronin/extensions/meta.rb +5 -5
- data/lib/ronin/extensions/regexp.rb +50 -5
- data/lib/ronin/extensions/resolv.rb +7 -9
- data/lib/ronin/extensions/string.rb +10 -10
- data/lib/ronin/formatting.rb +5 -5
- data/lib/ronin/formatting/binary.rb +5 -5
- data/lib/ronin/formatting/digest.rb +5 -5
- data/lib/ronin/formatting/extensions.rb +5 -5
- data/lib/ronin/formatting/extensions/binary.rb +7 -5
- data/lib/ronin/formatting/extensions/binary/array.rb +61 -0
- data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
- data/lib/ronin/formatting/extensions/binary/file.rb +44 -11
- data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
- data/lib/ronin/formatting/extensions/binary/integer.rb +66 -50
- data/lib/ronin/formatting/extensions/binary/string.rb +81 -205
- data/lib/ronin/formatting/extensions/digest.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
- data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
- data/lib/ronin/formatting/extensions/html.rb +5 -5
- data/lib/ronin/formatting/extensions/html/integer.rb +9 -13
- data/lib/ronin/formatting/extensions/html/string.rb +31 -39
- data/lib/ronin/formatting/extensions/http.rb +5 -5
- data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
- data/lib/ronin/formatting/extensions/http/string.rb +7 -7
- data/lib/ronin/formatting/extensions/sql.rb +5 -5
- data/lib/ronin/formatting/extensions/sql/string.rb +22 -24
- data/lib/ronin/formatting/extensions/text.rb +5 -5
- data/lib/ronin/formatting/extensions/text/array.rb +13 -11
- data/lib/ronin/formatting/extensions/text/string.rb +70 -13
- data/lib/ronin/formatting/html.rb +5 -5
- data/lib/ronin/formatting/http.rb +5 -5
- data/lib/ronin/formatting/sql.rb +5 -5
- data/lib/ronin/formatting/text.rb +5 -5
- data/lib/ronin/fuzzing.rb +5 -5
- data/lib/ronin/fuzzing/extensions.rb +5 -5
- data/lib/ronin/fuzzing/extensions/string.rb +42 -213
- data/lib/ronin/fuzzing/fuzzer.rb +110 -0
- data/lib/ronin/fuzzing/fuzzing.rb +33 -26
- data/lib/ronin/fuzzing/mutator.rb +161 -0
- data/lib/ronin/fuzzing/repeater.rb +81 -0
- data/lib/ronin/fuzzing/template.rb +133 -0
- data/lib/ronin/mixin.rb +2 -2
- data/lib/ronin/network.rb +7 -5
- data/lib/ronin/network/dns.rb +64 -24
- data/lib/ronin/network/esmtp.rb +5 -5
- data/lib/ronin/network/extensions.rb +5 -5
- data/lib/ronin/network/extensions/dns.rb +5 -5
- data/lib/ronin/network/extensions/dns/net.rb +5 -5
- data/lib/ronin/network/extensions/esmtp.rb +5 -5
- data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
- data/lib/ronin/network/extensions/http.rb +5 -5
- data/lib/ronin/network/extensions/http/net.rb +5 -5
- data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
- data/lib/ronin/network/extensions/imap.rb +5 -5
- data/lib/ronin/network/extensions/imap/net.rb +5 -5
- data/lib/ronin/network/extensions/pop3.rb +5 -5
- data/lib/ronin/network/extensions/pop3/net.rb +5 -5
- data/lib/ronin/network/extensions/smtp.rb +5 -5
- data/lib/ronin/network/extensions/smtp/net.rb +5 -5
- data/lib/ronin/network/extensions/ssl.rb +5 -5
- data/lib/ronin/network/extensions/ssl/net.rb +5 -5
- data/lib/ronin/network/extensions/tcp.rb +5 -5
- data/lib/ronin/network/extensions/tcp/net.rb +5 -5
- data/lib/ronin/network/extensions/telnet.rb +5 -5
- data/lib/ronin/network/extensions/telnet/net.rb +5 -5
- data/lib/ronin/network/extensions/udp.rb +5 -5
- data/lib/ronin/network/extensions/udp/net.rb +5 -5
- data/lib/ronin/network/ftp.rb +149 -0
- data/lib/ronin/network/http.rb +5 -5
- data/lib/ronin/network/http/exceptions.rb +5 -5
- data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
- data/lib/ronin/network/http/http.rb +65 -70
- data/lib/ronin/network/http/proxy.rb +5 -5
- data/lib/ronin/network/imap.rb +16 -15
- data/lib/ronin/network/mixins.rb +6 -5
- data/lib/ronin/network/mixins/dns.rb +5 -5
- data/lib/ronin/network/mixins/esmtp.rb +5 -5
- data/lib/ronin/network/mixins/ftp.rb +155 -0
- data/lib/ronin/network/mixins/http.rb +58 -587
- data/lib/ronin/network/mixins/imap.rb +5 -5
- data/lib/ronin/network/mixins/mixin.rb +5 -5
- data/lib/ronin/network/mixins/pop3.rb +5 -5
- data/lib/ronin/network/mixins/smtp.rb +5 -5
- data/lib/ronin/network/mixins/ssl.rb +5 -5
- data/lib/ronin/network/mixins/tcp.rb +43 -10
- data/lib/ronin/network/mixins/telnet.rb +5 -5
- data/lib/ronin/network/mixins/udp.rb +126 -6
- data/lib/ronin/network/mixins/unix.rb +279 -0
- data/lib/ronin/network/network.rb +5 -5
- data/lib/ronin/network/pop3.rb +10 -10
- data/lib/ronin/network/proxy.rb +578 -0
- data/lib/ronin/network/smtp.rb +5 -5
- data/lib/ronin/network/smtp/email.rb +6 -6
- data/lib/ronin/network/smtp/smtp.rb +12 -13
- data/lib/ronin/network/ssl.rb +16 -17
- data/lib/ronin/network/tcp.rb +7 -310
- data/lib/ronin/network/tcp/proxy.rb +417 -0
- data/lib/ronin/network/tcp/tcp.rb +452 -0
- data/lib/ronin/network/telnet.rb +34 -28
- data/lib/ronin/network/udp.rb +7 -271
- data/lib/ronin/network/udp/proxy.rb +191 -0
- data/lib/ronin/network/udp/udp.rb +452 -0
- data/lib/ronin/network/unix.rb +286 -0
- data/lib/ronin/path.rb +35 -39
- data/lib/ronin/spec/ui/output.rb +6 -12
- data/lib/ronin/support.rb +6 -5
- data/lib/ronin/support/inflector.rb +8 -12
- data/lib/ronin/support/support.rb +7 -5
- data/lib/ronin/support/version.rb +6 -6
- data/lib/ronin/templates.rb +5 -5
- data/lib/ronin/templates/erb.rb +5 -5
- data/lib/ronin/templates/template.rb +5 -5
- data/lib/ronin/ui/output.rb +5 -5
- data/lib/ronin/ui/output/helpers.rb +42 -28
- data/lib/ronin/ui/output/output.rb +17 -21
- data/lib/ronin/ui/output/terminal.rb +5 -5
- data/lib/ronin/ui/output/terminal/color.rb +15 -9
- data/lib/ronin/ui/output/terminal/raw.rb +5 -5
- data/lib/ronin/ui/shell.rb +8 -11
- data/lib/ronin/wordlist.rb +110 -30
- data/ronin-support.gemspec +39 -109
- data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
- data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
- data/spec/binary/hexdump/parser_spec.rb +302 -0
- data/spec/binary/struct_spec.rb +496 -0
- data/spec/binary/template_spec.rb +416 -0
- data/spec/extensions/enumerable_spec.rb +4 -4
- data/spec/extensions/file_spec.rb +12 -14
- data/spec/extensions/ip_addr_spec.rb +76 -50
- data/spec/extensions/kernel_spec.rb +7 -7
- data/spec/extensions/regexp_spec.rb +119 -59
- data/spec/extensions/resolv_spec.rb +2 -2
- data/spec/extensions/string_spec.rb +31 -30
- data/spec/formatting/binary/array_spec.rb +26 -0
- data/spec/formatting/binary/base64_spec.rb +50 -0
- data/spec/formatting/binary/float_spec.rb +36 -0
- data/spec/formatting/binary/integer_spec.rb +76 -50
- data/spec/formatting/binary/string_spec.rb +91 -198
- data/spec/formatting/digest/string_spec.rb +5 -5
- data/spec/formatting/html/integer_spec.rb +6 -6
- data/spec/formatting/html/string_spec.rb +10 -10
- data/spec/formatting/http/integer_spec.rb +3 -3
- data/spec/formatting/http/string_spec.rb +5 -5
- data/spec/formatting/sql/string_spec.rb +21 -19
- data/spec/formatting/text/array_spec.rb +15 -15
- data/spec/formatting/text/string_spec.rb +58 -28
- data/spec/fuzzing/extensions/string_spec.rb +87 -0
- data/spec/fuzzing/fuzzer_spec.rb +109 -0
- data/spec/fuzzing/fuzzing_spec.rb +24 -0
- data/spec/fuzzing/mutator_spec.rb +112 -0
- data/spec/fuzzing/repeater_spec.rb +57 -0
- data/spec/fuzzing/template_spec.rb +54 -0
- data/spec/mixin_spec.rb +10 -12
- data/spec/network/dns_spec.rb +89 -23
- data/spec/network/ftp_spec.rb +81 -0
- data/spec/network/http/http_spec.rb +237 -144
- data/spec/network/http/proxy_spec.rb +37 -37
- data/spec/network/network_spec.rb +2 -2
- data/spec/network/proxy_spec.rb +121 -0
- data/spec/network/shared/unix_server.rb +31 -0
- data/spec/network/smtp/email_spec.rb +14 -14
- data/spec/network/ssl_spec.rb +53 -3
- data/spec/network/tcp/proxy_spec.rb +118 -0
- data/spec/network/tcp/tcp_spec.rb +316 -0
- data/spec/network/telnet_spec.rb +67 -0
- data/spec/network/udp/udp_spec.rb +298 -0
- data/spec/network/unix_spec.rb +182 -0
- data/spec/path_spec.rb +43 -18
- data/spec/spec_helper.rb +2 -3
- data/spec/support/inflector_spec.rb +4 -4
- data/spec/support_spec.rb +1 -1
- data/spec/templates/erb_spec.rb +3 -3
- data/spec/templates/template_spec.rb +10 -10
- data/spec/ui/shell_spec.rb +15 -15
- data/spec/wordlist_spec.rb +80 -19
- metadata +176 -121
- data/.gemtest +0 -0
- data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
- data/spec/fuzzing/string_spec.rb +0 -158
- data/spec/network/tcp_spec.rb +0 -247
- data/spec/network/udp_spec.rb +0 -248
@@ -8,40 +8,40 @@ describe Network::HTTP::Proxy do
|
|
8
8
|
it "should parse host-names" do
|
9
9
|
proxy = subject.parse('127.0.0.1')
|
10
10
|
|
11
|
-
proxy.host.
|
11
|
+
expect(proxy.host).to eq('127.0.0.1')
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should parse 'host:port' URLs" do
|
15
15
|
proxy = subject.parse('127.0.0.1:80')
|
16
16
|
|
17
|
-
proxy.host.
|
18
|
-
proxy.port.
|
17
|
+
expect(proxy.host).to eq('127.0.0.1')
|
18
|
+
expect(proxy.port).to eq(80)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should parse 'user@host:port' URLs" do
|
22
22
|
proxy = subject.parse('joe@127.0.0.1:80')
|
23
23
|
|
24
|
-
proxy.user.
|
25
|
-
proxy.host.
|
26
|
-
proxy.port.
|
24
|
+
expect(proxy.user).to eq('joe')
|
25
|
+
expect(proxy.host).to eq('127.0.0.1')
|
26
|
+
expect(proxy.port).to eq(80)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should prase 'user:password@host:port' URLs" do
|
30
30
|
proxy = subject.parse('joe:lol@127.0.0.1:80')
|
31
31
|
|
32
|
-
proxy.user.
|
33
|
-
proxy.password.
|
34
|
-
proxy.host.
|
35
|
-
proxy.port.
|
32
|
+
expect(proxy.user).to eq('joe')
|
33
|
+
expect(proxy.password).to eq('lol')
|
34
|
+
expect(proxy.host).to eq('127.0.0.1')
|
35
|
+
expect(proxy.port).to eq(80)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should ignore http:// prefixes when parsing proxy URLs" do
|
39
39
|
proxy = subject.parse('http://joe:lol@127.0.0.1:80')
|
40
40
|
|
41
|
-
proxy.user.
|
42
|
-
proxy.password.
|
43
|
-
proxy.host.
|
44
|
-
proxy.port.
|
41
|
+
expect(proxy.user).to eq('joe')
|
42
|
+
expect(proxy.password).to eq('lol')
|
43
|
+
expect(proxy.host).to eq('127.0.0.1')
|
44
|
+
expect(proxy.port).to eq(80)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -54,55 +54,55 @@ describe Network::HTTP::Proxy do
|
|
54
54
|
it "should accept Proxy objects" do
|
55
55
|
proxy = subject.new(:host => host, :port => port)
|
56
56
|
|
57
|
-
subject.create(proxy).
|
57
|
+
expect(subject.create(proxy)).to eq(proxy)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should accept URI::HTTP objects" do
|
61
61
|
url = URI::HTTP.build(:host => host, :port => port)
|
62
62
|
proxy = subject.create(url)
|
63
63
|
|
64
|
-
proxy.host.
|
65
|
-
proxy.port.
|
64
|
+
expect(proxy.host).to eq(host)
|
65
|
+
expect(proxy.port).to eq(port)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should accept Hash objects" do
|
69
69
|
hash = {:host => host, :port => port}
|
70
70
|
proxy = subject.create(hash)
|
71
71
|
|
72
|
-
proxy.host.
|
73
|
-
proxy.port.
|
72
|
+
expect(proxy.host).to eq(host)
|
73
|
+
expect(proxy.port).to eq(port)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should accept String objects" do
|
77
77
|
string = "#{host}:#{port}"
|
78
78
|
proxy = subject.create(string)
|
79
79
|
|
80
|
-
proxy.host.
|
81
|
-
proxy.port.
|
80
|
+
expect(proxy.host).to eq(host)
|
81
|
+
expect(proxy.port).to eq(port)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should accept nil" do
|
85
85
|
proxy = subject.create(nil)
|
86
86
|
|
87
|
-
proxy.
|
87
|
+
expect(proxy).not_to be_enabled
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should behave like a Hash" do
|
92
92
|
subject[:host] = 'example.com'
|
93
|
-
subject[:host].
|
93
|
+
expect(subject[:host]).to eq('example.com')
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should not have a host by default" do
|
97
|
-
subject.host.
|
97
|
+
expect(subject.host).to be_nil
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should not have a port by default" do
|
101
|
-
subject.port.
|
101
|
+
expect(subject.port).to be_nil
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should be disabled by default" do
|
105
|
-
subject.
|
105
|
+
expect(subject).not_to be_enabled
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should reset the host, port, user and password when disabled" do
|
@@ -113,10 +113,10 @@ describe Network::HTTP::Proxy do
|
|
113
113
|
|
114
114
|
subject.disable!
|
115
115
|
|
116
|
-
subject[:host].
|
117
|
-
subject[:port].
|
118
|
-
subject[:user].
|
119
|
-
subject[:password].
|
116
|
+
expect(subject[:host]).to be_nil
|
117
|
+
expect(subject[:port]).to be_nil
|
118
|
+
expect(subject[:user]).to be_nil
|
119
|
+
expect(subject[:password]).to be_nil
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should return a URI::HTTP representing the proxy" do
|
@@ -127,22 +127,22 @@ describe Network::HTTP::Proxy do
|
|
127
127
|
|
128
128
|
url = subject.url
|
129
129
|
|
130
|
-
url.host.
|
131
|
-
url.port.
|
132
|
-
url.user.
|
133
|
-
url.password.
|
130
|
+
expect(url.host).to eq('example.com')
|
131
|
+
expect(url.port).to eq(9001)
|
132
|
+
expect(url.user).to eq('joe')
|
133
|
+
expect(url.password).to eq('lol')
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should return nil when converting a disabled proxy to a URL" do
|
137
|
-
subject.url.
|
137
|
+
expect(subject.url).to be_nil
|
138
138
|
end
|
139
139
|
|
140
140
|
it "should return the host-name when converted to a String" do
|
141
141
|
subject[:host] = 'example.com'
|
142
|
-
subject.to_s.
|
142
|
+
expect(subject.to_s).to eq('example.com')
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should return an empty String when there is no host-name" do
|
146
|
-
subject.to_s.
|
146
|
+
expect(subject.to_s).to be_empty
|
147
147
|
end
|
148
148
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require 'ronin/network/network'
|
3
3
|
|
4
4
|
describe Network do
|
5
|
-
it "should determine our public facing IP Address" do
|
6
|
-
subject.ip.
|
5
|
+
it "should determine our public facing IP Address", :network do
|
6
|
+
expect(subject.ip).not_to be_nil
|
7
7
|
end
|
8
8
|
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ronin/network/proxy'
|
3
|
+
|
4
|
+
describe Network::Proxy do
|
5
|
+
let(:port) { 1337 }
|
6
|
+
let(:host) { '127.0.0.1' }
|
7
|
+
let(:server_host) { 'www.example.com' }
|
8
|
+
let(:server_port) { 80 }
|
9
|
+
|
10
|
+
let(:proxy) do
|
11
|
+
described_class.new(
|
12
|
+
:port => port,
|
13
|
+
:host => host,
|
14
|
+
:server => [server_host, server_port]
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { proxy }
|
19
|
+
|
20
|
+
describe "#initialize" do
|
21
|
+
it "should default host to '0.0.0.0'" do
|
22
|
+
proxy = described_class.new(
|
23
|
+
:port => port,
|
24
|
+
:server => [server_host, server_port]
|
25
|
+
)
|
26
|
+
|
27
|
+
expect(proxy.port).to eq(port)
|
28
|
+
expect(proxy.host).to eq('0.0.0.0')
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should allow setting both the host and port" do
|
32
|
+
proxy = described_class.new(
|
33
|
+
:port => port,
|
34
|
+
:host => host,
|
35
|
+
:server => [server_host, server_port]
|
36
|
+
)
|
37
|
+
|
38
|
+
expect(proxy.port).to eq(port)
|
39
|
+
expect(proxy.host).to eq(host)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should set the server_host and server_port" do
|
43
|
+
proxy = described_class.new(
|
44
|
+
:port => port,
|
45
|
+
:host => host,
|
46
|
+
:server => [server_host, server_port]
|
47
|
+
)
|
48
|
+
|
49
|
+
expect(proxy.server_host).to eq(server_host)
|
50
|
+
expect(proxy.server_port).to eq(server_port)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#on_data" do
|
55
|
+
it "should call on_client_data" do
|
56
|
+
expect(subject).to receive(:on_client_data)
|
57
|
+
|
58
|
+
subject.on_data { |client,server,data| }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should call on_server_data" do
|
62
|
+
expect(subject).to receive(:on_server_data)
|
63
|
+
|
64
|
+
subject.on_data { |client,server,data| }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "actions" do
|
69
|
+
describe "#ignore!" do
|
70
|
+
it "should throw the :ignore action" do
|
71
|
+
expect {
|
72
|
+
subject.ignore!
|
73
|
+
}.to throw_symbol(:action, :ignore)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#close!" do
|
78
|
+
it "should throw the :close action" do
|
79
|
+
expect {
|
80
|
+
subject.close!
|
81
|
+
}.to throw_symbol(:action, :close)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#reset!" do
|
86
|
+
it "should throw the :reset action" do
|
87
|
+
expect {
|
88
|
+
subject.reset!
|
89
|
+
}.to throw_symbol(:action, :reset)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#stop!" do
|
94
|
+
it "should throw the :stop action" do
|
95
|
+
expect {
|
96
|
+
subject.stop!
|
97
|
+
}.to throw_symbol(:action, :stop)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#to_s" do
|
103
|
+
subject { proxy.to_s }
|
104
|
+
|
105
|
+
it "should include the proxy host and port" do
|
106
|
+
expect(subject).to include("#{host}:#{port}")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should include the server host and port" do
|
110
|
+
expect(subject).to include("#{server_host}:#{server_port}")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#inspect" do
|
115
|
+
subject { proxy.inspect }
|
116
|
+
|
117
|
+
it "should include the output of #to_s" do
|
118
|
+
expect(subject).to include(proxy.to_s)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'socket'
|
6
|
+
|
7
|
+
shared_context "UNIX Server" do
|
8
|
+
def socket_path(name); File.join(Dir.tmpdir,name); end
|
9
|
+
|
10
|
+
let(:path) { socket_path('ronin_unix_server') }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@server = UNIXServer.new(path)
|
14
|
+
@server_thread = Thread.new do
|
15
|
+
socket = @server.accept
|
16
|
+
|
17
|
+
begin
|
18
|
+
socket.puts socket.readline
|
19
|
+
ensure
|
20
|
+
socket.close
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
@server_thread.kill
|
27
|
+
@server.close
|
28
|
+
|
29
|
+
FileUtils.rm(path)
|
30
|
+
end
|
31
|
+
end
|
@@ -8,27 +8,27 @@ describe Network::SMTP::Email do
|
|
8
8
|
it "should default 'date' to Time.now" do
|
9
9
|
email = Network::SMTP::Email.new
|
10
10
|
|
11
|
-
email.date.
|
11
|
+
expect(email.date).not_to be_nil
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should accept a String body" do
|
15
15
|
body = 'hello'
|
16
16
|
email = Network::SMTP::Email.new(:body => body)
|
17
17
|
|
18
|
-
email.body.
|
18
|
+
expect(email.body).to eq([body])
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should accept an Array body" do
|
22
22
|
body = ['hello', 'world']
|
23
23
|
email = Network::SMTP::Email.new(:body => body)
|
24
24
|
|
25
|
-
email.body.
|
25
|
+
expect(email.body).to eq(body)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should default 'body' to an empty Array" do
|
29
29
|
email = Network::SMTP::Email.new
|
30
30
|
|
31
|
-
email.body.
|
31
|
+
expect(email.body).to be_empty
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -38,39 +38,39 @@ describe Network::SMTP::Email do
|
|
38
38
|
it "should add the 'from'" do
|
39
39
|
subject.from = 'joe@example.com'
|
40
40
|
|
41
|
-
subject.to_s.
|
41
|
+
expect(subject.to_s).to include("From: joe@example.com\n\r")
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when formatting 'to'" do
|
45
45
|
it "should accept an Array of addresses" do
|
46
46
|
subject.to = ['alice@example.com', 'joe@example.com']
|
47
47
|
|
48
|
-
subject.to_s.
|
48
|
+
expect(subject.to_s).to include("To: alice@example.com, joe@example.com\n\r")
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should accept a String" do
|
52
52
|
subject.to = 'joe@example.com'
|
53
53
|
|
54
|
-
subject.to_s.
|
54
|
+
expect(subject.to_s).to include("To: joe@example.com\n\r")
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should add the 'subject'" do
|
59
59
|
subject.subject = 'Hello'
|
60
60
|
|
61
|
-
subject.to_s.
|
61
|
+
expect(subject.to_s).to include("Subject: Hello\n\r")
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should add the 'date'" do
|
65
65
|
subject.date = Date.parse('Sun Apr 24 17:22:55 PDT 2011')
|
66
66
|
|
67
|
-
subject.to_s.
|
67
|
+
expect(subject.to_s).to include("Date: #{subject.date}\n\r")
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should add the 'message_id'" do
|
71
71
|
subject.message_id = '1234'
|
72
72
|
|
73
|
-
subject.to_s.
|
73
|
+
expect(subject.to_s).to include("Message-Id: <#{subject.message_id}>\n\r")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should add additional headers" do
|
@@ -79,21 +79,21 @@ describe Network::SMTP::Email do
|
|
79
79
|
|
80
80
|
lines = subject.to_s.split("\n\r")
|
81
81
|
|
82
|
-
lines.
|
83
|
-
lines.
|
82
|
+
expect(lines).to include('X-Foo: Bar')
|
83
|
+
expect(lines).to include('X-Baz: Quix')
|
84
84
|
end
|
85
85
|
|
86
86
|
context "when formatting 'body'" do
|
87
87
|
it "should append each line with a CRLF" do
|
88
88
|
subject.body = ['hello', 'world']
|
89
89
|
|
90
|
-
subject.to_s.
|
90
|
+
expect(subject.to_s).to include("hello\n\rworld")
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should add a CRLF before the body" do
|
94
94
|
subject.body = ['hello', 'world']
|
95
95
|
|
96
|
-
subject.to_s.
|
96
|
+
expect(subject.to_s).to include("\n\rhello")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
data/spec/network/ssl_spec.rb
CHANGED
@@ -6,15 +6,65 @@ describe Network::SSL do
|
|
6
6
|
subject { Network::SSL::VERIFY }
|
7
7
|
|
8
8
|
it "should map verify mode names to OpenSSL VERIFY_* constants" do
|
9
|
-
subject[:peer].
|
9
|
+
expect(subject[:peer]).to eq(OpenSSL::SSL::VERIFY_PEER)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should default to VERIFY_NONE if no verify mode name is given" do
|
13
|
-
subject[nil].
|
13
|
+
expect(subject[nil]).to eq(OpenSSL::SSL::VERIFY_NONE)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should raise an exception for unknown verify modes" do
|
17
|
-
|
17
|
+
expect { subject[:foo_bar] }.to raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "helpers", :network do
|
22
|
+
let(:host) { 'github.com' }
|
23
|
+
let(:port) { 443 }
|
24
|
+
|
25
|
+
subject do
|
26
|
+
obj = Object.new
|
27
|
+
obj.extend described_class
|
28
|
+
obj
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#ssl_connect" do
|
32
|
+
it "should connect to an SSL protected port" do
|
33
|
+
expect {
|
34
|
+
subject.ssl_connect(host,port)
|
35
|
+
}.not_to raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return an OpenSSL::SSL::SSLSocket" do
|
39
|
+
socket = subject.ssl_connect(host,port)
|
40
|
+
|
41
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when a block is given" do
|
45
|
+
it "should yield the OpenSSL::SSL::SSLSocket" do
|
46
|
+
socket = nil
|
47
|
+
|
48
|
+
subject.ssl_connect(host,port) do |yielded_socket|
|
49
|
+
socket = yielded_socket
|
50
|
+
end
|
51
|
+
|
52
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#ssl_session" do
|
58
|
+
it "should open then close a OpenSSL::SSL::SSLSocket" do
|
59
|
+
socket = nil
|
60
|
+
|
61
|
+
subject.ssl_session(host,port) do |yielded_socket|
|
62
|
+
socket = yielded_socket
|
63
|
+
end
|
64
|
+
|
65
|
+
expect(socket).to be_kind_of(OpenSSL::SSL::SSLSocket)
|
66
|
+
expect(socket).to be_closed
|
67
|
+
end
|
18
68
|
end
|
19
69
|
end
|
20
70
|
end
|