ronin-support 0.4.1 → 0.5.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/ChangeLog.md +75 -32
  2. data/Gemfile +17 -18
  3. data/README.md +9 -10
  4. data/Rakefile +10 -2
  5. data/gemspec.yml +1 -1
  6. data/lib/ronin/binary.rb +21 -0
  7. data/lib/ronin/binary/hexdump.rb +20 -0
  8. data/lib/ronin/binary/hexdump/parser.rb +411 -0
  9. data/lib/ronin/binary/struct.rb +579 -0
  10. data/lib/ronin/binary/template.rb +437 -0
  11. data/lib/ronin/extensions/ip_addr.rb +17 -13
  12. data/lib/ronin/extensions/regexp.rb +45 -0
  13. data/lib/ronin/extensions/string.rb +3 -3
  14. data/lib/ronin/formatting/extensions/binary.rb +1 -0
  15. data/lib/ronin/formatting/extensions/binary/array.rb +63 -0
  16. data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
  17. data/lib/ronin/formatting/extensions/binary/file.rb +39 -6
  18. data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
  19. data/lib/ronin/formatting/extensions/binary/integer.rb +56 -43
  20. data/lib/ronin/formatting/extensions/binary/string.rb +75 -187
  21. data/lib/ronin/formatting/extensions/text/string.rb +61 -0
  22. data/lib/ronin/fuzzing/extensions/string.rb +21 -8
  23. data/lib/ronin/fuzzing/fuzzing.rb +19 -17
  24. data/lib/ronin/network.rb +2 -1
  25. data/lib/ronin/network/dns.rb +57 -15
  26. data/lib/ronin/network/extensions.rb +0 -1
  27. data/lib/ronin/network/ftp.rb +145 -0
  28. data/lib/ronin/network/http/http.rb +13 -14
  29. data/lib/ronin/network/imap.rb +11 -10
  30. data/lib/ronin/network/mixins.rb +1 -0
  31. data/lib/ronin/network/mixins/ftp.rb +155 -0
  32. data/lib/ronin/network/mixins/ssl.rb +1 -1
  33. data/lib/ronin/network/mixins/tcp.rb +39 -6
  34. data/lib/ronin/network/mixins/udp.rb +121 -1
  35. data/lib/ronin/network/mixins/unix.rb +279 -0
  36. data/lib/ronin/network/pop3.rb +5 -5
  37. data/lib/ronin/network/proxy.rb +578 -0
  38. data/lib/ronin/network/smtp/email.rb +1 -1
  39. data/lib/ronin/network/smtp/smtp.rb +7 -8
  40. data/lib/ronin/network/ssl.rb +1 -6
  41. data/lib/ronin/network/tcp.rb +2 -305
  42. data/lib/ronin/network/tcp/proxy.rb +377 -0
  43. data/lib/ronin/network/tcp/tcp.rb +435 -0
  44. data/lib/ronin/network/telnet.rb +27 -23
  45. data/lib/ronin/network/udp.rb +2 -266
  46. data/lib/ronin/network/udp/proxy.rb +169 -0
  47. data/lib/ronin/network/udp/udp.rb +442 -0
  48. data/lib/ronin/network/unix.rb +287 -0
  49. data/lib/ronin/path.rb +2 -2
  50. data/lib/ronin/spec/ui/output.rb +1 -7
  51. data/lib/ronin/support.rb +1 -0
  52. data/lib/ronin/support/inflector.rb +3 -7
  53. data/lib/ronin/support/support.rb +2 -1
  54. data/lib/ronin/support/version.rb +1 -1
  55. data/lib/ronin/ui/output/helpers.rb +13 -15
  56. data/lib/ronin/ui/output/output.rb +2 -2
  57. data/lib/ronin/ui/output/terminal/color.rb +10 -4
  58. data/lib/ronin/wordlist.rb +92 -17
  59. data/ronin-support.gemspec +38 -109
  60. data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
  61. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
  62. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
  63. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
  64. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
  65. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
  66. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
  67. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
  68. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
  69. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
  70. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
  71. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
  72. data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
  73. data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
  74. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
  75. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
  76. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
  77. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
  78. data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
  79. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
  80. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
  81. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
  82. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
  83. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
  84. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
  85. data/spec/binary/hexdump/parser_spec.rb +302 -0
  86. data/spec/binary/struct_spec.rb +496 -0
  87. data/spec/binary/template_spec.rb +400 -0
  88. data/spec/extensions/ip_addr_spec.rb +58 -32
  89. data/spec/extensions/regexp_spec.rb +60 -0
  90. data/spec/extensions/string_spec.rb +1 -1
  91. data/spec/formatting/binary/array_spec.rb +22 -0
  92. data/spec/formatting/binary/base64_spec.rb +50 -0
  93. data/spec/formatting/binary/float_spec.rb +30 -0
  94. data/spec/formatting/binary/integer_spec.rb +54 -40
  95. data/spec/formatting/binary/string_spec.rb +69 -182
  96. data/spec/formatting/text/string_spec.rb +30 -0
  97. data/spec/network/dns_spec.rb +64 -0
  98. data/spec/network/ftp_spec.rb +65 -0
  99. data/spec/network/proxy_spec.rb +121 -0
  100. data/spec/network/shared/unix_server.rb +31 -0
  101. data/spec/network/tcp/proxy_spec.rb +116 -0
  102. data/spec/network/{tcp_spec.rb → tcp/tcp_spec.rb} +24 -1
  103. data/spec/network/telnet_spec.rb +67 -0
  104. data/spec/network/{udp_spec.rb → udp/udp_spec.rb} +24 -1
  105. data/spec/network/unix_spec.rb +183 -0
  106. data/spec/wordlist_spec.rb +74 -13
  107. metadata +129 -85
  108. data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
