ronin-support 0.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +504 -0
- data/ChangeLog.md +4 -0
- data/Gemfile +23 -0
- data/README.md +98 -0
- data/Rakefile +29 -0
- data/gemspec.yml +20 -0
- data/lib/ronin/extensions.rb +28 -0
- data/lib/ronin/extensions/file.rb +63 -0
- data/lib/ronin/extensions/ip_addr.rb +220 -0
- data/lib/ronin/extensions/kernel.rb +45 -0
- data/lib/ronin/extensions/meta.rb +22 -0
- data/lib/ronin/extensions/meta/object.rb +24 -0
- data/lib/ronin/extensions/string.rb +200 -0
- data/lib/ronin/formatting.rb +26 -0
- data/lib/ronin/formatting/binary.rb +22 -0
- data/lib/ronin/formatting/digest.rb +22 -0
- data/lib/ronin/formatting/extensions.rb +25 -0
- data/lib/ronin/formatting/extensions/binary.rb +24 -0
- data/lib/ronin/formatting/extensions/binary/file.rb +35 -0
- data/lib/ronin/formatting/extensions/binary/integer.rb +147 -0
- data/lib/ronin/formatting/extensions/binary/string.rb +363 -0
- data/lib/ronin/formatting/extensions/digest.rb +23 -0
- data/lib/ronin/formatting/extensions/digest/file.rb +117 -0
- data/lib/ronin/formatting/extensions/digest/string.rb +80 -0
- data/lib/ronin/formatting/extensions/http.rb +23 -0
- data/lib/ronin/formatting/extensions/http/integer.rb +57 -0
- data/lib/ronin/formatting/extensions/http/string.rb +102 -0
- data/lib/ronin/formatting/extensions/text.rb +23 -0
- data/lib/ronin/formatting/extensions/text/array.rb +125 -0
- data/lib/ronin/formatting/extensions/text/string.rb +206 -0
- data/lib/ronin/formatting/http.rb +22 -0
- data/lib/ronin/formatting/text.rb +22 -0
- data/lib/ronin/network.rb +29 -0
- data/lib/ronin/network/esmtp.rb +22 -0
- data/lib/ronin/network/extensions.rb +29 -0
- data/lib/ronin/network/extensions/esmtp.rb +22 -0
- data/lib/ronin/network/extensions/esmtp/net.rb +100 -0
- data/lib/ronin/network/extensions/http.rb +22 -0
- data/lib/ronin/network/extensions/http/net.rb +661 -0
- data/lib/ronin/network/extensions/imap.rb +22 -0
- data/lib/ronin/network/extensions/imap/net.rb +124 -0
- data/lib/ronin/network/extensions/pop3.rb +22 -0
- data/lib/ronin/network/extensions/pop3/net.rb +92 -0
- data/lib/ronin/network/extensions/smtp.rb +22 -0
- data/lib/ronin/network/extensions/smtp/net.rb +110 -0
- data/lib/ronin/network/extensions/ssl.rb +22 -0
- data/lib/ronin/network/extensions/ssl/net.rb +147 -0
- data/lib/ronin/network/extensions/tcp.rb +22 -0
- data/lib/ronin/network/extensions/tcp/net.rb +304 -0
- data/lib/ronin/network/extensions/telnet.rb +22 -0
- data/lib/ronin/network/extensions/telnet/net.rb +156 -0
- data/lib/ronin/network/extensions/udp.rb +22 -0
- data/lib/ronin/network/extensions/udp/net.rb +226 -0
- data/lib/ronin/network/http.rb +24 -0
- data/lib/ronin/network/http/exceptions.rb +22 -0
- data/lib/ronin/network/http/exceptions/unknown_request.rb +29 -0
- data/lib/ronin/network/http/http.rb +290 -0
- data/lib/ronin/network/http/proxy.rb +307 -0
- data/lib/ronin/network/imap.rb +49 -0
- data/lib/ronin/network/network.rb +41 -0
- data/lib/ronin/network/pop3.rb +49 -0
- data/lib/ronin/network/smtp.rb +24 -0
- data/lib/ronin/network/smtp/email.rb +143 -0
- data/lib/ronin/network/smtp/smtp.rb +68 -0
- data/lib/ronin/network/ssl.rb +47 -0
- data/lib/ronin/network/tcp.rb +22 -0
- data/lib/ronin/network/telnet.rb +109 -0
- data/lib/ronin/network/udp.rb +22 -0
- data/lib/ronin/path.rb +132 -0
- data/lib/ronin/support.rb +28 -0
- data/lib/ronin/support/inflector.rb +40 -0
- data/lib/ronin/support/version.rb +27 -0
- data/lib/ronin/templates.rb +23 -0
- data/lib/ronin/templates/erb.rb +75 -0
- data/lib/ronin/templates/template.rb +161 -0
- data/ronin-support.gemspec +10 -0
- data/spec/extensions/file_spec.rb +24 -0
- data/spec/extensions/ip_addr_spec.rb +171 -0
- data/spec/extensions/kernel_spec.rb +30 -0
- data/spec/extensions/string_spec.rb +177 -0
- data/spec/formatting/binary/helpers/hexdumps.rb +16 -0
- data/spec/formatting/binary/helpers/hexdumps/ascii.bin +0 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +6 -0
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +17 -0
- data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +6 -0
- data/spec/formatting/binary/helpers/hexdumps/repeated.bin +1 -0
- data/spec/formatting/binary/integer_spec.rb +140 -0
- data/spec/formatting/binary/string_spec.rb +306 -0
- data/spec/formatting/digest/string_spec.rb +82 -0
- data/spec/formatting/http/integer_spec.rb +42 -0
- data/spec/formatting/http/string_spec.rb +76 -0
- data/spec/formatting/text/array_spec.rb +105 -0
- data/spec/formatting/text/string_spec.rb +180 -0
- data/spec/network/http/http_spec.rb +280 -0
- data/spec/network/http/proxy_spec.rb +150 -0
- data/spec/network/network_spec.rb +8 -0
- data/spec/network/ssl_spec.rb +14 -0
- data/spec/path_spec.rb +84 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support_spec.rb +8 -0
- data/spec/templates/classes/example_erb.rb +11 -0
- data/spec/templates/classes/example_template.rb +35 -0
- data/spec/templates/erb_spec.rb +21 -0
- data/spec/templates/helpers/data.rb +9 -0
- data/spec/templates/helpers/data/includes/_relative.erb +1 -0
- data/spec/templates/helpers/data/templates/example.erb +1 -0
- data/spec/templates/template_spec.rb +54 -0
- metadata +286 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/extensions/imap/net'
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/imap'
|
23
|
+
require 'ronin/network/ssl'
|
24
|
+
|
25
|
+
require 'net/imap'
|
26
|
+
|
27
|
+
module Net
|
28
|
+
#
|
29
|
+
# Creates a connection to the IMAP server.
|
30
|
+
#
|
31
|
+
# @param [String] host
|
32
|
+
# The host to connect to.
|
33
|
+
#
|
34
|
+
# @param [Hash] options
|
35
|
+
# Additional options.
|
36
|
+
#
|
37
|
+
# @option options [Integer] :port (IMAP.default_port)
|
38
|
+
# The port the IMAP server is running on.
|
39
|
+
#
|
40
|
+
# @option options [String] :certs
|
41
|
+
# The path to the file containing CA certs of the server.
|
42
|
+
#
|
43
|
+
# @option options [Symbol] :auth
|
44
|
+
# The type of authentication to perform when connecting to the server.
|
45
|
+
# May be either `:login` or `:cram_md5`.
|
46
|
+
#
|
47
|
+
# @option options [String] :user
|
48
|
+
# The user to authenticate as when connecting to the server.
|
49
|
+
#
|
50
|
+
# @option options [String] :password
|
51
|
+
# The password to authenticate with when connecting to the server.
|
52
|
+
#
|
53
|
+
# @yield [session]
|
54
|
+
# If a block is given, it will be passed the newly created IMAP
|
55
|
+
# session.
|
56
|
+
#
|
57
|
+
# @yieldparam [Net::IMAP] session
|
58
|
+
# The newly created IMAP session object.
|
59
|
+
#
|
60
|
+
# @return [Net::IMAP]
|
61
|
+
# The newly created IMAP session object.
|
62
|
+
#
|
63
|
+
def Net.imap_connect(host,options={})
|
64
|
+
host = host.to_s
|
65
|
+
port = (options[:port] || Ronin::Network::IMAP.default_port)
|
66
|
+
certs = options[:certs]
|
67
|
+
auth = options[:auth]
|
68
|
+
user = options[:user]
|
69
|
+
passwd = options[:password]
|
70
|
+
|
71
|
+
if options[:ssl]
|
72
|
+
ssl = true
|
73
|
+
ssl_certs = options[:ssl][:certs]
|
74
|
+
ssl_verify = Ronin::Network::SSL.verify(options[:ssl][:verify])
|
75
|
+
else
|
76
|
+
ssl = false
|
77
|
+
ssl_verify = false
|
78
|
+
end
|
79
|
+
|
80
|
+
session = Net::IMAP.new(host,port,ssl,ssl_certs,ssl_verify)
|
81
|
+
|
82
|
+
if user
|
83
|
+
if auth == :cram_md5
|
84
|
+
session.authenticate('CRAM-MD5',user,passwd)
|
85
|
+
else
|
86
|
+
session.authenticate('LOGIN',user,passwd)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
yield session if block_given?
|
91
|
+
return session
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Starts an IMAP session with the IMAP server.
|
96
|
+
#
|
97
|
+
# @param [String] host
|
98
|
+
# The host to connect to.
|
99
|
+
#
|
100
|
+
# @param [Hash] options
|
101
|
+
# Additional options.
|
102
|
+
#
|
103
|
+
# @yield [session]
|
104
|
+
# If a block is given, it will be passed the newly created IMAP
|
105
|
+
# session. After the block has returned, the session will be closed.
|
106
|
+
#
|
107
|
+
# @yieldparam [Net::IMAP] session
|
108
|
+
# The newly created IMAP session object.
|
109
|
+
#
|
110
|
+
# @return [nil]
|
111
|
+
#
|
112
|
+
# @see Net.imap_connect
|
113
|
+
#
|
114
|
+
def Net.imap_session(host,options={})
|
115
|
+
session = Net.imap_connect(host,options)
|
116
|
+
|
117
|
+
yield session if block_given?
|
118
|
+
|
119
|
+
session.logout if options[:user]
|
120
|
+
session.close
|
121
|
+
session.disconnect
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/extensions/pop3/net'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/pop3'
|
23
|
+
|
24
|
+
require 'net/pop'
|
25
|
+
|
26
|
+
module Net
|
27
|
+
#
|
28
|
+
# Creates a connection to the POP3 server.
|
29
|
+
#
|
30
|
+
# @param [String] host
|
31
|
+
# The host to connect to.
|
32
|
+
#
|
33
|
+
# @param [Hash] options
|
34
|
+
# Additional options.
|
35
|
+
#
|
36
|
+
# @option options [Integer] :port (Ronin::Network::POP3.default_port)
|
37
|
+
# The port the POP3 server is running on.
|
38
|
+
#
|
39
|
+
# @option options [String] :user
|
40
|
+
# The user to authenticate with when connecting to the POP3 server.
|
41
|
+
#
|
42
|
+
# @option options [String] :password
|
43
|
+
# The password to authenticate with when connecting to the POP3 server.
|
44
|
+
#
|
45
|
+
# @yield [session]
|
46
|
+
# If a block is given, it will be passed the newly created POP3 session.
|
47
|
+
#
|
48
|
+
# @yieldparam [Net::POP3] session
|
49
|
+
# The newly created POP3 session.
|
50
|
+
#
|
51
|
+
# @return [Net::POP3]
|
52
|
+
# The newly created POP3 session.
|
53
|
+
#
|
54
|
+
def Net.pop3_connect(host,options={})
|
55
|
+
host = host.to_s
|
56
|
+
port = (options[:port] || Ronin::Network::POP3.default_port)
|
57
|
+
user = options[:user]
|
58
|
+
password = options[:password]
|
59
|
+
|
60
|
+
session = Net::POP3.start(host,port,user,password)
|
61
|
+
|
62
|
+
yield session if block_given?
|
63
|
+
return session
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Starts a session with the POP3 server.
|
68
|
+
#
|
69
|
+
# @param [String] host
|
70
|
+
# The host to connect to.
|
71
|
+
#
|
72
|
+
# @param [Hash] options
|
73
|
+
# Additional options.
|
74
|
+
#
|
75
|
+
# @yield [session]
|
76
|
+
# If a block is given, it will be passed the newly created POP3 session.
|
77
|
+
# After the block has returned, the session will be closed.
|
78
|
+
#
|
79
|
+
# @yieldparam [Net::POP3] session
|
80
|
+
# The newly created POP3 session.
|
81
|
+
#
|
82
|
+
# @return [nil]
|
83
|
+
#
|
84
|
+
def Net.pop3_session(host,options={})
|
85
|
+
session = Net.pop3_connect(host,options)
|
86
|
+
|
87
|
+
yield session if block_given?
|
88
|
+
|
89
|
+
session.finish
|
90
|
+
return nil
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/extensions/smtp/net'
|
@@ -0,0 +1,110 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/smtp/email'
|
23
|
+
|
24
|
+
require 'net/smtp'
|
25
|
+
|
26
|
+
module Net
|
27
|
+
#
|
28
|
+
# @see Ronin::Network::SMTP.message
|
29
|
+
#
|
30
|
+
def Net.smtp_message(options={},&block)
|
31
|
+
Ronin::Network::SMTP.message(options,&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Creates a connection to the SMTP server.
|
36
|
+
#
|
37
|
+
# @param [String] host
|
38
|
+
# The host to connect to.
|
39
|
+
#
|
40
|
+
# @param [Hash] options
|
41
|
+
# Additional options.
|
42
|
+
#
|
43
|
+
# @option options [Integer] :port (Ronin::Network::SMTP.default_port)
|
44
|
+
# The port to connect to.
|
45
|
+
#
|
46
|
+
# @option options [String] :helo
|
47
|
+
# The HELO domain.
|
48
|
+
#
|
49
|
+
# @option options [Symbol] :auth
|
50
|
+
# The type of authentication to use. Can be either `:login`, `:plain`,
|
51
|
+
# or `:cram_md5`.
|
52
|
+
#
|
53
|
+
# @option options [String] :user
|
54
|
+
# The user-name to authenticate with.
|
55
|
+
#
|
56
|
+
# @option options [String] :password
|
57
|
+
# The password to authenticate with.
|
58
|
+
#
|
59
|
+
# @yield [session]
|
60
|
+
# If a block is given, it will be passed an SMTP session object.
|
61
|
+
#
|
62
|
+
# @yieldparam [Net::SMTP] session
|
63
|
+
# The SMTP session.
|
64
|
+
#
|
65
|
+
# @return [Net::SMTP]
|
66
|
+
# The SMTP session.
|
67
|
+
#
|
68
|
+
def Net.smtp_connect(host,options={})
|
69
|
+
host = host.to_s
|
70
|
+
port = (options[:port] || Ronin::Network::SMTP.default_port)
|
71
|
+
|
72
|
+
helo = options[:helo]
|
73
|
+
|
74
|
+
auth = options[:auth]
|
75
|
+
user = options[:user]
|
76
|
+
password = options[:password]
|
77
|
+
|
78
|
+
session = Net::SMTP.start(host,port,helo,user,password,auth)
|
79
|
+
|
80
|
+
yield session if block_given?
|
81
|
+
return session
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Starts a session with the SMTP server.
|
86
|
+
#
|
87
|
+
# @param [String] host
|
88
|
+
# The host to connect to.
|
89
|
+
#
|
90
|
+
# @param [Hash] options
|
91
|
+
# Additional options.
|
92
|
+
#
|
93
|
+
# @yield [session]
|
94
|
+
# If a block is given, it will be passed an SMTP session object.
|
95
|
+
# After the block has returned, the session will be closed.
|
96
|
+
#
|
97
|
+
# @yieldparam [Net::SMTP] session
|
98
|
+
# The SMTP session.
|
99
|
+
#
|
100
|
+
# @see Net.smtp_connect
|
101
|
+
#
|
102
|
+
def Net.smtp_session(host,options={})
|
103
|
+
session = Net.smtp_connect(host,options)
|
104
|
+
|
105
|
+
yield session if block_given?
|
106
|
+
|
107
|
+
session.finish
|
108
|
+
return nil
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/extensions/ssl/net'
|
@@ -0,0 +1,147 @@
|
|
1
|
+
#
|
2
|
+
# Ronin - A Ruby platform for exploit development and security research.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2006-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License as published by the Free Software Foundation; either
|
9
|
+
# version 2.1 of the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
# Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with this library; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
19
|
+
# Boston, MA 02110-1301 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'ronin/network/extensions/tcp/net'
|
23
|
+
require 'ronin/network/ssl'
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'openssl'
|
27
|
+
rescue ::LoadError
|
28
|
+
end
|
29
|
+
|
30
|
+
module Net
|
31
|
+
#
|
32
|
+
# Establishes a SSL connection.
|
33
|
+
#
|
34
|
+
# @param [String] host
|
35
|
+
# The host to connect to.
|
36
|
+
#
|
37
|
+
# @param [Integer] port
|
38
|
+
# The port to connect to.
|
39
|
+
#
|
40
|
+
# @param [Hash] options
|
41
|
+
# Additional options.
|
42
|
+
#
|
43
|
+
# @option options [String] :local_host
|
44
|
+
# The local host to bind to.
|
45
|
+
#
|
46
|
+
# @option options [Integer] :local_port
|
47
|
+
# The local port to bind to.
|
48
|
+
#
|
49
|
+
# @option options [Symbol] :verify
|
50
|
+
# Specifies whether to verify the SSL certificate.
|
51
|
+
#
|
52
|
+
# @option options [String] :cert
|
53
|
+
# The path to the SSL certificate.
|
54
|
+
#
|
55
|
+
# @option options [String] :key
|
56
|
+
# The path to the SSL key.
|
57
|
+
#
|
58
|
+
# @yield [ssl_socket]
|
59
|
+
# The given block will be passed the new SSL Socket.
|
60
|
+
#
|
61
|
+
# @yieldparam [OpenSSL::SSL::SSLSocket] ssl_socket
|
62
|
+
# The new SSL Socket.
|
63
|
+
#
|
64
|
+
# @return [OpenSSL::SSL::SSLSocket]
|
65
|
+
# the new SSL Socket.
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# socket = Net.ssl_connect('twitter.com',443)
|
69
|
+
#
|
70
|
+
def Net.ssl_connect(host,port,options={})
|
71
|
+
local_host = options[:local_host]
|
72
|
+
local_port = options[:local_port]
|
73
|
+
|
74
|
+
socket = Net.tcp_connect(host,port,local_host,local_port)
|
75
|
+
|
76
|
+
ssl_context = OpenSSL::SSL::SSLContext.new()
|
77
|
+
ssl_context.verify_mode = Ronin::Network::SSL.verify(options[:verify])
|
78
|
+
|
79
|
+
if options[:cert]
|
80
|
+
cert_file = File.new(options[:cert])
|
81
|
+
ssl_context.cert = OpenSSL::X509::Certificate.new(cert_file)
|
82
|
+
end
|
83
|
+
|
84
|
+
if options[:key]
|
85
|
+
key_file = File.new(options[:key])
|
86
|
+
ssl_context.key = OpenSSL::PKey::RSA.new(key_file)
|
87
|
+
end
|
88
|
+
|
89
|
+
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket,ssl_context)
|
90
|
+
ssl_socket.sync_close = true
|
91
|
+
ssl_socket.connect
|
92
|
+
|
93
|
+
yield ssl_socket if block_given?
|
94
|
+
return ssl_socket
|
95
|
+
end
|
96
|
+
|
97
|
+
#
|
98
|
+
# Creates a new temporary SSL connection.
|
99
|
+
#
|
100
|
+
# @param [String] host
|
101
|
+
# The host to connect to.
|
102
|
+
#
|
103
|
+
# @param [Integer] port
|
104
|
+
# The port to connect to.
|
105
|
+
#
|
106
|
+
# @param [Hash] options
|
107
|
+
# Additional options.
|
108
|
+
#
|
109
|
+
# @option options [String] :local_host
|
110
|
+
# The local host to bind to.
|
111
|
+
#
|
112
|
+
# @option options [Integer] :local_port
|
113
|
+
# The local port to bind to.
|
114
|
+
#
|
115
|
+
# @option options [Symbol] :verify
|
116
|
+
# Specifies whether to verify the SSL certificate.
|
117
|
+
#
|
118
|
+
# @option options [String] :cert
|
119
|
+
# The path to the SSL certificate.
|
120
|
+
#
|
121
|
+
# @option options [String] :key
|
122
|
+
# The path to the SSL key.
|
123
|
+
#
|
124
|
+
# @yield [ssl_socket]
|
125
|
+
# The given block will be passed the temporary SSL Socket.
|
126
|
+
#
|
127
|
+
# @yieldparam [OpenSSL::SSL::SSLSocket] ssl_socket
|
128
|
+
# The temporary SSL Socket.
|
129
|
+
#
|
130
|
+
# @return [nil]
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# Net.ssl_session('twitter.com',443) do |sock|
|
134
|
+
# sock.write("GET /\n\n")
|
135
|
+
#
|
136
|
+
# sock.each_line { |line| puts line }
|
137
|
+
# end
|
138
|
+
#
|
139
|
+
def Net.ssl_session(host,port)
|
140
|
+
ssl_socket = Net.ssl_connect(host,port)
|
141
|
+
|
142
|
+
yield ssl_socket if block_given?
|
143
|
+
|
144
|
+
ssl_socket.close
|
145
|
+
return nil
|
146
|
+
end
|
147
|
+
end
|