Module: Net

Public Visibility

Public Class Method Summary

esmtp_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the ESMTP server.

Returns: Net::SMTP

esmtp_message(options = {}, &block)
esmtp_session(host, options = {}, &block) {|session| ... }

Starts an ESMTP session with the ESMTP enabled server.

http_copy(options = {}, &block) {|response| ... }

Performes an HTTP Copy request with the given options.

Returns: Net::HTTP::Response

http_delete(options = {}, &block) {|response| ... }

Performes an HTTP Delete request with the given options.

Returns: Net::HTTP::Response

http_get(options = {}, &block) {|response| ... }

Performes an HTTP Get request with the given options.

Returns: Net::HTTP::Response

http_get_body(options = {}, &block) {|response| ... }

Performes an HTTP Get request with the given options.

Returns: String

http_head(options = {}, &block) {|response| ... }

Performes an HTTP Head request with the given options.

Returns: Net::HTTP::Response

http_lock(options = {}, &block) {|response| ... }

Performes an HTTP Lock request with the given options.

Returns: Net::HTTP::Response

http_mkcol(options = {}, &block) {|response| ... }

Performes an HTTP Mkcol request with the given options.

Returns: Net::HTTP::Response

http_move(options = {}, &block) {|response| ... }

Performes an HTTP Move request with the given options.

Returns: Net::HTTP::Response

http_ok?(options = {})

Checks if the response has an HTTP OK status code.

Returns: Boolean

http_options(options = {}, &block) {|response| ... }

Performes an HTTP Options request with the given options.

Returns: Net::HTTP::Response

http_post(options = {}, &block) {|response| ... }

Performes an HTTP Post request with the given options.

Returns: Net::HTTP::Response

http_post_body(options = {}, &block) {|response| ... }

Performes an HTTP Post request with the given options.

Returns: String

http_powered_by(options = {})

Sends an HTTP Head request using the given options and returns the.

Returns: String

http_prop_find(options = {}, &block) {|response| ... }

Performes an HTTP Propfind request with the given options.

Returns: Net::HTTP::Response

http_prop_patch(options = {}, &block) {|response| ... }

Performes an HTTP Proppatch request with the given options.

Returns: Net::HTTP::Response

http_request(options = {}, &block) {|request, options| ... }

Connects to the HTTP server and sends an HTTP Request using the given.

Returns: Net::HTTP::Response

http_server(options = {})

Sends a HTTP Head request using the given options and returns the.

Returns: String

http_session(options = {}, &block) {|session| ... }

Connects to the HTTP server using the given options.

Returns: Net::HTTP

http_trace(options = {}, &block) {|response| ... }

Performes an HTTP Trace request with the given options.

Returns: Net::HTTP::Response

http_unlock(options = {}, &block) {|response| ... }

Performes an HTTP Unlock request with the given options.

Returns: Net::HTTP::Response

imap_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the IMAP server.

Returns: Net::IMAP

imap_session(host, options = {}, &block) {|session| ... }

Starts an IMAP session with the IMAP server.

pop3_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the POP3 server.

Returns: Net::POP3

pop3_session(host, options = {}, &block) {|session| ... }

Starts a session with the POP3 server.

smtp_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the SMTP server.

Returns: Net::SMTP

smtp_message(options = {}, &block)
smtp_session(host, options = {}, &block) {|session| ... }

Starts a session with the SMTP server.

tcp_banner(host, port, local_host = nil, local_port = nil, &block) {|banner| ... }

Connects to the specified host and port with the given.

Returns: String

