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
@@ -17,12 +17,12 @@
17
17
  # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/network/extensions/telnet'
20
+ require 'net/telnet'
21
21
 
22
22
  module Ronin
23
23
  module Network
24
24
  #
25
- # Global settings for accessing Telnet.
25
+ # Provides helper methods for communicating with Telnet services.
26
26
  #
27
27
  module Telnet
28
28
  # Default telnet port
@@ -121,6 +121,140 @@ module Ronin
121
121
  def Telnet.proxy=(new_proxy)
122
122
  @proxy = new_proxy
123
123
  end
124
+
125
+ #
126
+ # Creates a new Telnet connection.
127
+ #
128
+ # @param [String] host
129
+ # The host to connect to.
130
+ #
131
+ # @param [Hash] options
132
+ # Additional options.
133
+ #
134
+ # @option options [Integer] :port (Telnet.default_port)
135
+ # The port to connect to.
136
+ #
137
+ # @option options [Boolean] :binmode
138
+ # Indicates that newline substitution shall not be performed.
139
+ #
140
+ # @option options [String] :output_log
141
+ # The name of the file to write connection status messages and all
142
+ # received traffic to.
143
+ #
144
+ # @option options [String] :dump_log
145
+ # Similar to the `:output_log` option, but connection output is also
146
+ # written in hexdump format.
147
+ #
148
+ # @option options [Regexp] :prompt (Telnet.default_prompt)
149
+ # A regular expression matching the host command-line prompt sequence,
150
+ # used to determine when a command has finished.
151
+ #
152
+ # @option options [Boolean] :telnet (true)
153
+ # Indicates that the connection shall behave as a telnet connection.
154
+ #
155
+ # @option options [Boolean] :plain
156
+ # Indicates that the connection shall behave as a normal TCP
157
+ # connection.
158
+ #
159
+ # @option options [Integer] :timeout (Telnet.default_timeout)
160
+ # The number of seconds to wait before timing out both the initial
161
+ # attempt to connect to host, and all attempts to read data from the
162
+ # host.
163
+ #
164
+ # @option options [Integer] :wait_time
165
+ # The amount of time to wait after seeing what looks like a prompt.
166
+ #
167
+ # @option options [Net::Telnet, IO] :proxy (Telnet.proxy)
168
+ # A proxy object to used instead of opening a direct connection to the
169
+ # host.
170
+ #
171
+ # @option options [String] :user
172
+ # The user to login as.
173
+ #
174
+ # @option options [String] :password
175
+ # The password to login with.
176
+ #
177
+ # @yield [session]
178
+ # If a block is given, it will be passed the newly created Telnet
179
+ # session.
180
+ #
181
+ # @yieldparam [Net::Telnet] session
182
+ # The newly created Telnet session.
183
+ #
184
+ # @return [Net::Telnet]
185
+ # The Telnet session
186
+ #
187
+ # @example
188
+ # telnet_connect('towel.blinkenlights.nl')
189
+ # # => #<Net::Telnet: ...>
190
+ #
191
+ # @api public
192
+ #
193
+ def telnet_connect(host,options={})
194
+ host = host.to_s
195
+ telnet_options = {}
196
+
197
+ telnet_options['Host'] = host
198
+ telnet_options['Port'] = (options[:port] || Telnet.default_port)
199
+ telnet_options['Binmode'] = options[:binmode]
200
+ telnet_options['Output_log'] = options[:output_log]
201
+ telnet_options['Dump_log'] = options[:dump_log]
202
+ telnet_options['Prompt'] = (options[:prompt] || Telnet.default_prompt)
203
+
204
+ if (options[:telnet] && !options[:plain])
205
+ telnet_options['Telnetmode'] = true
206
+ end
207
+
208
+ telnet_options['Timeout'] = (options[:timeout] || Telnet.default_timeout)
209
+ telnet_options['Waittime'] = options[:wait_time]
210
+ telnet_options['Proxy'] = (options[:proxy] || Telnet.proxy)
211
+
212
+ user = options[:user]
213
+ passwd = options[:passwd]
214
+
215
+ session = Net::Telnet.new(telnet_options)
216
+ session.login(user,passwd) if user
217
+
218
+ yield session if block_given?
219
+ return session
220
+ end
221
+
222
+ #
223
+ # Starts a new Telnet session.
224
+ #
225
+ # @param [String] host
226
+ # The host to connect to.
227
+ #
228
+ # @param [Hash] options
229
+ # Additional options.
230
+ #
231
+ # @yield [session]
232
+ # If a block is given, it will be passed the newly created
233
+ # Telnet session. After the block has returned, the Telnet session
234
+ # will be closed.
235
+ #
236
+ # @yieldparam [Net::Telnet] session
237
+ # The newly created Telnet session.
238
+ #
239
+ # @return [nil]
240
+ #
241
+ # @example
242
+ # telnet_session('towel.blinkenlights.nl') do |movie|
243
+ # movie.each_line { |line| puts line }
244
+ # end
245
+ #
246
+ # @see telnet_session
247
+ #
248
+ # @api public
249
+ #
250
+ def telnet_session(host,options={})
251
+ session = telnet_connect(host,options)
252
+
253
+ yield session if block_given?
254
+
255
+ session.close
256
+ return nil
257
+ end
124
258
  end