@@ -0,0 +1,435 @@
1
+ #
2
+ # Copyright (c) 2006-2012 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 'socket'
21
+ require 'timeout'
22
+
23
+ module Ronin
24
+ module Network
25
+ #
26
+ # Provides helper methods for using the TCP protocol.
27
+ #
28
+ module TCP
29
+ #
30
+ # Tests whether a remote TCP port is open.
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 [String] local_host (nil)
39
+ # The local host to bind to.
40
+ #
41
+ # @param [Integer] local_port (nil)
42
+ # The local port to bind to.
43
+ #
44
+ # @param [Integer] timeout (5)
45
+ # The maximum time to attempt connecting.
46
+ #
47
+ # @return [Boolean, nil]
48
+ # Specifies whether the remote TCP port is open.
49
+ # If the connection was not accepted, `nil` will be returned.
50
+ #
51
+ # @api public
52
+ #
53
+ # @since 0.5.0
54
+ #
55
+ def tcp_open?(host,port,local_host=nil,local_port=nil,timeout=nil)
56
+ timeout ||= 5
57
+
58
+ begin
59
+ Timeout.timeout(timeout) do
60
+ tcp_session(host,port,local_host,local_port)
61
+ end
62
+
63
+ return true
64
+ rescue Timeout::Error
65
+ return nil
66
+ rescue SocketError, SystemCallError
67
+ return false
68
+ end
69
+ end
70
+
71
+ #
72
+ # Creates a new TCPSocket object connected to a given host and port.
73
+ #
74
+ # @param [String] host
75
+ # The host to connect to.
76
+ #
77
+ # @param [Integer] port
78
+ # The port to connect to.
79
+ #
80
+ # @param [String] local_host ('0.0.0.0')
81
+ # The local host to bind to.
82
+ #
83
+ # @param [Integer] local_port (nil)
84
+ # The local port to bind to.
85
+ #
86
+ # @yield [socket]
87
+ # If a block is given, it will be passed the newly created socket.
88
+ #
89
+ # @yieldparam [TCPsocket] socket
90
+ # The newly created TCPSocket object.
91
+ #
92
+ # @return [TCPSocket]
93
+ # The newly created TCPSocket object.
94
+ #
95
+ # @example
96
+ # tcp_connect('www.hackety.org',80) # => TCPSocket
97
+ #
98
+ # @example
99
+ # tcp_connect('www.wired.com',80) do |socket|
100
+ # socket.write("GET /\n\n")
101
+ #
102
+ # puts socket.readlines
103
+ # socket.close
104
+ # end
105
+ #
106
+ # @see http://rubydoc.info/stdlib/socket/TCPSocket
107
+ #
108
+ # @api public
109
+ #
110
+ def tcp_connect(host,port,local_host=nil,local_port=nil)
111
+ host = host.to_s
112
+ port = port.to_i
113
+ local_host = (local_host || '0.0.0.0').to_s
114
+ local_port = local_port.to_i
115
+
116
+ socket = TCPSocket.new(host,port,local_host,local_port)
117
+
118
+ yield socket if block_given?
119
+ return socket
120
+ end
121
+
122
+ #
123
+ # Creates a new TCPSocket object, connected to a given host and port.
124
+ # The given data will then be written to the newly created TCPSocket.
125
+ #
126
+ # @param [String] data
127
+ # The data to send through the connection.
128
+ #
129
+ # @param [String] host
130
+ # The host to connect to.
131
+ #
132
+ # @param [Integer] port
133
+ # The port to connect to.
134
+ #
135
+ # @param [String] local_host (nil)
136
+ # The local host to bind to.
137
+ #
138
+ # @param [Integer] local_port (nil)
139
+ # The local port to bind to.
140
+ #
141
+ # @yield [socket]
142
+ # If a block is given, it will be passed the newly created socket.
143
+ #
144
+ # @yieldparam [TCPSocket] socket
145
+ # The newly created TCPSocket object.
146
+ #
147
+ # @api public
148
+ #
149
+ def tcp_connect_and_send(data,host,port,local_host=nil,local_port=nil)
150
+ socket = tcp_connect(host,port,local_host,local_port)
151
+ socket.write(data)
152
+
153
+ yield socket if block_given?
154
+ return socket
155
+ end
156
+
157
+ #
158
+ # Creates a new temporary TCPSocket object, connected to the given host
159
+ # and port.
160
+ #
161
+ # @param [String] host
162
+ # The host to connect to.
163
+ #
164
+ # @param [Integer] port
165
+ # The port to connect to.
166
+ #
167
+ # @param [String] local_host (nil)
168
+ # The local host to bind to.
169
+ #
170
+ # @param [Integer] local_port (nil)
171
+ # The local port to bind to.
172
+ #
173
+ # @yield [socket]
174
+ # If a block is given, it will be passed the newly created socket.
175
+ # After the block has returned, the socket will then be closed.
176
+ #
177
+ # @yieldparam [TCPsocket] socket
178
+ # The newly created TCPSocket object.
179
+ #
180
+ # @return [nil]
181
+ #
182
+ # @api public
183
+ #
184
+ def tcp_session(host,port,local_host=nil,local_port=nil)
185
+ socket = tcp_connect(host,port,local_host,local_port)
186
+
187
+ yield socket if block_given?
188
+ socket.close
189
+ return nil
190
+ end
191
+
192
+ #
193
+ # Reads the banner from the service running on the given host and port.
194
+ #
195
+ # @param [String] host
196
+ # The host to connect to.
197
+ #
198
+ # @param [Integer] port
199
+ # The port to connect to.
200
+ #
201
+ # @param [String] local_host (nil)
202
+ # The local host to bind to.
203
+ #
204
+ # @param [Integer] local_port (nil)
205
+ # The local port to bind to.
206
+ #
207
+ # @yield [banner]
208
+ # If a block is given, it will be passed the grabbed banner.
209
+ #
210
+ # @yieldparam [String] banner
211
+ # The grabbed banner.
212
+ #
213
+ # @return [String]
214
+ # The grabbed banner.
215
+ #
216
+ # @example
217
+ # tcp_banner('pop.gmail.com',25)
218
+ # # => "220 mx.google.com ESMTP c20sm3096959rvf.1"
219
+ #
220
+ # @api public
221
+ #
222
+ def tcp_banner(host,port,local_host=nil,local_port=nil)
223
+ banner = nil
224
+
225
+ tcp_session(host,port,local_host,local_port) do |socket|
226
+ banner = socket.readline.strip
227
+ end
228
+
229
+ yield banner if block_given?
230
+ return banner
231
+ end
232
+
233
+ #
234
+ # Connects to a specified host and port, sends the given data and then
235
+ # closes the connection.
236
+ #
237
+ # @param [String] data
238
+ # The data to send through the connection.
239
+ #
240
+ # @param [String] host
241
+ # The host to connect to.
242
+ #
243
+ # @param [Integer] port
244
+ # The port to connect to.
245
+ #
246
+ # @param [String] local_host (nil)
247
+ # The local host to bind to.
248
+ #
249
+ # @param [Integer] local_port (nil)
250
+ # The local port to bind to.
251
+ #
252
+ # @return [true]
253
+ # The data was successfully sent.
254
+ #
255
+ # @example
256
+ # buffer = "GET /" + ('A' * 4096) + "\n\r"
257
+ # tcp_send(buffer,'victim.com',80)
258
+ # # => true
259
+ #
260
+ # @api public
261
+ #
262
+ def tcp_send(data,host,port,local_host=nil,local_port=nil)
263
+ tcp_session(host,port,local_host,local_port) do |socket|
264
+ socket.write(data)
265
+ end
266
+
267
+ return true
268
+ end
269
+
270
+ #
271
+ # Creates a new TCPServer listening on a given host and port.
272
+ #
273
+ # @param [Integer] port
274
+ # The local port to listen on.
275
+ #
276
+ # @param [String] host ('0.0.0.0')
277
+ # The host to bind to.
278
+ #
279
+ # @param [Integer] backlog (5)
280
+ # The maximum backlog of pending connections.
281
+ #
282
+ # @yield [server]
283
+ # The block which will be called after the server has been created.
284
+ #
285
+ # @yieldparam [TCPServer] server
286
+ # The newly created TCP server.
287
+ #
288
+ # @return [TCPServer]
289
+ # The new TCP server.
290
+ #
291
+ # @example
292
+ # tcp_server(1337)
293
+ #
294
+ # @see http://rubydoc.info/stdlib/socket/TCPServer
295
+ #
296
+ # @api public
297
+ #
298
+ def tcp_server(port=nil,host=nil,backlog=5)
299
+ port = port.to_i
300
+ host = (host || '0.0.0.0').to_s
301
+
302
+ server = TCPServer.new(host,port)
303
+ server.listen(backlog)
304
+
305
+ yield server if block_given?
306
+ return server
307
+ end
308
+
309
+ #
310
+ # Creates a new temporary TCPServer listening on a host and port.
311
+ #
312
+ # @param [Integer] port
313
+ # The local port to bind to.
314
+ #
315
+ # @param [String] host ('0.0.0.0')
316
+ # The host to bind to.
317
+ #
318
+ # @param [Integer] backlog (5)
319
+ # The maximum backlog of pending connections.
320
+ #
321
+ # @yield [server]
322
+ # The block which will be called after the server has been created.
323
+ # After the block has finished, the server will be closed.
324
+ #
325
+ # @yieldparam [TCPServer] server
326
+ # The newly created TCP server.
327
+ #
328
+ # @return [nil]
329
+ #
330
+ # @example
331
+ # tcp_server_session(1337) do |server|
332
+ # client1 = server.accept
333
+ # client2 = server.accept
334
+ #
335
+ # client2.write(server.read_line)
336
+ #
337
+ # client1.close
338
+ # client2.close
339
+ # end
340
+ #
341
+ # @api public
342
+ #
343
+ def tcp_server_session(port=nil,host=nil,backlog=5,&block)
344
+ server = tcp_server(port,host,backlog,&block)
345
+ server.close()
346
+ return nil
347
+ end
348
+
349
+ #
350
+ # Creates a new TCPServer listening on a given host and port,
351
+ # accepting clients in a loop.
352
+ #
353
+ # @param [Integer] port
354
+ # The local port to bind to.
355
+ #
356
+ # @param [String] host ('0.0.0.0')
357
+ # The host to bind to.
358
+ #
359
+ # @yield [client]
360
+ # The given block will be passed the newly connected client.
361
+ # After the block has finished, the client will be closed.
362
+ #
363
+ # @yieldparam [TCPSocket] client
364
+ # A newly connected client.
365
+ #
366
+ # @return [nil]
367
+ #
368
+ # @example
369
+ # tcp_server_loop(1337) do |client|
370
+ # client.puts 'lol'
371
+ # end
372
+ #
373
+ # @api public
374
+ #
375
+ # @since 0.5.0
376
+ #
377
+ def tcp_server_loop(port=nil,host=nil)
378
+ tcp_server_session(port,host) do |server|
379
+ loop do
380
+ client = server.accept
381
+
382
+ yield client if block_given?
383
+ client.close
384
+ end
385
+ end
386
+ end
387
+
388
+ #
389
+ # Creates a new TCPServer listening on a given host and port,
390
+ # accepts only one client and then stops listening.
391
+ #
392
+ # @param [Integer] port
393
+ # The local port to bind to.
394
+ #
395
+ # @param [String] host ('0.0.0.0')
396
+ # The host to bind to.
397
+ #
398
+ # @yield [client]
399
+ # The given block will be passed the newly connected client.
400
+ # After the block has finished, both the client and the server will be
401
+ # closed.
402
+ #
403
+ # @yieldparam [TCPSocket] client
404
+ # The newly connected client.
405
+ #
406
+ # @return [nil]
407
+ #
408
+ # @example
409
+ # tcp_accept(1337) do |client|
410
+ # client.puts 'lol'
411
+ # end
412
+ #
413
+ # @api public
414
+ #
415
+ # @since 0.5.0
416
+ #
417
+ def tcp_accept(port=nil,host=nil)
418
+ tcp_server_session(port,host,1) do |server|
419
+ client = server.accept
420
+
421
+ yield client if block_given?
422
+ client.close
423
+ end
424
+ end
425
+
426
+ #
427
+ # @deprecated
428
+ # Deprecated as of 0.5.0. Use {#tcp_accept} instead.
429
+ #
430
+ def tcp_single_server(port=nil,host=nil)
431
+ tcp_accept(port,host)
432
+ end
433
+ end
434
+ end
435
+ end
@@ -40,7 +40,7 @@ module Ronin
40
40
  #
