ronin-support 0.3.0 → 0.4.0.rc1

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.
Files changed (59) hide show
  1. data/ChangeLog.md +77 -7
  2. data/README.md +19 -3
  3. data/gemspec.yml +2 -2
  4. data/lib/ronin/extensions/regexp.rb +50 -2
  5. data/lib/ronin/extensions/string.rb +1 -0
  6. data/lib/ronin/formatting.rb +1 -0
  7. data/lib/ronin/formatting/extensions.rb +1 -0
  8. data/lib/ronin/formatting/extensions/binary/string.rb +56 -5
  9. data/lib/ronin/formatting/extensions/html/string.rb +6 -7
  10. data/lib/ronin/formatting/extensions/sql/string.rb +34 -0
  11. data/lib/ronin/formatting/extensions/text/string.rb +0 -180
  12. data/lib/ronin/fuzzing.rb +21 -0
  13. data/lib/ronin/fuzzing/extensions.rb +20 -0
  14. data/lib/ronin/fuzzing/extensions/string.rb +380 -0
  15. data/lib/ronin/fuzzing/fuzzing.rb +191 -0
  16. data/lib/ronin/network/esmtp.rb +94 -1
  17. data/lib/ronin/network/extensions/esmtp/net.rb +2 -82
  18. data/lib/ronin/network/extensions/http/net.rb +1 -736
  19. data/lib/ronin/network/extensions/imap/net.rb +1 -103
  20. data/lib/ronin/network/extensions/pop3/net.rb +1 -71
  21. data/lib/ronin/network/extensions/smtp/net.rb +2 -157
  22. data/lib/ronin/network/extensions/ssl/net.rb +1 -132
  23. data/lib/ronin/network/extensions/tcp/net.rb +2 -296
  24. data/lib/ronin/network/extensions/telnet/net.rb +1 -135
  25. data/lib/ronin/network/extensions/udp/net.rb +2 -214
  26. data/lib/ronin/network/http/http.rb +750 -5
  27. data/lib/ronin/network/imap.rb +105 -2
  28. data/lib/ronin/network/mixins.rb +1 -1
  29. data/lib/ronin/network/mixins/esmtp.rb +49 -52
  30. data/lib/ronin/network/mixins/http.rb +49 -53
  31. data/lib/ronin/network/mixins/imap.rb +47 -44
  32. data/lib/ronin/network/mixins/mixin.rb +58 -0
  33. data/lib/ronin/network/mixins/pop3.rb +44 -38
  34. data/lib/ronin/network/mixins/smtp.rb +49 -51
  35. data/lib/ronin/network/mixins/tcp.rb +56 -69
  36. data/lib/ronin/network/mixins/telnet.rb +57 -50
  37. data/lib/ronin/network/mixins/udp.rb +48 -52
  38. data/lib/ronin/network/network.rb +1 -0
  39. data/lib/ronin/network/pop3.rb +72 -2
  40. data/lib/ronin/network/smtp/email.rb +1 -0
  41. data/lib/ronin/network/smtp/smtp.rb +159 -3
  42. data/lib/ronin/network/ssl.rb +131 -2
  43. data/lib/ronin/network/tcp.rb +306 -1
  44. data/lib/ronin/network/telnet.rb +136 -2
  45. data/lib/ronin/network/udp.rb +229 -1
  46. data/lib/ronin/support.rb +2 -3
  47. data/lib/ronin/support/support.rb +38 -0
  48. data/lib/ronin/support/version.rb +1 -1
  49. data/lib/ronin/templates/erb.rb +2 -1
  50. data/lib/ronin/ui/output/helpers.rb +35 -1
  51. data/lib/ronin/ui/shell.rb +12 -2
  52. data/lib/ronin/wordlist.rb +157 -0
  53. data/spec/extensions/regexp_spec.rb +38 -0
  54. data/spec/formatting/html/string_spec.rb +1 -1
  55. data/spec/formatting/sql/string_spec.rb +23 -3
  56. data/spec/formatting/text/string_spec.rb +0 -110
  57. data/spec/fuzzing/string_spec.rb +158 -0
  58. data/spec/wordlist_spec.rb +65 -0
  59. metadata +35 -27
@@ -18,109 +18,7 @@
18
18
  #
19
19
 
20
20
  require 'ronin/network/imap'
21
- require 'ronin/network/ssl'
22
-
23
- require 'net/imap'
24
21
 
25
22
  module Net
