ronin-support 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/ChangeLog.md +17 -0
  2. data/Gemfile +5 -5
  3. data/README.md +10 -9
  4. data/Rakefile +1 -0
  5. data/gemspec.yml +2 -2
  6. data/lib/ronin/formatting/extensions/binary/string.rb +1 -2
  7. data/lib/ronin/network.rb +1 -0
  8. data/lib/ronin/network/extensions.rb +2 -0
  9. data/lib/ronin/network/extensions/dns.rb +20 -0
  10. data/lib/ronin/network/extensions/dns/net.rb +24 -0
  11. data/lib/ronin/network/extensions/http/uri/http.rb +47 -45
  12. data/lib/ronin/network/http/http.rb +26 -25
  13. data/lib/ronin/network/mixins/dns.rb +1 -1
  14. data/lib/ronin/network/mixins/esmtp.rb +3 -1
  15. data/lib/ronin/network/mixins/http.rb +23 -21
  16. data/lib/ronin/network/mixins/imap.rb +3 -1
  17. data/lib/ronin/network/mixins/pop3.rb +3 -1
  18. data/lib/ronin/network/mixins/smtp.rb +3 -1
  19. data/lib/ronin/network/mixins/ssl.rb +5 -1
  20. data/lib/ronin/network/mixins/tcp.rb +17 -1
  21. data/lib/ronin/network/mixins/telnet.rb +3 -1
  22. data/lib/ronin/network/mixins/udp.rb +12 -0
  23. data/lib/ronin/network/smtp/smtp.rb +2 -2
  24. data/lib/ronin/network/ssl.rb +122 -117
  25. data/lib/ronin/network/tcp.rb +9 -9
  26. data/lib/ronin/network/telnet.rb +1 -1
  27. data/lib/ronin/network/udp.rb +7 -7
  28. data/lib/ronin/support/support.rb +1 -0
  29. data/lib/ronin/support/version.rb +1 -1
  30. data/lib/ronin/ui/output/output.rb +1 -1
  31. data/lib/ronin/ui/output/terminal/color.rb +5 -5
  32. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  33. data/spec/extensions/string_spec.rb +14 -12
  34. data/spec/network/dns_spec.rb +6 -6
  35. data/spec/network/tcp_spec.rb +25 -22
  36. data/spec/network/udp_spec.rb +24 -21
  37. metadata +25 -23
@@ -37,7 +37,7 @@ module Ronin
37
37
  # @api private
38
38
  #
39
39
  def self.write(data)
40
- STDOUT.write(data)
40
+ $stdout.write(data)
41
41
  end
42
42
 
43
43
  #
@@ -51,7 +51,7 @@ module Ronin
51
51
  # @api private
52
52
  #
53
53
  def self.print_info(message)
54
- puts "[-] #{message}"
54
+ $stdout.puts "[-] #{message}"
55
55
  end
56
56
 
57
57
  #
@@ -65,7 +65,7 @@ module Ronin
65
65
  # @api private
66
66
  #
67
67
  def self.print_debug(message)
68
- puts "[=] #{message}"
68
+ $stdout.puts "[=] #{message}"
69
69
  end
70
70
 
71
71
  #
@@ -79,7 +79,7 @@ module Ronin
79
79
  # @api private
80
80
  #
81
81
  def self.print_warning(message)
82
- puts "[*] #{message}"
82
+ $stdout.puts "[*] #{message}"
83
83
  end
84
84
 
85
85
  #
@@ -93,7 +93,7 @@ module Ronin
93
93
  # @api private
94
94
  #
95
95
  def self.print_error(message)
96
- puts "[!] #{message}"
96
+ $stdout.puts "[!] #{message}"
97
97
  end
98
98
 
99
99
  end
@@ -157,21 +157,23 @@ describe String do
157
157
  end
158
158
  end
159
159
 
160
- describe "#dump" do
161
- it "should dump printable strings" do
162
- "hello".dump.should == '"hello"'
163
- end
160
+ if RUBY_VERSION < '1.9'
161
+ describe "#dump" do
162
+ it "should dump printable strings" do
163
+ "hello".dump.should == '"hello"'
164
+ end
164
165
 
165
- it "should dump strings containing control characters" do
166
- "hello\n\b\a".dump.should == '"hello\n\b\a"'
167
- end
166
+ it "should dump strings containing control characters" do
167
+ "hello\n\b\a".dump.should == '"hello\n\b\a"'
168
+ end
168
169
 