41
41
  # @api public
42
42
  #
43
- def Telnet.default_port
43
+ def self.default_port
44
44
  @default_port ||= DEFAULT_PORT
45
45
  end
46
46
 
@@ -52,7 +52,7 @@ module Ronin
52
52
  #
53
53
  # @api public
54
54
  #
55
- def Telnet.default_port=(port)
55
+ def self.default_port=(port)
56
56
  @default_port = port
57
57
  end
58
58
 
@@ -62,7 +62,7 @@ module Ronin
62
62
  #
63
63
  # @api public
64
64
  #
65
- def Telnet.default_prompt
65
+ def self.default_prompt
66
66
  @default_prompt ||= DEFAULT_PROMPT
67
67
  end
68
68
 
@@ -74,7 +74,7 @@ module Ronin
74
74
  #
75
75
  # @api public
76
76
  #
77
- def Telnet.default_prompt=(prompt)
77
+ def self.default_prompt=(prompt)
78
78
  @default_prompt = prompt
79
79
  end
80
80
 
@@ -84,7 +84,7 @@ module Ronin
84
84
  #
85
85
  # @api public
86
86
  #
87
- def Telnet.default_timeout
87
+ def self.default_timeout
88
88
  @default_timeout ||= DEFAULT_TIMEOUT
