ronin-support 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +11 -0
- data/ChangeLog.md +42 -1
- data/README.md +4 -1
- data/gemspec.yml +2 -1
- data/lib/ronin/extensions.rb +2 -0
- data/lib/ronin/extensions/enumerable.rb +54 -0
- data/lib/ronin/extensions/file.rb +70 -2
- data/lib/ronin/extensions/ip_addr.rb +45 -45
- data/lib/ronin/extensions/regexp.rb +45 -0
- data/lib/ronin/extensions/resolv.rb +80 -0
- data/lib/ronin/extensions/string.rb +35 -32
- data/lib/ronin/formatting/extensions/binary/integer.rb +12 -5
- data/lib/ronin/formatting/extensions/binary/string.rb +44 -16
- data/lib/ronin/formatting/extensions/html/integer.rb +51 -31
- data/lib/ronin/formatting/extensions/html/string.rb +50 -31
- data/lib/ronin/formatting/extensions/http/integer.rb +10 -2
- data/lib/ronin/formatting/extensions/sql.rb +20 -0
- data/lib/ronin/formatting/extensions/sql/string.rb +98 -0
- data/lib/ronin/formatting/extensions/text/array.rb +11 -9
- data/lib/ronin/formatting/extensions/text/string.rb +213 -29
- data/lib/ronin/formatting/sql.rb +20 -0
- data/lib/ronin/network/extensions/http.rb +1 -0
- data/lib/ronin/network/extensions/http/net.rb +2 -2
- data/lib/ronin/network/extensions/http/uri/http.rb +226 -0
- data/lib/ronin/network/extensions/imap/net.rb +1 -1
- data/lib/ronin/network/extensions/ssl/net.rb +7 -1
- data/lib/ronin/network/http/proxy.rb +20 -21
- data/lib/ronin/network/mixins.rb +27 -0
- data/lib/ronin/network/mixins/esmtp.rb +165 -0
- data/lib/ronin/network/mixins/http.rb +723 -0
- data/lib/ronin/network/mixins/imap.rb +151 -0
- data/lib/ronin/network/mixins/pop3.rb +141 -0
- data/lib/ronin/network/mixins/smtp.rb +159 -0
- data/lib/ronin/network/mixins/tcp.rb +331 -0
- data/lib/ronin/network/mixins/telnet.rb +199 -0
- data/lib/ronin/network/mixins/udp.rb +227 -0
- data/lib/ronin/network/ssl.rb +17 -11
- data/lib/ronin/path.rb +3 -3
- data/lib/ronin/spec/ui/output.rb +28 -0
- data/lib/ronin/support.rb +3 -0
- data/lib/ronin/support/version.rb +1 -1
- data/lib/ronin/ui/output.rb +21 -0
- data/lib/ronin/ui/output/helpers.rb +248 -0
- data/lib/ronin/ui/output/output.rb +146 -0
- data/lib/ronin/ui/output/terminal.rb +21 -0
- data/lib/ronin/ui/output/terminal/color.rb +118 -0
- data/lib/ronin/ui/output/terminal/raw.rb +103 -0
- data/lib/ronin/ui/shell.rb +219 -0
- data/ronin-support.gemspec +1 -1
- data/spec/extensions/enumerable_spec.rb +24 -0
- data/spec/extensions/file_spec.rb +39 -0
- data/spec/extensions/ip_addr_spec.rb +6 -0
- data/spec/extensions/resolv_spec.rb +18 -0
- data/spec/formatting/html/integer_spec.rb +2 -2
- data/spec/formatting/html/string_spec.rb +1 -1
- data/spec/formatting/sql/string_spec.rb +55 -0
- data/spec/formatting/text/string_spec.rb +110 -0
- data/spec/network/ssl_spec.rb +10 -4
- data/spec/ui/classes/test_shell.rb +22 -0
- data/spec/ui/output_spec.rb +32 -0
- data/spec/ui/shell_spec.rb +79 -0
- metadata +132 -90
@@ -0,0 +1,151 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of Ronin Support.
|
5
|
+
#
|
6
|
+
# Ronin Support is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Ronin Support 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
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/network/imap'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
23
|
+
|
24
|
+
require 'parameters'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Network
|
28
|
+
module Mixins
|
29
|
+
#
|
30
|
+
# Adds IMAP convenience methods and connection parameters to a class.
|
31
|
+
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - IMAP host.
|
35
|
+
# * `port` (`Integer`) - IMAP port.
|
36
|
+
# * `imap_auth` (`String`) - IMAP authentication method.
|
37
|
+
# * `imap_user` (`String`) - IMAP user to login as.
|
38
|
+
# * `imap_password` (`String`) - IMAP password to login with.
|
39
|
+
#
|
40
|
+
module IMAP
|
41
|
+
include Mixin
|
42
|
+
|
43
|
+
mixin UI::Output::Helpers, Parameters
|
44
|
+
|
45
|
+
mixin do
|
46
|
+
# IMAP host
|
47
|
+
parameter :host, :type => String,
|
48
|
+
:description => 'IMAP host'
|
49
|
+
|
50
|
+
# IMAP port
|
51
|
+
parameter :port, :type => Integer,
|
52
|
+
:description => 'IMAP port'
|
53
|
+
|
54
|
+
# IMAP auth
|
55
|
+
parameter :imap_auth, :type => String,
|
56
|
+
:description => 'IMAP authentication method'
|
57
|
+
|
58
|
+
# IMAP user to login as
|
59
|
+
parameter :imap_user, :type => String,
|
60
|
+
:description => 'IMAP user to login as'
|
61
|
+
|
62
|
+
# IMAP password to login with
|
63
|
+
parameter :imap_password, :type => String,
|
64
|
+
:description => 'IMAP password to login with'
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
#
|
70
|
+
# Creates a connection to the IMAP server. The `host`, `port`,
|
71
|
+
# `imap_auth`, `imap_user` and `imap_password` parameters
|
72
|
+
# will also be used to make the connection.
|
73
|
+
#
|
74
|
+
# @param [Hash] options
|
75
|
+
# Additional options.
|
76
|
+
#
|
77
|
+
# @option options [Integer] :port (IMAP.default_port)
|
78
|
+
# The port the IMAP server is running on.
|
79
|
+
#
|
80
|
+
# @option options [String] :certs
|
81
|
+
# The path to the file containing CA certs of the server.
|
82
|
+
#
|
83
|
+
# @option options [Symbol] :auth
|
84
|
+
# The type of authentication to perform when connecting to the
|
85
|
+
# server. May be either `:login` or `:cram_md5`.
|
86
|
+
#
|
87
|
+
# @option options [String] :user
|
88
|
+
# The user to authenticate as when connecting to the server.
|
89
|
+
#
|
90
|
+
# @option options [String] :password
|
91
|
+
# The password to authenticate with when connecting to the
|
92
|
+
# server.
|
93
|
+
#
|
94
|
+
# @option options [Boolean]
|
95
|
+
# Indicates wether or not to use SSL when connecting to the
|
96
|
+
# server.
|
97
|
+
#
|
98
|
+
# @api public
|
99
|
+
#
|
100
|
+
def imap_connect(options={},&block)
|
101
|
+
options[:port] ||= self.port
|
102
|
+
options[:auth] ||= self.imap_auth
|
103
|
+
options[:user] ||= self.imap_user
|
104
|
+
options[:password] ||= self.imap_password
|
105
|
+
|
106
|
+
if self.port
|
107
|
+
print_info "Connecting to #{self.host}:#{self.port} ..."
|
108
|
+
else
|
109
|
+
print_info "Connecting to #{self.host} ..."
|
110
|
+
end
|
111
|
+
|
112
|
+
return ::Net.imap_connect(self.host,options,&block)
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# Starts a session with the IMAP server. The `host`, `port`,
|
117
|
+
# `imap_auth`, `imap_user` and `imap_password` parameters
|
118
|
+
# will also be used to make the connection.
|
119
|
+
#
|
120
|
+
# @yield [session]
|
121
|
+
# If a block is given, it will be passed the newly created
|
122
|
+
# IMAP session. After the block has returned, the session will
|
123
|
+
# be closed.
|
124
|
+
#
|
125
|
+
# @yieldparam [Net::IMAP] session
|
126
|
+
# The newly created IMAP session object.
|
127
|
+
#
|
128
|
+
# @see imap_connect
|
129
|
+
#
|
130
|
+
# @api public
|
131
|
+
#
|
132
|
+
def imap_session(options={})
|
133
|
+
imap_connect(options) do |sess|
|
134
|
+
yield sess if block_given?
|
135
|
+
|
136
|
+
print_info "Logging out ..."
|
137
|
+
|
138
|
+
sess.close
|
139
|
+
sess.logout
|
140
|
+
|
141
|
+
if self.port
|
142
|
+
print_info "Disconnecting from #{self.host}:#{self.port}"
|
143
|
+
else
|
144
|
+
print_info "Disconnecting from #{self.host}"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of Ronin Support.
|
5
|
+
#
|
6
|
+
# Ronin Support is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Ronin Support 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
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/network/pop3'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
23
|
+
|
24
|
+
require 'parameters'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Network
|
28
|
+
module Mixins
|
29
|
+
#
|
30
|
+
# Adds POP3 convenience methods and connection parameters to a class.
|
31
|
+
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - POP3 host.
|
35
|
+
# * `port` (`Integer`) - POP3 port.
|
36
|
+
# * `pop3_user` (`String`) - POP3 user to login as.
|
37
|
+
# * `pop3_password` (`String`) - POP3 password to login with.
|
38
|
+
#
|
39
|
+
module POP3
|
40
|
+
include Mixin
|
41
|
+
|
42
|
+
mixin UI::Output::Helpers, Parameters
|
43
|
+
|
44
|
+
mixin do
|
45
|
+
# POP3 host
|
46
|
+
parameter :host, :type => String,
|
47
|
+
:description => 'POP3 host'
|
48
|
+
|
49
|
+
# POP3 port
|
50
|
+
parameter :port, :type => Integer,
|
51
|
+
:description => 'POP3 port'
|
52
|
+
|
53
|
+
# POP3 user
|
54
|
+
parameter :pop3_user, :type => String,
|
55
|
+
:description => 'POP3 user to login as'
|
56
|
+
|
57
|
+
# POP3 password
|
58
|
+
parameter :pop3_password, :type => String,
|
59
|
+
:description => 'POP3 password to login with'
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
#
|
65
|
+
# Creates a connection to the POP3 server. The `host}, `port`,
|
66
|
+
# `pop3_user` and `pop3_password` parameters will also be used
|
67
|
+
# to connect to the server.
|
68
|
+
#
|
69
|
+
# @param [Hash] options
|
70
|
+
# Additional options.
|
71
|
+
#
|
72
|
+
# @option options [Integer] :port (Ronin::Network::POP3.default_port)
|
73
|
+
# The port the POP3 server is running on.
|
74
|
+
#
|
75
|
+
# @option options [String] :user
|
76
|
+
# The user to authenticate with when connecting to the POP3
|
77
|
+
# server.
|
78
|
+
#
|
79
|
+
# @option options [String] :password
|
80
|
+
# The password to authenticate with when connecting to the POP3
|
81
|
+
# server.
|
82
|
+
#
|
83
|
+
# @yield [session]
|
84
|
+
# If a block is given, it will be passed the newly created
|
85
|
+
# POP3 session.
|
86
|
+
#
|
87
|
+
# @yieldparam [Net::POP3] session
|
88
|
+
# The newly created POP3 session.
|
89
|
+
#
|
90
|
+
# @return [Net::POP3]
|
91
|
+
# The newly created POP3 session.
|
92
|
+
#
|
93
|
+
# @api public
|
94
|
+
#
|
95
|
+
def pop3_connect(options={},&block)
|
96
|
+
options[:port] ||= self.port
|
97
|
+
options[:user] ||= self.pop3_user
|
98
|
+
options[:password] ||= self.pop3_password
|
99
|
+
|
100
|
+
if self.port
|
101
|
+
print_info "Connecting to #{self.host}:#{self.port} ..."
|
102
|
+
else
|
103
|
+
print_info "Connecting to #{self.host} ..."
|
104
|
+
end
|
105
|
+
|
106
|
+
return ::Net.pop3_connect(self.host,options,&block)
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Starts a session with the POP3 server. The `host`, `port`,
|
111
|
+
# `pop3_user` and `pop3_password` parameters will also be used
|
112
|
+
# to connect to the server.
|
113
|
+
#
|
114
|
+
# @yield [session]
|
115
|
+
# If a block is given, it will be passed the newly created
|
116
|
+
# POP3 session. After the block has returned, the session
|
117
|
+
# will be closed.
|
118
|
+
#
|
119
|
+
# @yieldparam [Net::POP3] session
|
120
|
+
# The newly created POP3 session.
|
121
|
+
#
|
122
|
+
# @see pop3_connect
|
123
|
+
#
|
124
|
+
# @api public
|
125
|
+
#
|
126
|
+
def pop3_session(options={})
|
127
|
+
pop3_connect(options) do |sess|
|
128
|
+
yield sess if block_given?
|
129
|
+
sess.finish
|
130
|
+
|
131
|
+
if @port
|
132
|
+
print_info "Disconnecting to #{self.host}:#{self.port}"
|
133
|
+
else
|
134
|
+
print_info "Disconnecting to #{self.host}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2006-2011 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
#
|
4
|
+
# This file is part of Ronin Support.
|
5
|
+
#
|
6
|
+
# Ronin Support is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# Ronin Support 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
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ronin/network/smtp'
|
21
|
+
require 'ronin/ui/output/helpers'
|
22
|
+
require 'ronin/mixin'
|
23
|
+
|
24
|
+
require 'parameters'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module Network
|
28
|
+
module Mixins
|
29
|
+
#
|
30
|
+
# Adds SMTP convenience methods and connection parameters to a class.
|
31
|
+
#
|
32
|
+
# Defines the following parameters:
|
33
|
+
#
|
34
|
+
# * `host` (`String`) - SMTP host.
|
35
|
+
# * `port` (`Integer`) - SMTP port.
|
36
|
+
# * `smtp_login` (`String`) - SMTP authentication method.
|
37
|
+
# * `smtp_user` (`String`) - SMTP user to login as.
|
38
|
+
# * `smtp_password` (`String`) - SMTP password to login with.
|
39
|
+
#
|
40
|
+
module SMTP
|
41
|
+
include Mixin
|
42
|
+
|
43
|
+
mixin UI::Output::Helpers, Parameters
|
44
|
+
|
45
|
+
mixin do
|
46
|
+
# SMTP host
|
47
|
+
parameter :host, :type => String,
|
48
|
+
:description => 'SMTP host'
|
49
|
+
|
50
|
+
# SMTP port
|
51
|
+
parameter :port, :type => Integer,
|
52
|
+
:description => 'SMTP port'
|
53
|
+
|
54
|
+
# SMTP authentication method
|
55
|
+
parameter :smtp_login, :type => String,
|
56
|
+
:description => 'SMTP authentication method'
|
57
|
+
|
58
|
+
# SMTP user to login as
|
59
|
+
parameter :smtp_user, :type => String,
|
60
|
+
:description => 'SMTP user to login as'
|
61
|
+
|
62
|
+
# SMTP user to login with
|
63
|
+
parameter :smtp_password, :type => String,
|
64
|
+
:description => 'SMTP password to login with'
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
#
|
70
|
+
# @see Ronin::Network::SMTP.message
|
71
|
+
#
|
72
|
+
# @api public
|
73
|
+
#
|
74
|
+
def smtp_message(options={},&block)
|
75
|
+
Network::SMTP.message(options,&block)
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Creates a connection to the SMTP server. The `host`, `port`,
|
80
|
+
# `smtp_login`, `smtp_user` and `smtp_password` parameters
|
81
|
+
# will also be used to connect to the server.
|
82
|
+
#
|
83
|
+
# @param [Hash] options
|
84
|
+
# Additional options.
|
85
|
+
#
|
86
|
+
# @option options [Integer] :port (Ronin::Network::SMTP.default_port)
|
87
|
+
# The port to connect to.
|
88
|
+
#
|
89
|
+
# @option options [String] :helo
|
90
|
+
# The HELO domain.
|
91
|
+
#
|
92
|
+
# @option options [Symbol] :auth
|
93
|
+
# The type of authentication to use. Can be either `:login`,
|
94
|
+
# `:plain` or `:cram_md5`.
|
95
|
+
#
|
96
|
+
# @option options [String] :user
|
97
|
+
# The user-name to authenticate with.
|
98
|
+
#
|
99
|
+
# @option options [String] :password
|
100
|
+
# The password to authenticate with.
|
101
|
+
#
|
102
|
+
# @yield [session]
|
103
|
+
# If a block is given, it will be passed an SMTP session object.
|
104
|
+
#
|
105
|
+
# @yieldparam [Net::SMTP] session
|
106
|
+
# The SMTP session.
|
107
|
+
#
|
108
|
+
# @return [Net::SMTP]
|
109
|
+
# The SMTP session.
|
110
|
+
#
|
111
|
+
# @api public
|
112
|
+
#
|
113
|
+
def smtp_connect(options={},&block)
|
114
|
+
options[:port] ||= self.port
|
115
|
+
options[:login] ||= self.smtp_login
|
116
|
+
options[:user] ||= self.smtp_user
|
117
|
+
options[:password] ||= self.smtp_password
|
118
|
+
|
119
|
+
if self.port
|
120
|
+
print_info "Connecting to #{self.host}:#{self.port} ..."
|
121
|
+
else
|
122
|
+
print_info "Connecting to #{self.host} ..."
|
123
|
+
end
|
124
|
+
|
125
|
+
return ::Net.smtp_connect(self.host,options,&block)
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Starts a session with the SMTP server. The `host`, `port`,
|
130
|
+
# `smtp_login`, `smtp_user` and `smtp_password` parameters
|
131
|
+
# will also be used to connect to the server.
|
132
|
+
#
|
133
|
+
# @yield [session]
|
134
|
+
# If a block is given, it will be passed an SMTP session object.
|
135
|
+
# After the block has returned, the session will be closed.
|
136
|
+
#
|
137
|
+
# @yieldparam [Net::SMTP] session
|
138
|
+
# The SMTP session.
|
139
|
+
#
|
140
|
+
# @see smtp_connect
|
141
|
+
#
|
142
|
+
# @api public
|
143
|
+
#
|
144
|
+
def smtp_session(options={},&block)
|
145
|
+
smtp_connect(options) do |sess|
|
146
|
+
yield sess if block_given?
|
147
|
+
sess.close
|
148
|
+
|
149
|
+
if self.port
|
150
|
+
print_info "Disconnecting to #{self.host}:#{self.port}"
|
151
|
+
else
|
152
|
+
print_info "Disconnecting to #{self.host}"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|