169
- it "should dump strings containing non-printable characters" do
170
- "hello\x90\x05\xEF".dump.should == '"hello\x90\x05\xEF"'
171
- end
170
+ it "should dump strings containing non-printable characters" do
171
+ "hello\x90\x05\xEF".dump.should == '"hello\x90\x05\xEF"'
172
+ end
172
173
 
173
- it "should dump the string when calling the inspect method" do
174
- "hello\x90\x05\xEF".inspect.should == '"hello\x90\x05\xEF"'
174
+ it "should dump the string when calling the inspect method" do
175
+ "hello\x90\x05\xEF".inspect.should == '"hello\x90\x05\xEF"'
176
+ end
175
177
  end
176
178
  end
177
179
  end
@@ -82,7 +82,7 @@ describe Network::DNS do
82
82
 
83
83
  describe "#dns_lookup_all" do
84
84
  it "should lookup all addresses for a hostname" do
85
- subject.dns_lookup_all(hostname).should == [address]
85
+ subject.dns_lookup_all(hostname).should include(address)
86
86
  end
87
87
 
88
88
  it "should return an empty Array for unknown hostnames" do
@@ -90,11 +90,11 @@ describe Network::DNS do
90
90
  end
91
91
 
92
92
  it "should accept non-String hostnames" do
93
- subject.dns_lookup_all(hostname.to_sym).should == [address]
93
+ subject.dns_lookup_all(hostname.to_sym).should include(address)
94
94
  end
95
95
 
96
96
  it "should accept an additional nameserver argument" do
97
- subject.dns_lookup_all(hostname,server).should == [address]
97
+ subject.dns_lookup_all(hostname,server).should include(address)
98
98
  end
99
99
  end
100
100
 
@@ -118,7 +118,7 @@ describe Network::DNS do
118
118
 
119
119
  describe "#dns_reverse_lookup_all" do
120
120
  it "should lookup all addresses for a hostname" do
121
- subject.dns_reverse_lookup_all(address).should == [reverse_hostname]
121
+ subject.dns_reverse_lookup_all(address).should include(reverse_hostname)
122
122
  end
123
123
 
124
124
  it "should return an empty Array for unknown hostnames" do
@@ -126,11 +126,11 @@ describe Network::DNS do
126
126
  end
127
127
 
128
128
  it "should accept non-String addresses" do
129
- subject.dns_reverse_lookup_all(IPAddr.new(address)).should == [reverse_hostname]
129
+ subject.dns_reverse_lookup_all(IPAddr.new(address)).should include(reverse_hostname)
130
130
  end
131
131
 
132
132
  it "should accept an additional nameserver argument" do
133
- subject.dns_reverse_lookup_all(address,server).should == [reverse_hostname]
133
+ subject.dns_reverse_lookup_all(address,server).should include(reverse_hostname)
134
134
  end
135
135
  end
136
136
  end
@@ -30,10 +30,10 @@ describe Network::TCP do
30
30
  end
31
31
 
32
32
  it "should bind to a local host and port" do
33
- socket = subject.tcp_connect(host,port,nil,local_port)
33
+ socket = subject.tcp_connect(host,port,nil,local_port)
34
+ bound_port = socket.addr[1]
34
35
 
35
- local_address = socket.local_address
36
- local_address.ip_port.should == local_port
36
+ bound_port.should == local_port
37
37
 
38
38
  socket.close
39
39
  end
@@ -65,10 +65,10 @@ describe Network::TCP do
65
65
  end
66
66
 
67
67
  it "should bind to a local host and port" do
68
- socket = subject.tcp_connect_and_send(data,host,port,nil,local_port)
68
+ socket = subject.tcp_connect_and_send(data,host,port,nil,local_port)
69
+ bound_port = socket.addr[1]
69
70
 
70
- local_address = socket.local_address
71
- local_address.ip_port.should == local_port
71
+ bound_port.should == local_port
72
72
 
73
73
  socket.close
74
74
  end
@@ -102,13 +102,13 @@ describe Network::TCP do
102
102
  end
103
103
 
104
104
  it "should bind to a local host and port" do
105
- local_address = nil
105
+ bound_port = nil
106
106
 
107
107
  subject.tcp_session(host,port,nil,local_port) do |socket|
108
- local_address = socket.local_address
108
+ bound_port = socket.addr[1]
109
109
  end
110
110
 
111
- local_address.ip_port.should == local_port
111
+ bound_port.should == local_port
112
112
  end