26
- #
27
- # Creates a connection to the IMAP server.
28
- #
29
- # @param [String] host
30
- # The host to connect to.
31
- #
32
- # @param [Hash] options
33
- # Additional options.
34
- #
35
- # @option options [Integer] :port (IMAP.default_port)
36
- # The port the IMAP server is running on.
37
- #
38
- # @option options [String] :certs
39
- # The path to the file containing CA certs of the server.
40
- #
41
- # @option options [Symbol] :auth
42
- # The type of authentication to perform when connecting to the server.
43
- # May be either `:login` or `:cram_md5`.
44
- #
45
- # @option options [String] :user
46
- # The user to authenticate as when connecting to the server.
47
- #
48
- # @option options [String] :password
49
- # The password to authenticate with when connecting to the server.
50
- #
51
- # @yield [session]
52
- # If a block is given, it will be passed the newly created IMAP
53
- # session.
54
- #
55
- # @yieldparam [Net::IMAP] session
56
- # The newly created IMAP session object.
57
- #
58
- # @return [Net::IMAP]
59
- # The newly created IMAP session object.
60
- #
61
- # @api public
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
- # @api public
115
- #
116
- def Net.imap_session(host,options={})
117
- session = Net.imap_connect(host,options)
118
-
119
- yield session if block_given?
120
-
121
- session.logout if options[:user]
122
- session.close
123
- session.disconnect
124
- return nil
125
- end
23
+ extend Ronin::Network::IMAP
126
24
  end
@@ -19,76 +19,6 @@
19
19
 
20
20
  require 'ronin/network/pop3'
21
21
 
22
- require 'net/pop'
23
-
24
22
  module Net
25
- #
26
- # Creates a connection to the POP3 server.
27
- #
28
- # @param [String] host
29
- # The host to connect to.
30
- #
31
- # @param [Hash] options
32
- # Additional options.
33
- #
34
- # @option options [Integer] :port (Ronin::Network::POP3.default_port)
35
- # The port the POP3 server is running on.
36
- #
37
- # @option options [String] :user
38
- # The user to authenticate with when connecting to the POP3 server.
39
- #
40
- # @option options [String] :password
41
- # The password to authenticate with when connecting to the POP3 server.
42
- #
43
- # @yield [session]
44
- # If a block is given, it will be passed the newly created POP3 session.
45
- #
46
- # @yieldparam [Net::POP3] session
47
- # The newly created POP3 session.
48
- #
49
- # @return [Net::POP3]
50
- # The newly created POP3 session.
51
- #
52
- # @api public
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
- # @api public
85
- #
86
- def Net.pop3_session(host,options={})
87
- session = Net.pop3_connect(host,options)
88
-
89
- yield session if block_given?
90
-
91
- session.finish
92
- return nil
93
- end
23
+ extend Ronin::Network::POP3
94
24
  end
@@ -17,163 +17,8 @@
17
17
  # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/network/smtp/smtp'
21
- require 'ronin/network/smtp/email'
22
-
23
- require 'net/smtp'
20
+ require 'ronin/network/smtp'
24
21
 
25
22
  module Net
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
41
- #
42
- def Net.smtp_message(options={},&block)
43
- Ronin::Network::SMTP::Email.new(options,&block)
44
- end
45
-
46
- #
47
- # Creates a connection to the SMTP server.
48
- #
49
- # @param [String] host
50
- # The host to connect to.
51
- #
52
- # @param [Hash] options
53
- # Additional options.
54
- #
55
- # @option options [Integer] :port (Ronin::Network::SMTP.default_port)
56
- # The port to connect to.
57
- #
58
- # @option options [String] :helo
59
- # The HELO domain.
60
- #
61
- # @option options [Symbol] :auth
62
- # The type of authentication to use. Can be either `:login`, `:plain`,
63
- # or `:cram_md5`.
64
- #
65
- # @option options [String] :user
66
- # The user-name to authenticate with.
67
- #
68
- # @option options [String] :password
69
- # The password to authenticate with.
70
- #
71
- # @yield [session]
72
- # If a block is given, it will be passed an SMTP session object.
73
- #
74
- # @yieldparam [Net::SMTP] session
75
- # The SMTP session.
76
- #
77
- # @return [Net::SMTP]
78
- # The SMTP session.
79
- #
80
- # @example
81
- # Net.smtp_connect('www.example.com', :user => 'joe')
82
- #
83
- # @api public
84
- #
85
- def Net.smtp_connect(host,options={})
86
- host = host.to_s
87
- port = (options[:port] || Ronin::Network::SMTP.default_port)
88
-
89
- helo = options[:helo]
90
-
91
- auth = options[:auth]
92
- user = options[:user]
93
- password = options[:password]
94
-
95
- session = Net::SMTP.start(host,port,helo,user,password,auth)
96
-
97
- yield session if block_given?
98
- return session
99
- end
100
-
101
- #
102
- # Starts a session with the SMTP server.
103
- #
104
- # @param [String] host
105
- # The host to connect to.
106
- #
107
- # @param [Hash] options
108
- # Additional options.
109
- #
110
- # @yield [session]
111
- # If a block is given, it will be passed an SMTP session object.
112
- # After the block has returned, the session will be closed.
113
- #
114
- # @yieldparam [Net::SMTP] session
115
- # The SMTP session.
116
- #
117
- # @example
118
- # Net.smtp_session('www.example.com', :user => 'joe') do |smtp|
119
- # # ...
120
- # end
121
- #
122
- # @see Net.smtp_connect
123
- #
124
- # @api public
125
- #
126
- def Net.smtp_session(host,options={})
127
- session = Net.smtp_connect(host,options)
128
-
129
- yield session if block_given?
130
-
131
- session.finish
132
- return nil
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
23
+ extend Ronin::Network::SMTP
179
24
  end