tcp_connect(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port.

Returns: TCPSocket

tcp_connect_and_send(data, host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port, and.

tcp_send(data, host, port, local_host = nil, local_port = nil)

Connects to the specified host and port with the given local_host.

Returns: true

tcp_server(port, host = '0.0.0.0', &block)

Creates a new TCPServer listening on the specified host and port.

Returns: TCPServer

tcp_server_session(port, host = '0.0.0.0', &block) {|server| ... }

Creates a new TCPServer listening on the specified host and port,.

Returns: nil

tcp_session(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port.

tcp_single_server(port, host = '0.0.0.0', &block) {|client| ... }

Creates a new TCPServer listening on the specified host and port,.

Returns: nil

telnet_connect(host, options = {}, &block) {|session| ... }

Creates a new Telnet connection.

Returns: Net::Telnet

telnet_session(host, options = {}, &block) {|session| ... }

Starts a new Telnet session.

udp_banner(host, port, local_host = nil, local_port = nil, &block) {|banner| ... }

Connects to the specified host and port with the given local_host.

Returns: String

udp_connect(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port.

Returns: UDPSocket

udp_connect_and_send(data, host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port, and.

Returns: UDPSocket

udp_server(port, host = '0.0.0.0', &block)

Creates a new UDPServer listening on the specified host and port.

Returns: UDPServer

udp_server_session(port, host = '0.0.0.0', &block) {|server| ... }

Creates a new UDPServer listening on the specified host and port,.

Returns: nil

udp_session(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port.

Public Class Method Details

esmtp_connect

public Net::SMTP esmtp_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the ESMTP server.

Meta Tags

Parameters:

[String] host

The host to connect to.

Options Hash options
Key Name Default Value Accepted Types Description
:port Ronin::Network::SMTP.default_port [Integer]

The port to connect to.

:helo N/A [String]

The HELO domain.

:auth N/A [Symbol]

The type of authentication to use. Can be either :login, :plain, or :cram_md5.

:user N/A [String]

The user-name to authenticate with.

:password N/A [String]

The password to authenticate with.

Yields:

[session]

If a block is given, it will be passed an ESMTP enabled session object.

Yield Parameters:

[Net::SMTP] session

The ESMTP session.

Returns:

[Net::SMTP]

The ESMTP enabled session.

[View source]


65
66
67
68
69
70
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 65

def Net.esmtp_connect(host,options={},&block)
  Net.smtp_connect(host,options) do |sess|
    sess.esmtp = true
    block.call(sess)
  end
end

esmtp_message

public esmtp_message(options = {}, &block)

Meta Tags

[View source]


27
28
29
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 27

def Net.esmtp_message(options={},&block)
  Net.smtp_message(options,&block)
end

esmtp_session

public esmtp_session(host, options = {}, &block) {|session| ... }

Starts an ESMTP session with the ESMTP enabled server.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Hash] options

Additional options.

Yields:

[session]

If a block is given, it will be passed an ESMTP enabled session object. After the block has returned, the session will be closed.

Yield Parameters:

[Net::SMTP] session

The ESMTP session.

See Also:

Net.esmtp_connect
[View source]


90
91
92
93
94
95
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 90

def Net.esmtp_session(host,options={},&block)
  Net.smtp_session(host,options) do |sess|
    sess.esmtp = true
    block.call(sess)
  end
end

http_copy

public Net::HTTP::Response http_copy(options = {}, &block) {|response| ... }

Performes an HTTP Copy request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


156
157
158
159
160
161
# File 'lib/ronin/network/extensions/http/net.rb', line 156

def Net.http_copy(options={},&block)
  resp = Net.http_request(options.merge(:method => :copy))

  block.call(resp) if block
  return resp
end

http_delete

public Net::HTTP::Response http_delete(options = {}, &block) {|response| ... }

Performes an HTTP Delete request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/ronin/network/extensions/http/net.rb', line 182

def Net.http_delete(options={},&block)
  original_headers = options[:headers]

  # set the HTTP Depth header
  options[:headers] = {:depth => 'Infinity'}

  if original_headers
    options[:header].merge!(original_headers)
  end

  resp = Net.http_request(options.merge(:method => :delete))

  block.call(resp) if block
  return resp
end

http_get

public Net::HTTP::Response http_get(options = {}, &block) {|response| ... }

Performes an HTTP Get request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


217
218
219
220
221
222
# File 'lib/ronin/network/extensions/http/net.rb', line 217

def Net.http_get(options={},&block)
  resp = Net.http_request(options.merge(:method => :get))

  block.call(resp) if block
  return resp
end

http_get_body

public String http_get_body(options = {}, &block) {|response| ... }

Performes an HTTP Get request with the given options. If a block is given, it will be passed the response body from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[String]

The body of the HTTP response.

See Also:

http_request
[View source]


243
244
245
# File 'lib/ronin/network/extensions/http/net.rb', line 243

def Net.http_get_body(options={},&block)
  Net.http_get(options,&block).body
end

http_head

public Net::HTTP::Response http_head(options = {}, &block) {|response| ... }

Performes an HTTP Head request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


266
267
268
269
270
271
# File 'lib/ronin/network/extensions/http/net.rb', line 266

def Net.http_head(options={},&block)
  resp = Net.http_request(options.merge(:method => :head))

  block.call(resp) if block
  return resp
end

http_lock

public Net::HTTP::Response http_lock(options = {}, &block) {|response| ... }

Performes an HTTP Lock request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


345
346
347
348
349
350
# File 'lib/ronin/network/extensions/http/net.rb', line 345

def Net.http_lock(options={},&block)
  resp = Net.http_request(options.merge(:method => :lock))

  block.call(resp) if block
  return resp
end

http_mkcol

public Net::HTTP::Response http_mkcol(options = {}, &block) {|response| ... }

Performes an HTTP Mkcol request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


371
372
373
374
375
376
# File 'lib/ronin/network/extensions/http/net.rb', line 371

def Net.http_mkcol(options={},&block)
  resp = Net.http_request(options.merge(:method => :mkcol))

  block.call(resp) if block
  return resp
end

http_move

public Net::HTTP::Response http_move(options = {}, &block) {|response| ... }

Performes an HTTP Move request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


397
398
399
400
401
402
# File 'lib/ronin/network/extensions/http/net.rb', line 397

def Net.http_move(options={},&block)
  resp = Net.http_request(options.merge(:method => :move))

  block.call(resp) if block
  return resp
end

http_ok?

public Boolean http_ok?(options = {})

Checks if the response has an HTTP OK status code.

Meta Tags

Parameters:

[Hash] options

Additional options.

Returns:

[Boolean]

Specifies wether the response had an HTTP OK status code or not.

See Also:

http_request
[View source]


284
285
286
# File 'lib/ronin/network/extensions/http/net.rb', line 284

def Net.http_ok?(options={})
  Net.http_head(options).code == 200
end

http_options

public Net::HTTP::Response http_options(options = {}, &block) {|response| ... }

Performes an HTTP Options request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


423
424
425
426
427
428
# File 'lib/ronin/network/extensions/http/net.rb', line 423

def Net.http_options(options={},&block)
  resp = Net.http_request(options.merge(:method => :options))

  block.call(resp) if block
  return resp
end

http_post

public Net::HTTP::Response http_post(options = {}, &block) {|response| ... }

Performes an HTTP Post request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:postdata N/A [String]

The POSTDATA to send with the HTTP Post request.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/ronin/network/extensions/http/net.rb', line 452

def Net.http_post(options={},&block)
  options = options.merge(:method => :post)
  postdata = options.delete(:postdata)

  if options[:url]
    url = URI(options[:url].to_s)
    postdata ||= url.query_params
  end

  resp = Net.http_request(options) do |req,expanded_options|
    req.set_form_data(postdata) if postdata
  end

  block.call(resp) if block
  return resp
end

http_post_body

public String http_post_body(options = {}, &block) {|response| ... }

Performes an HTTP Post request with the given options. If a block is given, it will be passed the response body from the HTTP server.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:postdata N/A [String]

The POSTDATA to send with the HTTP Post request.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[String]

The body of the HTTP response.

See Also:

http_request
[View source]


491
492
493
# File 'lib/ronin/network/extensions/http/net.rb', line 491

def Net.http_post_body(options={},&block)
  Net.http_post(options,&block).body
end

http_powered_by

public String http_powered_by(options = {})

Sends an HTTP Head request using the given options and returns the HTTP X-Powered-By header.

Meta Tags

Parameters:

[Hash] options

Additional options.

Returns:

[String]

The HTTP X-Powered-By header.

See Also:

http_request
[View source]


316
317
318
319
320
321
322
323
324
# File 'lib/ronin/network/extensions/http/net.rb', line 316

def Net.http_powered_by(options={})
  resp = Net.http_head(options)

  if resp.code != 200
    resp = Net.http_get(options)
  end

  return resp['x-powered-by']
end

http_prop_find

public Net::HTTP::Response http_prop_find(options = {}, &block) {|response| ... }

Performes an HTTP Propfind request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
# File 'lib/ronin/network/extensions/http/net.rb', line 514

def Net.http_prop_find(options={},&block)
  original_headers = options[:headers]

  # set the HTTP Depth header
  options[:headers] = {:depth => '0'}

  if original_headers
    options[:header].merge!(original_headers)
  end

  resp = Net.http_request(options.merge(:method => :propfind))

  block.call(resp) if block
  return resp
end

http_prop_patch

public Net::HTTP::Response http_prop_patch(options = {}, &block) {|response| ... }

Performes an HTTP Proppatch request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


549
550
551
552
553
554
# File 'lib/ronin/network/extensions/http/net.rb', line 549

def Net.http_prop_patch(options={},&block)
  resp = Net.http_request(options.merge(:method => :proppatch))

  block.call(resp) if block
  return resp
end

http_request

public Net::HTTP::Response http_request(options = {}, &block) {|request, options| ... }

Connects to the HTTP server and sends an HTTP Request using the given options. If a block is given it will be passed the newly created HTTP Request object.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:method N/A [Symbol, String]

The HTTP method to use in the request.

:headers N/A [Hash]

The Hash of the HTTP headers to send with the request. May contain either Strings or Symbols, lower-case or camel-case keys.

Yields:

[request, (options)]

If a block is given, it will be passed the HTTP request object. If the block has an arity of 2, it will also be passed the expanded version of the given options.

Yield Parameters:

[Net::HTTP::Request] request

The HTTP request object to use in the request.

[Hash] options

The expanded version of the given options.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_session
[View source]


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ronin/network/extensions/http/net.rb', line 115

def Net.http_request(options={},&block)
  resp = nil

  Net.http_session(options) do |http,expanded_options|
    http_body = expanded_options.delete(:body)

    req = Ronin::Network::HTTP.request(expanded_options)

    if block
      if block.arity == 2
        block.call(req,expanded_options)
      else
        block.call(req)
      end
    end

    resp = http.request(req,http_body)
  end

  return resp
end

http_server

public String http_server(options = {})

Sends a HTTP Head request using the given options and returns the HTTP Server header.

Meta Tags

Parameters:

[Hash] options

Additional options.

Returns:

[String]

The HTTP Server header.

See Also:

http_request
[View source]


300
301
302
# File 'lib/ronin/network/extensions/http/net.rb', line 300

def Net.http_server(options={})
  Net.http_head(options)['server']
end

http_session

public Net::HTTP http_session(options = {}, &block) {|session| ... }

Connects to the HTTP server using the given options.

Meta Tags

Parameters:

Options Hash options
Key Name Default Value Accepted Types Description
:url N/A [String, URI::HTTP]

The full URL to request.

:user N/A [String]

The user to authenticate with when connecting to the HTTP server.

:password N/A [String]

The password to authenticate with when connecting to the HTTP server.

:host N/A [String]

The host the HTTP server is running on.

:port Net::HTTP.default_port [Integer]

The port the HTTP server is listening on.

:path N/A [String]

The path to request from the HTTP server.

:proxy Ronin::Network::HTTP.proxy [String, Hash]

A Hash of proxy settings to use when connecting to the HTTP server.

Yields:

[session]

If a block is given, it will be passed the newly created HTTP session object.

Yield Parameters:

[Net::HTTP] session

The newly created HTTP session.

Returns:

[Net::HTTP]

The HTTP session object.

[View source]


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ronin/network/extensions/http/net.rb', line 64

def Net.http_session(options={},&block)
  options = Ronin::Network::HTTP.expand_options(options)

  host = options[:host]
  port = options[:port]
  proxy = options[:proxy]

  sess = Net::HTTP::Proxy(proxy[:host],proxy[:port],proxy[:user],proxy[:pass]).start(host,port)

  if block
    if block.arity == 2
      block.call(sess,options)
    else
      block.call(sess)
    end
  end

  return sess
end

http_trace

public Net::HTTP::Response http_trace(options = {}, &block) {|response| ... }

Performes an HTTP Trace request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


575
576
577
578
579
580
# File 'lib/ronin/network/extensions/http/net.rb', line 575

def Net.http_trace(options={},&block)
  resp = Net.http_request(options.merge(:method => :trace))

  block.call(resp) if block
  return resp
end

http_unlock

public Net::HTTP::Response http_unlock(options = {}, &block) {|response| ... }

Performes an HTTP Unlock request with the given options. If a block is given, it will be passed the response from the HTTP server.

Meta Tags

Parameters:

[Hash] options

Additional options.

Yields:

[response]

If a block is given, it will be passed the response received from the request.

Yield Parameters:

[Net::HTTP::Response] response

The HTTP response object.

Returns:

[Net::HTTP::Response]

The response of the HTTP request.

See Also:

http_request
[View source]


601
602
603
604
605
606
# File 'lib/ronin/network/extensions/http/net.rb', line 601

def Net.http_unlock(options={},&block)
  resp = Net.http_request(options.merge(:method => :unlock))

  block.call(resp) if block
  return resp
end

imap_connect

public Net::IMAP imap_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the IMAP server.

Meta Tags

Parameters:

[String] host

The host to connect to.

Options Hash options
Key Name Default Value Accepted Types Description
:port IMAP.default_port [Integer]

The port the IMAP server is running on.

:certs N/A [String]

The path to the file containing CA certs of the server.

:auth N/A [Symbol]

The type of authentication to perform when connecting to the server. May be either :login or :cram_md5.

:user N/A [String]

The user to authenticate as when connecting to the server.

:password N/A [String]

The password to authenticate with when connecting to the server.

Yields:

[session]

If a block is given, it will be passed the newly created IMAP session.

Yield Parameters:

[Net::IMAP] session

The newly created IMAP session object.

Returns:

[Net::IMAP]

The newly created IMAP session object.

[View source]


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ronin/network/extensions/imap/net.rb', line 61

def Net.imap_connect(host,options={},&block)
  port = (options[:port] || Ronin::Net::IMAP.default_port)
  certs = options[:certs]
  auth = options[:auth]
  user = options[:user]
  passwd = options[:password]

  if options[:ssl]
    ssl = true
    ssl_certs = options[:ssl][:certs]
    ssl_verify = options[:ssl][:verify]
  else
    ssl = false
    ssl_verify = false
  end

  sess = Net::IMAP.new(host,port,ssl,ssl_certs,ssl_verify)

  if user
    if auth==:cram_md5
      sess.authenticate('CRAM-MD5',user,passwd)
    else
      sess.authenticate('LOGIN',user,passwd)
    end
  end

  block.call(sess) if block
  return sess
end

imap_session

public imap_session(host, options = {}, &block) {|session| ... }

Starts an IMAP session with the IMAP server.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Hash] options

Additional options.

Yields:

[session]

If a block is given, it will be passed the newly created IMAP session. After the block has returned, the session will be closed.

Yield Parameters:

[Net::IMAP] session

The newly created IMAP session object.

See Also:

Net.imap_connect
[View source]


109
110
111
112
113
114
115
116
117
118
# File 'lib/ronin/network/extensions/imap/net.rb', line 109

def Net.imap_session(host,options={},&block)
  Net.imap_connect(host,options) do |sess|
    block.call(sess) if block
    sess.logout if options[:user]
    sess.close
    sess.disconnect
  end

  return nil
end

pop3_connect

public Net::POP3 pop3_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the POP3 server.

Meta Tags

Parameters:

[String] host

The host to connect to.

Options Hash options
Key Name Default Value Accepted Types Description
:port Ronin::Network::POP3.default_port [Integer]

The port the POP3 server is running on.

:user N/A [String]

The user to authenticate with when connecting to the POP3 server.

:password N/A [String]

The password to authenticate with when connecting to the POP3 server.

Yields:

[session]

If a block is given, it will be passed the newly created POP3 session.

Yield Parameters:

[Net::POP3] session

The newly created POP3 session.

Returns:

[Net::POP3]

The newly created POP3 session.

[View source]


54
55
56
57
58
59
60
61
62
# File 'lib/ronin/network/extensions/pop3/net.rb', line 54

def Net.pop3_connect(host,options={},&block)
  port = (options[:port] || Ronin::Network::POP3.default_port)
  user = options[:user]
  password = options[:password]

  sess Net::POP3.start(host,port,user,password)
  block.call(sess) if block
  return sess
end

pop3_session

public pop3_session(host, options = {}, &block) {|session| ... }

Starts a session with the POP3 server.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Hash] options

Additional options.

Yields:

[session]

If a block is given, it will be passed the newly created POP3 session. After the block has returned, the session will be closed.

Yield Parameters:

[Net::POP3] session

The newly created POP3 session.

[View source]


80
81
82
83
84
85
86
87
# File 'lib/ronin/network/extensions/pop3/net.rb', line 80

def Net.pop3_session(host,options={},&block)
  Net.pop3_connect(host,options) do |sess|
    block.call(sess) if block
    sess.finish
  end

  return nil
end

smtp_connect

public Net::SMTP smtp_connect(host, options = {}, &block) {|session| ... }

Creates a connection to the SMTP server.

Meta Tags

Parameters:

[String] host

The host to connect to.

Options Hash options
Key Name Default Value Accepted Types Description
:port Ronin::Network::SMTP.default_port [Integer]

The port to connect to.

:helo N/A [String]

The HELO domain.

:auth N/A [Symbol]

The type of authentication to use. Can be either :login, :plain, or :cram_md5.

:user N/A [String]

The user-name to authenticate with.

:password N/A [String]

The password to authenticate with.

Yields:

[session]

If a block is given, it will be passed an SMTP session object.

Yield Parameters:

[Net::SMTP] session

The SMTP session.

Returns:

[Net::SMTP]

The SMTP session.

[View source]


67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ronin/network/extensions/smtp/net.rb', line 67

def Net.smtp_connect(host,options={},&block)
  port = (options[:port] || Ronin::Network::SMTP.default_port)

  helo = options[:helo]

  auth = options[:auth]
  user = options[:user]
  password = options[:password]

  sess = Net::SMTP.start(host,port,helo,user,password,auth)

  block.call(sess) if block
  return sess
end

smtp_message

public smtp_message(options = {}, &block)

Meta Tags

[View source]


29
30
31
# File 'lib/ronin/network/extensions/smtp/net.rb', line 29

def Net.smtp_message(options={},&block)
  Ronin::Network::SMTP.message(options,&block)
end

smtp_session

public smtp_session(host, options = {}, &block) {|session| ... }

Starts a session with the SMTP server.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Hash] options

Additional options.

Yields:

[session]

If a block is given, it will be passed an SMTP session object. After the block has returned, the session will be closed.

Yield Parameters:

[Net::SMTP] session

The SMTP session.

See Also:

Net.smtp_connect
[View source]


100
101
102
103
104
105
106
107
# File 'lib/ronin/network/extensions/smtp/net.rb', line 100

def Net.smtp_session(host,options={},&block)
  Net.smtp_connect(host,options) do |sess|
    block.call(sess) if block
    sess.finish
  end

  return nil
end

tcp_banner

public String tcp_banner(host, port, local_host = nil, local_port = nil, &block) {|banner| ... }

Connects to the specified host and port with the given local_host and local_port, reads the banner then closes the connection.

Meta Tags

Example:

  Net.tcp_banner('pop.gmail.com',25)
  # => "220 mx.google.com ESMTP c20sm3096959rvf.1"

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[banner]

If a block is given, it will be passed the grabbed banner.

Yield Parameters:

[String] banner

The grabbed banner.

Returns:

[String]

The grabbed banner.

[View source]


164
165
166
167
168
169
170
171
172
173
# File 'lib/ronin/network/extensions/tcp/net.rb', line 164

def Net.tcp_banner(host,port,local_host=nil,local_port=nil,&block)
   = nil

  Net.tcp_session(host,port,local_host,local_port) do |sock|
     = sock.readline.strip
  end

  block.call() if block
  return 
end

tcp_connect

public TCPSocket tcp_connect(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port and the given local_host and local_port.

Meta Tags

Examples

  Net.tcp_connect('www.hackety.org',80) # => TCPSocket
  Net.tcp_connect('www.wired.com',80) do |sock|
    sock.write("GET /\n\n")
    puts sock.readlines
    sock.close
  end

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket.

Yield Parameters:

[TCPsocket] socket

The newly created TCPSocket object.

Returns:

[TCPSocket]

The newly created TCPSocket object.

[View source]


59
60
61
62
63
64
# File 'lib/ronin/network/extensions/tcp/net.rb', line 59

def Net.tcp_connect(host,port,local_host=nil,local_port=nil,&block)
  sock = TCPSocket.new(host,port,local_host,local_port)
  block.call(sock) if block

  return sock
end

tcp_connect_and_send

public tcp_connect_and_send(data, host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port, and the given local_host and local_port. The specified data will then be written to the newly created TCPSocket.

Meta Tags

Parameters:

[String] data

The data to send through the connection.

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket.

Yield Parameters:

[TCPsocket] socket

The newly created TCPSocket object.

[View source]


92
93
94
95
96
97
98
# File 'lib/ronin/network/extensions/tcp/net.rb', line 92

def Net.tcp_connect_and_send(data,host,port,local_host=nil,local_port=nil,&block)
  Net.tcp_connect(host,port,local_host,local_port) do |sock|
    sock.write(data)

    block.call(sock) if block
  end
end

tcp_send

public true tcp_send(data, host, port, local_host = nil, local_port = nil)

Connects to the specified host and port with the given local_host and local_port, sends the specified data and then closes the connection.

Meta Tags

Example:

  buffer = "GET /" + ('A' * 4096) + "\n\r"
  Net.tcp_send(buffer,'victim.com',80)
  # => true

Parameters:

[String] data

The data to send through the connection.

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Returns:

[true]

The data was successfully sent.

[View source]


203
204
205
206
207
208
209
# File 'lib/ronin/network/extensions/tcp/net.rb', line 203

def Net.tcp_send(data,host,port,local_host=nil,local_port=nil)
  Net.tcp_session(host,port,local_host,local_port) do |sock|
    sock.write(data)
  end

  return true
end

tcp_server

public TCPServer tcp_server(port, host = '0.0.0.0', &block)

Creates a new TCPServer listening on the specified host and port.

Meta Tags

Example:

  Net.tcp_server(1337)

Parameters:

[Integer] port

The local port to listen on.

[String] host

The host to bind to.

Returns:

[TCPServer]

The new TCP server.

Since:

0.3.0

[View source]


228
229
230
231
232
233
234
# File 'lib/ronin/network/extensions/tcp/net.rb', line 228

def Net.tcp_server(port,host='0.0.0.0',&block)
  server = TCPServer.new(host,port)
  server.listen(3)

  block.call(server) if block
  return server
end

tcp_server_session

public nil tcp_server_session(port, host = '0.0.0.0', &block) {|server| ... }

Creates a new TCPServer listening on the specified host and port, passing it to the given block and then closing the server.

Meta Tags

Example:

  Net.tcp_server_session(1337) do |server|
    client1 = server.accept
    client2 = server.accept

    client2.write(server.read_line)

    client1.close
    client2.close
  end

Parameters:

[Integer] port

The local port to bind to.

[String] host

The host to bind to.

Yields:

[server]

The block which will be called after the server has been created. After the block has finished, the server will be closed.

Yield Parameters:

[TCPServer] server

The newly created TCP server.

Returns:

[nil]

Since:

0.3.0

[View source]


268
269
270
271
272
# File 'lib/ronin/network/extensions/tcp/net.rb', line 268

def Net.tcp_server_session(port,host='0.0.0.0',&block)
  server = Net.tcp_server(port,host,&block)
  server.close()
  return nil
end

tcp_session

public tcp_session(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new TCPSocket object with the specified host, port and the given local_host and local_port. If block is given, it will be passed the newly created TCPSocket object. After the TCPSocket object has been passed to the given block it will be closed.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket. After the block has returned, the socket will then be closed.

Yield Parameters:

[TCPsocket] socket

The newly created TCPSocket object.

[View source]


125
126
127
128
129
130
131
132
# File 'lib/ronin/network/extensions/tcp/net.rb', line 125

def Net.tcp_session(host,port,local_host=nil,local_port=nil,&block)
  Net.tcp_connect(host,port,local_host,local_port) do |sock|
    block.call(sock) if block
    sock.close
  end

  return nil
end

tcp_single_server

public nil tcp_single_server(port, host = '0.0.0.0', &block) {|client| ... }

Creates a new TCPServer listening on the specified host and port, then accepts only one client.

Meta Tags

Example:

  Net.tcp_single_server(1337) do |client|
    client.puts 'lol'
  end

Parameters:

[Integer] port

The local port to listen on.

[String] host

The host to bind to.

Yields:

[client]

The block which will be passed the newly connected client. After the block has finished, the client and the server will be closed.

Yield Parameters:

[TCPSocket] client

The newly connected client.

Returns:

[nil]

Since:

0.3.0

[View source]


301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/ronin/network/extensions/tcp/net.rb', line 301

def Net.tcp_single_server(port,host='0.0.0.0',&block)
  server = TCPServer.new(host,port)
  server.listen(1)

  client = server.accept

  block.call(client) if block

  client.close
  server.close
  return nil
end

telnet_connect

public Net::Telnet telnet_connect(host, options = {}, &block) {|session| ... }

Creates a new Telnet connection.

Meta Tags

Example:

  Net.telnet_connect('towel.blinkenlights.nl')
  # => #<Net::Telnet: ...>

Parameters:

[String] host

The host to connect to.

Options Hash options
Key Name Default Value Accepted Types Description
:port Ronin::Network::Telnet.default_port [Integer]

The port to connect to.

:binmode N/A [Boolean]

Indicates that newline substitution shall not be performed.

:output_log N/A [String]

The name of the file to write connection status messages and all received traffic to.

:dump_log N/A [String]

Similar to the :output_log option, but connection output is also written in hexdump format.

:prompt Ronin::Network::Telnet.default_prompt [Regexp]

A regular expression matching the host command-line prompt sequence, used to determine when a command has finished.

:telnet true [Boolean]

Indicates that the connection shall behave as a telnet connection.

:plain N/A [Boolean]

Indicates that the connection shall behave as a normal TCP connection.

:timeout Ronin::Network::Telnet.default_timeout [Integer]

The number of seconds to wait before timing out both the initial attempt to connect to host, and all attempts to read data from the host.

:wait_time N/A [Integer]

The amount of time to wait after seeing what looks like a prompt.

:proxy Ronin::Network::Telnet.proxy [Net::Telnet, IO]

A proxy object to used instead of opening a direct connection to the host.

:user N/A [String]

The user to login as.

:password N/A [String]

The password to login with.

Yields:

[session]

If a block is given, it will be passed the newly created Telnet session.

Yield Parameters:

[Net::Telnet] session

The newly created Telnet session.

Returns:

[Net::Telnet]

The Telnet session

[View source]


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ronin/network/extensions/telnet/net.rb', line 92

def Net.telnet_connect(host,options={},&block)
  sess_opts = {}
  sess_opts['Host'] = host
  sess_opts['Port'] = (options[:port] || Ronin::Network::Telnet.default_port)
  sess_opts['Binmode'] = options[:binmode]
  sess_opts['Output_log'] = options[:output_log]
  sess_opts['Dump_log'] = options[:dump_log]
  sess_opts['Prompt'] = (options[:prompt] || Ronin::Network::Telnet.default_prompt)

  if (options[:telnet] && !options[:plain])
    sess_opts['Telnetmode'] = true
  end

  sess_opts['Timeout'] = (options[:timeout] || Ronin::Network::Telnet.default_timeout)
  sess_opts['Waittime'] = options[:wait_time]
  sess_opts['Proxy'] = (options[:proxy] || Ronin::Network::Telnet.proxy)

  user = options[:user]
  passwd = options[:passwd]

  sess = Net::Telnet.new(sess_opts)
  sess.(user,passwd) if user

  block.call(sess) if block
  return sess
end

telnet_session

public telnet_session(host, options = {}, &block) {|session| ... }

Starts a new Telnet session.

Meta Tags

Example:

  Net.telnet_session('towel.blinkenlights.nl') do |movie|
    movie.each_line { |line| puts line }
  end

Parameters:

[String] host

The host to connect to.

[Hash] options

Additional options.

Yields:

[session]

If a block is given, it will be passed the newly created Telnet session. After the block has returned, the Telnet session will be closed.

Yield Parameters:

[Net::Telnet] session

The newly created Telnet session.

See Also:

Net.telnet_session
[View source]


143
144
145
146
147
148
149
150
# File 'lib/ronin/network/extensions/telnet/net.rb', line 143

def Net.telnet_session(host,options={},&block)
  Net.telnet_connect(host,options) do |sess|
    block.call(sess) if block
    sess.close
  end

  return nil
end

udp_banner

public String udp_banner(host, port, local_host = nil, local_port = nil, &block) {|banner| ... }

Connects to the specified host and port with the given local_host and local_port, reads the banner then closes the connection, returning the received banner.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[banner]

If a block is given, it will be passed the grabbed banner.

Yield Parameters:

[String] banner

The grabbed banner.

Returns:

[String]

The grabbed banner.

[View source]


160
161
162
163
164
165
166
167
# File 'lib/ronin/network/extensions/udp/net.rb', line 160

def Net.udp_banner(host,port,local_host=nil,local_port=nil,&block)
  Net.udp_session(host,port,local_host,local_port) do |sock|
     = sock.readline
  end

  block.call() if block
  return 
end

udp_connect

public UDPSocket udp_connect(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port and the given local_host and local_port.

Meta Tags

Examples

  Net.udp_connect('www.hackety.org',80)
  # => UDPSocket
  Net.udp_connect('www.wired.com',80) do |sock|
    puts sock.readlines
  end

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket.

Yield Parameters:

[UDPsocket] socket

The newly created UDPSocket object.

Returns:

[UDPSocket]

The newly created UDPSocket object.

[View source]


58
59
60
61
62
63
# File 'lib/ronin/network/extensions/udp/net.rb', line 58

def Net.udp_connect(host,port,local_host=nil,local_port=nil,&block)
  sock = UDPSocket.new(host,port,local_host,local_port)
  block.call(sock) if block

  return sock
end

udp_connect_and_send

public UDPSocket udp_connect_and_send(data, host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port, and the given local_host and local_port. The specified data will then be written to the newly created UDPSocket.

Meta Tags

Parameters:

[String] data

The data to send through the connection.

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket.

Yield Parameters:

[UDPsocket] socket

The newly created UDPSocket object.

Returns:

[UDPSocket]

The newly created UDPSocket object.

[View source]


94
95
96
97
98
99
100
# File 'lib/ronin/network/extensions/udp/net.rb', line 94

def Net.udp_connect_and_send(data,host,port,local_host=nil,local_port=nil,&block)
  Net.udp_connect(host,port,local_host,local_port) do |sock|
    sock.write(data)

    block.call(sock) if block
  end
end

udp_server

public UDPServer udp_server(port, host = '0.0.0.0', &block)

Creates a new UDPServer listening on the specified host and port.

Meta Tags

Example:

  Net.udp_server(1337)

Parameters:

[Integer] port

The local port to listen on.

[String] host

The host to bind to.

Returns:

[UDPServer]

The new UDP server.

Since:

0.3.0

[View source]


186
187
188
189
190
191
# File 'lib/ronin/network/extensions/udp/net.rb', line 186

def Net.udp_server(port,host='0.0.0.0',&block)
  server = UDPServer.new(host,port)

  block.call(server) if block
  return server
end

udp_server_session

public nil udp_server_session(port, host = '0.0.0.0', &block) {|server| ... }

Creates a new UDPServer listening on the specified host and port, passing it to the given block and then closing the server.

Meta Tags

Example:

  Net.udp_server_session(1337) do |server|
    data, sender = server.recvfrom(1024)
  end

Parameters:

[Integer] port

The local port to bind to.

[String] host

The host to bind to.

Yields:

[server]

The block which will be called after the server has been created. After the block has finished, the server will be closed.

Yield Parameters:

[UDPServer] server

The newly created UDP server.

Returns:

[nil]

Since:

0.3.0

[View source]


219
220
221
222
223
# File 'lib/ronin/network/extensions/udp/net.rb', line 219

def Net.udp_server_session(port,host='0.0.0.0',&block)
  server = Net.udp_server(port,host,&block)
  server.close()
  return nil
end

udp_session

public udp_session(host, port, local_host = nil, local_port = nil, &block) {|socket| ... }

Creates a new UDPSocket object with the specified host, port and the given local_host and local_port.

Meta Tags

Parameters:

[String] host

The host to connect to.

[Integer] port

The port to connect to.

[String] local_host

The local host to bind to.

[Integer] local_port

The local port to bind to.

Yields:

[socket]

If a block is given, it will be passed the newly created socket. After the block has returned, the socket will then be closed.

Yield Parameters:

[UDPsocket] socket

The newly created UDPSocket object.

[View source]


125
126
127
128
129
130
131
132
# File 'lib/ronin/network/extensions/udp/net.rb', line 125

def Net.udp_session(host,port,local_host=nil,local_port=nil,&block)
  Net.udp_connect(host,port,local_host,local_port) do |sock|
    block.call(sock) if block
    sock.close
  end

  return nil
end
Generated on Friday, September 25 2009 at 02:57:29 PM by YARD 0.2.3.5 (ruby-1.8.6).