125
259
  end
126
260
  end
@@ -17,4 +17,232 @@
17
17
  # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/network/extensions/udp'
20
+ require 'socket'
21
+
22
+ module Ronin
23
+ module Network
24
+ #
25
+ # Provides helper methods for using the UDP protocol.
26
+ #
27
+ module UDP
28
+ #
29
+ # Creates a new UDPSocket object connected to a given host and port.
30
+ #
31
+ # @param [String] host
32
+ # The host to connect to.
33
+ #
34
+ # @param [Integer] port
35
+ # The port to connect to.
36
+ #
37
+ # @param [String] local_host (nil)
38
+ # The local host to bind to.
39
+ #
40
+ # @param [Integer] local_port (nil)
41
+ # The local port to bind to.
42
+ #
43
+ # @yield [socket]
44
+ # If a block is given, it will be passed the newly created socket.
45
+ #
46
+ # @yieldparam [UDPsocket] socket
47
+ # The newly created UDPSocket object.
48
+ #
49
+ # @return [UDPSocket]
50
+ # The newly created UDPSocket object.
51
+ #
52
+ # @example
53
+ # udp_connect('www.hackety.org',80)
54
+ # # => UDPSocket
55
+ #
56
+ # @example
57
+ # udp_connect('www.wired.com',80) do |sock|
58
+ # puts sock.readlines
59
+ # end
60
+ #
61
+ # @api public
62
+ #
63
+ def udp_connect(host,port,local_host=nil,local_port=nil)
64
+ host = host.to_s
65
+ local_host = if local_host
66
+ local_host.to_s
67
+ end
68
+
69
+ socket = UDPSocket.new
70
+ socket.bind(local_host,local_port) if (local_host && local_port)
71
+ socket.connect(host,port)
72
+
73
+ yield socket if block_given?
74
+ return socket
75
+ end
76
+
77
+ #
78
+ # Creates a new UDPSocket object, connected to a given host and port.
79
+ # The given data will then be written to the newly created UDPSocket.
80
+ #
81
+ # @param [String] data
82
+ # The data to send through the connection.
83
+ #
84
+ # @param [String] host
85
+ # The host to connect to.
86
+ #
87
+ # @param [Integer] port
88
+ # The port to connect to.
89
+ #
90
+ # @param [String] local_host (nil)
91
+ # The local host to bind to.
92
+ #
93
+ # @param [Integer] local_port (nil)
94
+ # The local port to bind to.
95
+ #
96
+ # @yield [socket]
97
+ # If a block is given, it will be passed the newly created socket.
98
+ #
99
+ # @yieldparam [UDPsocket] socket
100
+ # The newly created UDPSocket object.
101
+ #
102
+ # @return [UDPSocket]
103
+ # The newly created UDPSocket object.
104
+ #
105
+ # @api public
106
+ #
107
+ def udp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
108
+ sock = udp_connect(host,port,local_host,local_port)
109
+ sock.write(data)
110
+
111
+ yield sock if block_given?
112
+ return sock
113
+ end
114
+
115
+ #
116
+ # Creates a new temporary UDPSocket object, connected to the given host
117
+ # and port.
118
+ #
119
+ # @param [String] host
120
+ # The host to connect to.
121
+ #
122
+ # @param [Integer] port
123
+ # The port to connect to.
124
+ #
125
+ # @param [String] local_host (nil)
126
+ # The local host to bind to.
127
+ #
128
+ # @param [Integer] local_port (nil)
129
+ # The local port to bind to.
130
+ #
131
+ # @yield [socket]
132
+ # If a block is given, it will be passed the newly created socket.
133
+ # After the block has returned, the socket will then be closed.
134
+ #
135
+ # @yieldparam [UDPsocket] socket
136
+ # The newly created UDPSocket object.
137
+ #
138
+ # @return [nil]
139
+ #
140
+ # @api public
141
+ #
142
+ def udp_session(host,port,local_host=nil,local_port=nil)
143
+ sock = udp_connect(host,port,local_host,local_port)
144
+
145
+ yield sock if block_given?
146
+
147
+ sock.close
148
+ return nil
149
+ end
150
+
151
+ #
152
+ # Reads the banner from the service running on the given host and port.
153
+ #
154
+ # @param [String] host
155
+ # The host to connect to.
156
+ #
157
+ # @param [Integer] port
158
+ # The port to connect to.
159
+ #
160
+ # @param [String] local_host (nil)
161
+ # The local host to bind to.
162
+ #
163
+ # @param [Integer] local_port (nil)
164
+ # The local port to bind to.
165
+ #
166
+ # @yield [banner]
167
+ # If a block is given, it will be passed the grabbed banner.
168
+ #
169
+ # @yieldparam [String] banner
170
+ # The grabbed banner.
171
+ #
172
+ # @return [String]
173
+ # The grabbed banner.
174
+ #
175
+ # @api public
176
+ #
177
+ def udp_banner(host,port,local_host=nil,local_port=nil)
178
+ banner = nil
179
+
180
+ udp_session(host,port,local_host,local_port) do |sock|
181
+ banner = sock.readline
182
+ end
183
+
184
+ yield banner if block_given?
185
+ return banner
186
+ end
187
+
188
+ #
189
+ # Creates a new UDPServer listening on a given host and port.
190
+ #
191
+ # @param [Integer] port
192
+ # The local port to listen on.
193
+ #
194
+ # @param [String] host ('0.0.0.0')
195
+ # The host to bind to.
196
+ #
197
+ # @return [UDPServer]
198
+ # The new UDP server.
199
+ #
200
+ # @example
201
+ # udp_server(1337)
202
+ #
203
+ # @api public
204
+ #
205
+ def udp_server(port,host='0.0.0.0')
206
+ host = host.to_s
207
+ server = UDPSocket.new
208
+
209
+ server.bind(host,port)
210
+
211
+ yield server if block_given?
212
+ return server
213
+ end
214
+
215
+ #
216
+ # Creates a new temporary UDPServer listening on a given host and port.
217
+ #
218
+ # @param [Integer] port
219
+ # The local port to bind to.
220
+ #
221
+ # @param [String] host ('0.0.0.0')
222
+ # The host to bind to.
223
+ #
224
+ # @yield [server]
225
+ # The block which will be called after the server has been created.
226
+ # After the block has finished, the server will be closed.
227
+ #
228
+ # @yieldparam [UDPServer] server
229
+ # The newly created UDP server.
230
+ #
231
+ # @return [nil]
232
+ #
233
+ # @example
234
+ # udp_server_session(1337) do |server|
235
+ # data, sender = server.recvfrom(1024)
236
+ # end
237
+ #
238
+ # @api public
239
+ #
240
+ def udp_server_session(port,host='0.0.0.0',&block)
241
+ server = udp_server(port,host,&block)
242
+
243
+ server.close()
244
+ return nil
245
+ end
246
+ end
247
+ end
248
+ end
data/lib/ronin/support.rb CHANGED
@@ -19,11 +19,10 @@
19
19
 
20
20
  require 'ronin/extensions'
21
21
  require 'ronin/formatting'
22
+ require 'ronin/fuzzing'
22
23
  require 'ronin/network'
23
24
  require 'ronin/path'
24
25
  require 'ronin/templates'
25
- require 'ronin/ui/output'
26
26
  require 'ronin/support/inflector'
27
+ require 'ronin/support/support'
27
28
  require 'ronin/support/version'
28
-
29
- include Ronin::UI::Output::Helpers
@@ -0,0 +1,38 @@
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/ui/output'
21
+ require 'ronin/network'
22
+
23
+ module Ronin
24
+ #
25
+ # The main namespace for `ronin-support`.
26
+ #
27
+ module Support
28
+ include UI::Output::Helpers
29
+ include Network::TCP
30
+ include Network::UDP
31
+ include Network::SMTP
32
+ include Network::ESMTP
33
+ include Network::POP3
34
+ include Network::IMAP
35
+ include Network::Telnet
36
+ include Network::HTTP
37
+ end
38
+ end
@@ -20,6 +20,6 @@
20
20
  module Ronin
21
21
  module Support
22
22
  # ronin-support version
23
- VERSION = '0.3.0'
23
+ VERSION = '0.4.0.rc1'
24
24
  end
25
25
  end