113
113
  end
114
114
 
@@ -142,8 +142,8 @@ describe Network::TCP do
142
142
  end
143
143
 
144
144
  describe "#tcp_send" do
145
- let(:server) { TCPServer.new(server_host,nil) }
146
- let(:server_port) { server.local_address.ip_port }
145
+ let(:server) { TCPServer.new(server_host,0) }
146
+ let(:server_port) { server.addr[1] }
147
147
 
148
148
  let(:data) { "hello\n" }
149
149
  let(:local_port) { 1024 + rand(65535 - 1024) }
@@ -164,10 +164,10 @@ describe Network::TCP do
164
164
  it "should bind to a local host and port" do
165
165
  subject.tcp_send(data,server_host,server_port,nil,local_port)
166
166
 
167
- client = server.accept
167
+ client = server.accept
168
+ client_port = client.peeraddr[1]
168
169
 
169
- client_address = client.remote_address
170
- client_address.ip_port.should == local_port
170
+ client_port.should == local_port
171
171
 
172
172
  client.close
173
173
  end
@@ -186,11 +186,12 @@ describe Network::TCP do
186
186
  end
187
187
 
188
188
  it "should bind to a specific port and host" do
189
- server = subject.tcp_server(server_port,server_host)
189
+ server = subject.tcp_server(server_port,server_host)
190
+ bound_host = server.addr[3]
191
+ bound_port = server.addr[1]
190
192
 
191
- local_address = server.local_address
192
- local_address.ip_address.should == server_ip
193
- local_address.ip_port.should == server_port
193
+ bound_host.should == server_ip
194
+ bound_port.should == server_port
194
195
 
195
196
  server.close
196
197
  end
@@ -224,14 +225,16 @@ describe Network::TCP do
224
225
  end
225
226
 
226
227
  it "should bind to a specific port and host" do
227
- local_address = nil
228
+ bound_host = nil
229
+ bound_port = nil
228
230
 
229
231
  subject.tcp_server_session(server_port,server_host) do |yielded_server|
230
- local_address = yielded_server.local_address
232
+ bound_host = yielded_server.addr[3]
233
+ bound_port = yielded_server.addr[1]
231
234
  end
232
235
 
233
- local_address.ip_address.should == server_ip
234
- local_address.ip_port.should == server_port
236
+ bound_host.should == server_ip
237
+ bound_port.should == server_port
235
238
  end
236
239
  end
237
240
 
@@ -29,11 +29,11 @@ describe Network::UDP do
29
29
  socket.close
30
30
  end
31
31
 
32
- it "should bind to a local host and port" do
33
- socket = subject.udp_connect(host,port,nil,local_port)
32
+ it "should bind to a local port" do
33
+ socket = subject.udp_connect(host,port,nil,local_port)
34
+ bound_port = socket.addr[1]
34
35
 
35
- local_address = socket.local_address
36
- local_address.ip_port.should == local_port
36
+ bound_port.should == local_port
37
37
 
38
38
  socket.close
39
39
  end
@@ -65,11 +65,11 @@ describe Network::UDP do
65
65
  socket.close
66
66
  end
67
67
 
68
- it "should bind to a local host and port" do
69
- socket = subject.udp_connect_and_send(data,host,port,nil,local_port)
68
+ it "should bind to a local port" do
69
+ socket = subject.udp_connect_and_send(data,host,port,nil,local_port)
70
+ bound_port = socket.addr[1]
70
71
 
71
- local_address = socket.local_address
72
- local_address.ip_port.should == local_port
72
+ bound_port.should == local_port
73
73
 
74
74
  socket.close
75
75
  end
@@ -104,13 +104,13 @@ describe Network::UDP do
104
104
  end
105
105
 
106
106
  it "should bind to a local host and port" do
107
- local_address = nil
107
+ bound_port = nil
108
108
 
109
109
  subject.udp_session(host,port,nil,local_port) do |socket|
110
- local_address = socket.local_address
110
+ bound_port = socket.addr[1]
111
111
  end
112
112
 
113
- local_address.ip_port.should == local_port
113
+ bound_port.should == local_port
114
114
  end
115
115
  end
116
116
 
@@ -148,10 +148,10 @@ describe Network::UDP do
148
148
  describe "#udp_send" do
149
149
  let(:server) do
150
150
  socket = UDPSocket.new
151
- socket.bind(server_host,nil)
151
+ socket.bind(server_host,0)
152
152
  socket
153
153
  end