@@ -17,139 +17,8 @@
17
17
  # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/network/extensions/tcp/net'
21
20
  require 'ronin/network/ssl'
22
21
 
23
- begin
24
- require 'openssl'
25
- rescue ::LoadError
26
- end
27
-
28
22
  module Net
29
- #
30
- # Establishes a SSL connection.
31
- #
32
- # @param [String] host
33
- # The host to connect to.
34
- #
35
- # @param [Integer] port
36
- # The port to connect to.
37
- #
38
- # @param [Hash] options
39
- # Additional options.
40
- #
41
- # @option options [String] :local_host
42
- # The local host to bind to.
43
- #
44
- # @option options [Integer] :local_port
45
- # The local port to bind to.
46
- #
47
- # @option options [Symbol] :verify
48
- # Specifies whether to verify the SSL certificate.
49
- # May be one of the following:
50
- #
51
- # * `:none`
52
- # * `:peer`
53
- # * `:client_once`
54
- # * `:fail_if_no_peer_cert`
55
- #
56
- # @option options [String] :cert
57
- # The path to the SSL certificate.
58
- #
59
- # @option options [String] :key
60
- # The path to the SSL key.
61
- #
62
- # @yield [ssl_socket]
63
- # The given block will be passed the new SSL Socket.
64
- #
65
- # @yieldparam [OpenSSL::SSL::SSLSocket] ssl_socket
66
- # The new SSL Socket.
67
- #
68
- # @return [OpenSSL::SSL::SSLSocket]
69
- # the new SSL Socket.
70
- #
71
- # @example
72
- # socket = Net.ssl_connect('twitter.com',443)
73
- #
74
- # @api public
75
- #
76
- def Net.ssl_connect(host,port,options={})
77
- local_host = options[:local_host]
78
- local_port = options[:local_port]
79
-
80
- socket = Net.tcp_connect(host,port,local_host,local_port)
81
-
82
- ssl_context = OpenSSL::SSL::SSLContext.new()
83
- ssl_context.verify_mode = Ronin::Network::SSL::VERIFY[options[:verify]]
84
-
85
- if options[:cert]
86
- cert_file = File.new(options[:cert])
87
- ssl_context.cert = OpenSSL::X509::Certificate.new(cert_file)
88
- end
89
-
90
- if options[:key]
91
- key_file = File.new(options[:key])
92
- ssl_context.key = OpenSSL::PKey::RSA.new(key_file)
93
- end
94
-
95
- ssl_socket = OpenSSL::SSL::SSLSocket.new(socket,ssl_context)
96
- ssl_socket.sync_close = true
97
- ssl_socket.connect
98
-
99
- yield ssl_socket if block_given?
100
- return ssl_socket
101
- end
102
-
103
- #
104
- # Creates a new temporary SSL connection.
105
- #
106
- # @param [String] host
107
- # The host to connect to.
108
- #
109
- # @param [Integer] port
110
- # The port to connect to.
111
- #
112
- # @param [Hash] options
113
- # Additional options.
114
- #
115
- # @option options [String] :local_host
116
- # The local host to bind to.
117
- #
118
- # @option options [Integer] :local_port
119
- # The local port to bind to.
120
- #
121
- # @option options [Symbol] :verify
122
- # Specifies whether to verify the SSL certificate.
123
- #
124
- # @option options [String] :cert
125
- # The path to the SSL certificate.
126
- #
127
- # @option options [String] :key
128
- # The path to the SSL key.
129
- #
130
- # @yield [ssl_socket]
131
- # The given block will be passed the temporary SSL Socket.
132
- #
133
- # @yieldparam [OpenSSL::SSL::SSLSocket] ssl_socket
134
- # The temporary SSL Socket.
135
- #
136
- # @return [nil]
137
- #
138
- # @example
139
- # Net.ssl_session('twitter.com',443) do |sock|
140
- # sock.write("GET /\n\n")
141
- #
142
- # sock.each_line { |line| puts line }
143
- # end
144
- #
145
- # @api public
146
- #
147
- def Net.ssl_session(host,port)
148
- ssl_socket = Net.ssl_connect(host,port)
149
-
150
- yield ssl_socket if block_given?
151
-
152
- ssl_socket.close
153
- return nil
154
- end
23
+ extend Ronin::Network::SSL
155
24
  end