ronin-support 0.1.0 → 0.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +24 -0
- data/Gemfile +9 -1
- data/README.md +6 -3
- data/gemspec.yml +3 -1
- data/lib/ronin/extensions.rb +2 -1
- data/lib/ronin/extensions/file.rb +4 -0
- data/lib/ronin/extensions/ip_addr.rb +8 -0
- data/lib/ronin/extensions/kernel.rb +2 -0
- data/lib/ronin/extensions/string.rb +50 -11
- data/lib/ronin/formatting/extensions/binary.rb +2 -0
- data/lib/ronin/formatting/extensions/binary/file.rb +12 -1
- data/lib/ronin/formatting/extensions/binary/integer.rb +6 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +20 -0
- data/lib/ronin/formatting/extensions/digest/file.rb +14 -0
- data/lib/ronin/formatting/extensions/digest/string.rb +8 -0
- data/lib/ronin/formatting/extensions/html.rb +21 -0
- data/lib/ronin/formatting/extensions/html/integer.rb +126 -0
- data/lib/ronin/formatting/extensions/html/string.rb +184 -0
- data/lib/ronin/formatting/extensions/http/integer.rb +7 -1
- data/lib/ronin/formatting/extensions/http/string.rb +10 -0
- data/lib/ronin/formatting/extensions/text.rb +2 -0
- data/lib/ronin/formatting/extensions/text/array.rb +10 -0
- data/lib/ronin/formatting/extensions/text/string.rb +44 -12
- data/lib/ronin/formatting/html.rb +20 -0
- data/lib/ronin/mixin.rb +89 -0
- data/lib/ronin/network/extensions/esmtp/net.rb +6 -0
- data/lib/ronin/network/extensions/http/net.rb +124 -51
- data/lib/ronin/network/extensions/imap/net.rb +4 -0
- data/lib/ronin/network/extensions/pop3/net.rb +4 -0
- data/lib/ronin/network/extensions/smtp/net.rb +73 -2
- data/lib/ronin/network/extensions/ssl/net.rb +4 -0
- data/lib/ronin/network/extensions/tcp/net.rb +16 -0
- data/lib/ronin/network/extensions/telnet/net.rb +4 -0
- data/lib/ronin/network/extensions/udp/net.rb +12 -0
- data/lib/ronin/network/http/http.rb +50 -29
- data/lib/ronin/network/http/proxy.rb +26 -0
- data/lib/ronin/network/imap.rb +4 -0
- data/lib/ronin/network/network.rb +2 -0
- data/lib/ronin/network/pop3.rb +4 -0
- data/lib/ronin/network/smtp/email.rb +43 -14
- data/lib/ronin/network/smtp/smtp.rb +6 -0
- data/lib/ronin/network/ssl.rb +2 -0
- data/lib/ronin/network/telnet.rb +16 -0
- data/lib/ronin/path.rb +6 -0
- data/lib/ronin/support/inflector.rb +3 -1
- data/lib/ronin/support/version.rb +1 -1
- data/lib/ronin/templates/erb.rb +4 -0
- data/lib/ronin/templates/template.rb +10 -0
- data/spec/extensions/string_spec.rb +4 -4
- data/spec/formatting/html/integer_spec.rb +66 -0
- data/spec/formatting/html/string_spec.rb +103 -0
- data/spec/formatting/http/string_spec.rb +1 -1
- data/spec/formatting/text/string_spec.rb +18 -66
- data/spec/mixin_spec.rb +53 -0
- data/spec/network/http/http_spec.rb +0 -7
- data/spec/network/http/proxy_spec.rb +2 -2
- data/spec/network/smtp/email_spec.rb +100 -0
- data/spec/path_spec.rb +13 -13
- data/spec/templates/helpers/data.rb +1 -1
- metadata +52 -33
@@ -58,6 +58,8 @@ module Net
|
|
58
58
|
# @return [Net::IMAP]
|
59
59
|
# The newly created IMAP session object.
|
60
60
|
#
|
61
|
+
# @api public
|
62
|
+
#
|
61
63
|
def Net.imap_connect(host,options={})
|
62
64
|
host = host.to_s
|
63
65
|
port = (options[:port] || Ronin::Network::IMAP.default_port)
|
@@ -109,6 +111,8 @@ module Net
|
|
109
111
|
#
|
110
112
|
# @see Net.imap_connect
|
111
113
|
#
|
114
|
+
# @api public
|
115
|
+
#
|
112
116
|
def Net.imap_session(host,options={})
|
113
117
|
session = Net.imap_connect(host,options)
|
114
118
|
|
@@ -49,6 +49,8 @@ module Net
|
|
49
49
|
# @return [Net::POP3]
|
50
50
|
# The newly created POP3 session.
|
51
51
|
#
|
52
|
+
# @api public
|
53
|
+
#
|
52
54
|
def Net.pop3_connect(host,options={})
|
53
55
|
host = host.to_s
|
54
56
|
port = (options[:port] || Ronin::Network::POP3.default_port)
|
@@ -79,6 +81,8 @@ module Net
|
|
79
81
|
#
|
80
82
|
# @return [nil]
|
81
83
|
#
|
84
|
+
# @api public
|
85
|
+
#
|
82
86
|
def Net.pop3_session(host,options={})
|
83
87
|
session = Net.pop3_connect(host,options)
|
84
88
|
|
@@ -17,16 +17,30 @@
|
|
17
17
|
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
+
require 'ronin/network/smtp/smtp'
|
20
21
|
require 'ronin/network/smtp/email'
|
21
22
|
|
22
23
|
require 'net/smtp'
|
23
24
|
|
24
25
|
module Net
|
25
26
|
#
|
26
|
-
#
|
27
|
+
# Creates a new email message.
|
28
|
+
#
|
29
|
+
# @param [Hash] options
|
30
|
+
# Additional options for the email.
|
31
|
+
#
|
32
|
+
# @yield [email]
|
33
|
+
# The given block will be passed the new email.
|
34
|
+
#
|
35
|
+
# @yieldparam [Ronin::Network::SMTP::Email] email
|
36
|
+
# The new email.
|
37
|
+
#
|
38
|
+
# @see Ronin::Network::SMTP::Email.new
|
39
|
+
#
|
40
|
+
# @api public
|
27
41
|
#
|
28
42
|
def Net.smtp_message(options={},&block)
|
29
|
-
Ronin::Network::SMTP.
|
43
|
+
Ronin::Network::SMTP::Email.new(options,&block)
|
30
44
|
end
|
31
45
|
|
32
46
|
#
|
@@ -63,6 +77,11 @@ module Net
|
|
63
77
|
# @return [Net::SMTP]
|
64
78
|
# The SMTP session.
|
65
79
|
#
|
80
|
+
# @example
|
81
|
+
# Net.smtp_connect('www.example.com', :user => 'joe')
|
82
|
+
#
|
83
|
+
# @api public
|
84
|
+
#
|
66
85
|
def Net.smtp_connect(host,options={})
|
67
86
|
host = host.to_s
|
68
87
|
port = (options[:port] || Ronin::Network::SMTP.default_port)
|
@@ -95,8 +114,15 @@ module Net
|
|
95
114
|
# @yieldparam [Net::SMTP] session
|
96
115
|
# The SMTP session.
|
97
116
|
#
|
117
|
+
# @example
|
118
|
+
# Net.smtp_session('www.example.com', :user => 'joe') do |smtp|
|
119
|
+
# # ...
|
120
|
+
# end
|
121
|
+
#
|
98
122
|
# @see Net.smtp_connect
|
99
123
|
#
|
124
|
+
# @api public
|
125
|
+
#
|
100
126
|
def Net.smtp_session(host,options={})
|
101
127
|
session = Net.smtp_connect(host,options)
|
102
128
|
|
@@ -105,4 +131,49 @@ module Net
|
|
105
131
|
session.finish
|
106
132
|
return nil
|
107
133
|
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# @since 0.2.0
|
137
|
+
#
|
138
|
+
# @param [String] host
|
139
|
+
# The host to connect to.
|
140
|
+
#
|
141
|
+
# @param [Hash] options
|
142
|
+
# Additional SMTP and Email options.
|
143
|
+
#
|
144
|
+
# @yield [email]
|
145
|
+
# The given block will be passed the new email to be sent.
|
146
|
+
#
|
147
|
+
# @yieldparam [Ronin::Network::SMTP::Email] email
|
148
|
+
# The new email to be sent.
|
149
|
+
#
|
150
|
+
# @see Net.smtp_session
|
151
|
+
#
|
152
|
+
# @example
|
153
|
+
# Net.smtp_send_message 'www.example.com', :to => 'joe@example.com',
|
154
|
+
# :from => 'eve@example.com',
|
155
|
+
# :subject => 'Hello',
|
156
|
+
# :message_id => 'XXXX',
|
157
|
+
# :body => 'Hello'
|
158
|
+
#
|
159
|
+
# @example Using the block.
|
160
|
+
# Net.smtp_send_message('www.example.com') do |email|
|
161
|
+
# email.to = 'joe@example.com'
|
162
|
+
# email.from 'eve@example.com'
|
163
|
+
# email.subject = 'Hello'
|
164
|
+
# email.message_id = 'XXXXXXXXXX'
|
165
|
+
# email.body << 'Hello!'
|
166
|
+
# end
|
167
|
+
#
|
168
|
+
# @since 0.2.0
|
169
|
+
#
|
170
|
+
# @api public
|
171
|
+
#
|
172
|
+
def Net.smtp_send_message(host,options={},&block)
|
173
|
+
email = Net.smtp_message(options,&block)
|
174
|
+
|
175
|
+
Net.smtp_session(host,options) do |smtp|
|
176
|
+
smtp.send_message(email.to_s, email.from, email.to)
|
177
|
+
end
|
178
|
+
end
|
108
179
|
end
|
@@ -65,6 +65,8 @@ module Net
|
|
65
65
|
# @example
|
66
66
|
# socket = Net.ssl_connect('twitter.com',443)
|
67
67
|
#
|
68
|
+
# @api public
|
69
|
+
#
|
68
70
|
def Net.ssl_connect(host,port,options={})
|
69
71
|
local_host = options[:local_host]
|
70
72
|
local_port = options[:local_port]
|
@@ -134,6 +136,8 @@ module Net
|
|
134
136
|
# sock.each_line { |line| puts line }
|
135
137
|
# end
|
136
138
|
#
|
139
|
+
# @api public
|
140
|
+
#
|
137
141
|
def Net.ssl_session(host,port)
|
138
142
|
ssl_socket = Net.ssl_connect(host,port)
|
139
143
|
|
@@ -54,6 +54,8 @@ module Net
|
|
54
54
|
# sock.close
|
55
55
|
# end
|
56
56
|
#
|
57
|
+
# @api public
|
58
|
+
#
|
57
59
|
def Net.tcp_connect(host,port,local_host=nil,local_port=nil)
|
58
60
|
host = host.to_s
|
59
61
|
local_host = if local_host
|
@@ -91,6 +93,8 @@ module Net
|
|
91
93
|
# @yieldparam [TCPsocket] socket
|
92
94
|
# The newly created TCPSocket object.
|
93
95
|
#
|
96
|
+
# @api public
|
97
|
+
#
|
94
98
|
def Net.tcp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
|
95
99
|
sock = Net.tcp_connect(host,port,local_host,local_port)
|
96
100
|
sock.write(data)
|
@@ -124,6 +128,8 @@ module Net
|
|
124
128
|
#
|
125
129
|
# @return [nil]
|
126
130
|
#
|
131
|
+
# @api public
|
132
|
+
#
|
127
133
|
def Net.tcp_session(host,port,local_host=nil,local_port=nil)
|
128
134
|
sock = Net.tcp_connect(host,port,local_host,local_port)
|
129
135
|
|
@@ -161,6 +167,8 @@ module Net
|
|
161
167
|
# Net.tcp_banner('pop.gmail.com',25)
|
162
168
|
# # => "220 mx.google.com ESMTP c20sm3096959rvf.1"
|
163
169
|
#
|
170
|
+
# @api public
|
171
|
+
#
|
164
172
|
def Net.tcp_banner(host,port,local_host=nil,local_port=nil)
|
165
173
|
banner = nil
|
166
174
|
|
@@ -199,6 +207,8 @@ module Net
|
|
199
207
|
# Net.tcp_send(buffer,'victim.com',80)
|
200
208
|
# # => true
|
201
209
|
#
|
210
|
+
# @api public
|
211
|
+
#
|
202
212
|
def Net.tcp_send(data,host,port,local_host=nil,local_port=nil)
|
203
213
|
Net.tcp_session(host,port,local_host,local_port) do |sock|
|
204
214
|
sock.write(data)
|
@@ -222,6 +232,8 @@ module Net
|
|
222
232
|
# @example
|
223
233
|
# Net.tcp_server(1337)
|
224
234
|
#
|
235
|
+
# @api public
|
236
|
+
#
|
225
237
|
def Net.tcp_server(port,host='0.0.0.0')
|
226
238
|
host = host.to_s
|
227
239
|
|
@@ -261,6 +273,8 @@ module Net
|
|
261
273
|
# client2.close
|
262
274
|
# end
|
263
275
|
#
|
276
|
+
# @api public
|
277
|
+
#
|
264
278
|
def Net.tcp_server_session(port,host='0.0.0.0',&block)
|
265
279
|
server = Net.tcp_server(port,host,&block)
|
266
280
|
server.close()
|
@@ -285,6 +299,8 @@ module Net
|
|
285
299
|
# client.puts 'lol'
|
286
300
|
# end
|
287
301
|
#
|
302
|
+
# @api public
|
303
|
+
#
|
288
304
|
def Net.tcp_single_server(port,host='0.0.0.0')
|
289
305
|
host = host.to_s
|
290
306
|
|
@@ -88,6 +88,8 @@ module Net
|
|
88
88
|
# Net.telnet_connect('towel.blinkenlights.nl')
|
89
89
|
# # => #<Net::Telnet: ...>
|
90
90
|
#
|
91
|
+
# @api public
|
92
|
+
#
|
91
93
|
def Net.telnet_connect(host,options={})
|
92
94
|
host = host.to_s
|
93
95
|
telnet_options = {}
|
@@ -143,6 +145,8 @@ module Net
|
|
143
145
|
#
|
144
146
|
# @see Net.telnet_session
|
145
147
|
#
|
148
|
+
# @api public
|
149
|
+
#
|
146
150
|
def Net.telnet_session(host,options={})
|
147
151
|
session = Net.telnet_connect(host,options)
|
148
152
|
|
@@ -53,6 +53,8 @@ module Net
|
|
53
53
|
# puts sock.readlines
|
54
54
|
# end
|
55
55
|
#
|
56
|
+
# @api public
|
57
|
+
#
|
56
58
|
def Net.udp_connect(host,port,local_host=nil,local_port=nil)
|
57
59
|
host = host.to_s
|
58
60
|
local_host = if local_host
|
@@ -93,6 +95,8 @@ module Net
|
|
93
95
|
# @return [UDPSocket]
|
94
96
|
# The newly created UDPSocket object.
|
95
97
|
#
|
98
|
+
# @api public
|
99
|
+
#
|
96
100
|
def Net.udp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
|
97
101
|
sock = Net.udp_connect(host,port,local_host,local_port)
|
98
102
|
sock.write(data)
|
@@ -126,6 +130,8 @@ module Net
|
|
126
130
|
#
|
127
131
|
# @return [nil]
|
128
132
|
#
|
133
|
+
# @api public
|
134
|
+
#
|
129
135
|
def Net.udp_session(host,port,local_host=nil,local_port=nil)
|
130
136
|
sock = Net.udp_connect(host,port,local_host,local_port)
|
131
137
|
|
@@ -159,6 +165,8 @@ module Net
|
|
159
165
|
# @return [String]
|
160
166
|
# The grabbed banner.
|
161
167
|
#
|
168
|
+
# @api public
|
169
|
+
#
|
162
170
|
def Net.udp_banner(host,port,local_host=nil,local_port=nil)
|
163
171
|
banner = nil
|
164
172
|
|
@@ -185,6 +193,8 @@ module Net
|
|
185
193
|
# @example
|
186
194
|
# Net.udp_server(1337)
|
187
195
|
#
|
196
|
+
# @api public
|
197
|
+
#
|
188
198
|
def Net.udp_server(port,host='0.0.0.0')
|
189
199
|
host = host.to_s
|
190
200
|
server = UDPServer.new(host,port)
|
@@ -216,6 +226,8 @@ module Net
|
|
216
226
|
# data, sender = server.recvfrom(1024)
|
217
227
|
# end
|
218
228
|
#
|
229
|
+
# @api public
|
230
|
+
#
|
219
231
|
def Net.udp_server_session(port,host='0.0.0.0',&block)
|
220
232
|
server = Net.udp_server(port,host,&block)
|
221
233
|
server.close()
|
@@ -37,6 +37,8 @@ module Ronin
|
|
37
37
|
# @see Proxy.new
|
38
38
|
# @see Proxy.parse
|
39
39
|
#
|
40
|
+
# @api public
|
41
|
+
#
|
40
42
|
def HTTP.proxy
|
41
43
|
@proxy ||= if ENV['HTTP_PROXY']
|
42
44
|
Proxy.parse(ENV['HTTP_PROXY'])
|
@@ -58,6 +60,8 @@ module Ronin
|
|
58
60
|
# The given proxy information was not a {Proxy}, `URI::HTTP`,
|
59
61
|
# `Hash` or {String}.
|
60
62
|
#
|
63
|
+
# @api public
|
64
|
+
#
|
61
65
|
def HTTP.proxy=(new_proxy)
|
62
66
|
@proxy = Proxy.create(new_proxy)
|
63
67
|
end
|
@@ -68,6 +72,8 @@ module Ronin
|
|
68
72
|
# @return [String, nil]
|
69
73
|
# The default Ronin HTTP User-Agent.
|
70
74
|
#
|
75
|
+
# @api public
|
76
|
+
#
|
71
77
|
def HTTP.user_agent
|
72
78
|
@user_agent ||= nil
|
73
79
|
end
|
@@ -78,6 +84,8 @@ module Ronin
|
|
78
84
|
# @param [String] agent
|
79
85
|
# The new User-Agent string to use.
|
80
86
|
#
|
87
|
+
# @api public
|
88
|
+
#
|
81
89
|
def HTTP.user_agent=(agent)
|
82
90
|
@user_agent = agent
|
83
91
|
end
|
@@ -85,39 +93,40 @@ module Ronin
|
|
85
93
|
#
|
86
94
|
# Expands the URL into options.
|
87
95
|
#
|
88
|
-
# @param [URI::HTTP, String
|
96
|
+
# @param [URI::HTTP, String] url
|
89
97
|
# The URL to expand.
|
90
98
|
#
|
91
99
|
# @return [Hash{Symbol => Object}]
|
92
100
|
# The options for the URL.
|
93
101
|
#
|
102
|
+
# @api private
|
103
|
+
#
|
94
104
|
def HTTP.expand_url(url)
|
95
|
-
new_options = {
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
105
|
+
new_options = {}
|
106
|
+
|
107
|
+
url = case url
|
108
|
+
when URI
|
109
|
+
url
|
110
|
+
when Hash
|
111
|
+
URI::HTTP.build(url)
|
112
|
+
else
|
113
|
+
URI(url.to_s)
|
114
|
+
end
|
115
|
+
|
116
|
+
new_options[:ssl] = {} if url.scheme == 'https'
|
117
|
+
|
118
|
+
new_options[:host] = url.host
|
119
|
+
new_options[:port] = url.port
|
120
|
+
|
121
|
+
new_options[:user] = url.user if url.user
|
122
|
+
new_options[:password] = url.password if url.password
|
123
|
+
|
124
|
+
new_options[:path] = unless url.path.empty?
|
125
|
+
url.path
|
126
|
+
else
|
127
|
+
'/'
|
128
|
+
end
|
129
|
+
new_options[:path] += "?#{url.query}" if url.query
|
121
130
|
|
122
131
|
return new_options
|
123
132
|
end
|
@@ -152,15 +161,21 @@ module Ronin
|
|
152
161
|
# @return [Hash]
|
153
162
|
# The expanded version of options.
|
154
163
|
#
|
164
|
+
# @api private
|
165
|
+
#
|
155
166
|
def HTTP.expand_options(options={})
|
156
167
|
new_options = options.dup
|
157
168
|
|
169
|
+
new_options[:port] ||= Net::HTTP.default_port
|
170
|
+
new_options[:path] ||= '/'
|
171
|
+
|
158
172
|
if new_options[:ssl] == true
|
159
173
|
new_options[:ssl] = {}
|
160
174
|
end
|
161
175
|
|
162
|
-
url = new_options.delete(:url)
|
163
|
-
|
176
|
+
if (url = new_options.delete(:url))
|
177
|
+
new_options.merge!(HTTP.expand_url(url))
|
178
|
+
end
|
164
179
|
|
165
180
|
new_options[:proxy] = if new_options.has_key?(:proxy)
|
166
181
|
HTTP::Proxy.create(new_options[:proxy])
|
@@ -181,6 +196,8 @@ module Ronin
|
|
181
196
|
# @return [String]
|
182
197
|
# The camel-case HTTP header name.
|
183
198
|
#
|
199
|
+
# @api private
|
200
|
+
#
|
184
201
|
def HTTP.header_name(name)
|
185
202
|
words = name.to_s.split(/[\s+_-]/)
|
186
203
|
|
@@ -198,6 +215,8 @@ module Ronin
|
|
198
215
|
# @return [Hash]
|
199
216
|
# The camel-cased HTTP headers created from the given options.
|
200
217
|
#
|
218
|
+
# @api private
|
219
|
+
#
|
201
220
|
def HTTP.headers(options={})
|
202
221
|
headers = {}
|
203
222
|
|
@@ -253,6 +272,8 @@ module Ronin
|
|
253
272
|
#
|
254
273
|
# @see HTTP.expand_options
|
255
274
|
#
|
275
|
+
# @api private
|
276
|
+
#
|
256
277
|
def HTTP.request(options={})
|
257
278
|
unless options[:method]
|
258
279
|
raise(ArgumentError,"the :method option must be specified")
|