89
89
  end
90
90
 
@@ -96,7 +96,7 @@ module Ronin
96
96
  #
97
97
  # @api public
98
98
  #
99
- def Telnet.default_timeout=(timeout)
99
+ def self.default_timeout=(timeout)
100
100
  @default_timeout = timeout
101
101
  end
102
102
 
@@ -106,7 +106,7 @@ module Ronin
106
106
  #
107
107
  # @api public
108
108
  #
109
- def Telnet.proxy
109
+ def self.proxy
110
110
  @proxy ||= nil
111
111
  end
112
112
 
@@ -118,7 +118,7 @@ module Ronin
118
118
  #
119
119
  # @api public
120
120
  #
121
- def Telnet.proxy=(new_proxy)
121
+ def self.proxy=(new_proxy)
122
122
  @proxy = new_proxy
123
123
  end
124
124
 
@@ -191,29 +191,33 @@ module Ronin
191
191
  # @api public
192
192
  #
193
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)
194
+ telnet_options = {
195
+ 'Host' => host.to_s,
196
+ 'Port' => (options[:port] || Telnet.default_port),
197
+ 'Binmode' => (options[:binmode] || false),
198
+ 'Waittime' => (options[:wait_time] || 0),
199
+ 'Prompt' => (options[:prompt] || Telnet.default_prompt),
200
+ 'Timeout' => (options[:timeout] || Telnet.default_timeout)
201
+ }
203
202
 
204
203
  if (options[:telnet] && !options[:plain])
205
204
  telnet_options['Telnetmode'] = true
206
205
  end
207
206
 
208
- telnet_options['Timeout'] = (options[:timeout] || Telnet.default_timeout)
209
- telnet_options['Waittime'] = options[:wait_time]
210
- telnet_options['Proxy'] = (options[:proxy] || Telnet.proxy)
207
+ if options[:output_log]
208
+ telnet_options['Output_log'] = options[:output_log]
209
+ end
211
210
 
212
- user = options[:user]
213
- passwd = options[:passwd]
211
+ if options[:dump_log]
212
+ telnet_options['Dump_log'] = options[:dump_log]
213
+ end
214
+
215
+ if (proxy = (options[:proxy] || Telnet.proxy))
216
+ telnet_options['Proxy'] = proxy
217
+ end
214
218
 
215
219
  session = Net::Telnet.new(telnet_options)
216
- session.login(user,passwd) if user
220
+ session.login(options[:user],options[:password]) if options[:user]
217
221
 
218
222
  yield session if block_given?
219
223
  return session