154
- let(:server_port) { server.local_address.ip_port }
154
+ let(:server_port) { server.addr[1] }
155
155
 
156
156
  let(:data) { "hello\n" }
157
157
  let(:local_port) { 1024 + rand(65535 - 1024) }
@@ -189,11 +189,12 @@ describe Network::UDP do
189
189
  end
190
190
 
191
191
  it "should bind to a specific port and host" do
192
- server = subject.udp_server(server_port,server_host)
192
+ server = subject.udp_server(server_port,server_host)
193
+ bound_host = server.addr[3]
194
+ bound_port = server.addr[1]
193
195
 
194
- local_address = server.local_address
195
- local_address.ip_address.should == server_ip
196
- local_address.ip_port.should == server_port
196
+ bound_host.should == server_ip
197
+ bound_port.should == server_port
197
198
 
198
199
  server.close
199
200
  end
@@ -227,14 +228,16 @@ describe Network::UDP do
227
228
  end
228
229
 
229
230
  it "should bind to a specific port and host" do
230
- local_address = nil
231
+ bound_host = nil
232
+ bound_port = nil
231
233
 
232
234
  subject.udp_server_session(server_port,server_host) do |yielded_server|
233
- local_address = yielded_server.local_address
235
+ bound_host = yielded_server.addr[3]
236
+ bound_port = yielded_server.addr[1]
234
237
  end
235
238
 
236
- local_address.ip_address.should == server_ip
237
- local_address.ip_port.should == server_port
239
+ bound_host.should == server_ip
240
+ bound_port.should == server_port
238
241
  end
239
242
  end
240
243
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ronin-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-12 00:00:00.000000000 Z
12
+ date: 2012-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chars
16
- requirement: &21873340 !ruby/object:Gem::Requirement
16
+ requirement: &17665600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21873340
24
+ version_requirements: *17665600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hexdump
27
- requirement: &21872300 !ruby/object:Gem::Requirement
27
+ requirement: &17664640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21872300
35
+ version_requirements: *17664640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: combinatorics
38
- requirement: &21871660 !ruby/object:Gem::Requirement
38
+ requirement: &17663420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *21871660
46
+ version_requirements: *17663420
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: uri-query_params
49
- requirement: &21837140 !ruby/object:Gem::Requirement
49
+ requirement: &17646180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.6'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *21837140
57
+ version_requirements: *17646180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: data_paths
60
- requirement: &21834740 !ruby/object:Gem::Requirement
60
+ requirement: &17645620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0.3'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *21834740
68
+ version_requirements: *17645620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parameters
71
- requirement: &21831580 !ruby/object:Gem::Requirement
71
+ requirement: &17645080 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.4'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *21831580
79
+ version_requirements: *17645080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: bundler
82
- requirement: &21758280 !ruby/object:Gem::Requirement
82
+ requirement: &17644240 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,29 +87,29 @@ dependencies:
87
87
  version: '1.0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *21758280
90
+ version_requirements: *17644240
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: yard
93
- requirement: &21752700 !ruby/object:Gem::Requirement
93
+ requirement: &17643400 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: 0.7.0
98
+ version: '0.7'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *21752700
101
+ version_requirements: *17643400
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: yard-parameters
104
- requirement: &21749860 !ruby/object:Gem::Requirement
104
+ requirement: &17642480 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 0.1.0
109
+ version: '0.1'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *21749860
112
+ version_requirements: *17642480
113
113
  description: Ronin Support is a support library for Ronin. Ronin Support contains
114
114
  many of the convenience methods used by Ronin and additional libraries.
115
115
  email: postmodern.mod3@gmail.com
@@ -173,6 +173,8 @@ files:
173
173
  - lib/ronin/network/dns.rb
174
174
  - lib/ronin/network/esmtp.rb
175
175
  - lib/ronin/network/extensions.rb
176
+ - lib/ronin/network/extensions/dns.rb
177
+ - lib/ronin/network/extensions/dns/net.rb
176
178
  - lib/ronin/network/extensions/esmtp.rb
177
179
  - lib/ronin/network/extensions/esmtp/net.rb
178
180
  - lib/ronin/network/extensions/http.rb
@@ -322,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
324
  version: '0'
323
325
  requirements: []
324
326
  rubyforge_project:
325
- rubygems_version: 1.8.16
327
+ rubygems_version: 1.8.15
326
328
  signing_key:
327
329
  specification_version: 3
328
330
  summary: A support library for Ronin.