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
Creates a connection to the ESMTP server.
65 66 67 68 69 70 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 65 def Net.esmtp_connect(host,={},&block) Net.smtp_connect(host,) do |sess| sess.esmtp = true block.call(sess) end end |
esmtp_message
27 28 29 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 27 def Net.(={},&block) Net.(,&block) end |
esmtp_session
Starts an ESMTP session with the ESMTP enabled server.
90 91 92 93 94 95 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 90 def Net.esmtp_session(host,={},&block) Net.smtp_session(host,) do |sess| sess.esmtp = true block.call(sess) end end |
http_copy
Performes an HTTP Copy request with the given options. If a block is given, it will be passed the response from the HTTP server.
156 157 158 159 160 161 |
# File 'lib/ronin/network/extensions/http/net.rb', line 156 def Net.http_copy(={},&block) resp = Net.http_request(.merge(:method => :copy)) block.call(resp) if block return resp end |
http_delete
Performes an HTTP Delete request with the given options. If a block is given, it will be passed the response from the HTTP server.
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(={},&block) original_headers = [:headers] # set the HTTP Depth header [:headers] = {:depth => 'Infinity'} if original_headers [:header].merge!(original_headers) end resp = Net.http_request(.merge(:method => :delete)) block.call(resp) if block return resp end |
http_get
Performes an HTTP Get request with the given options. If a block is given, it will be passed the response from the HTTP server.
217 218 219 220 221 222 |
# File 'lib/ronin/network/extensions/http/net.rb', line 217 def Net.http_get(={},&block) resp = Net.http_request(.merge(:method => :get)) block.call(resp) if block return resp end |
http_get_body
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.
243 244 245 |
# File 'lib/ronin/network/extensions/http/net.rb', line 243 def Net.http_get_body(={},&block) Net.http_get(,&block).body end |
http_head
Performes an HTTP Head request with the given options. If a block is given, it will be passed the response from the HTTP server.
266 267 268 269 270 271 |
# File 'lib/ronin/network/extensions/http/net.rb', line 266 def Net.http_head(={},&block) resp = Net.http_request(.merge(:method => :head)) block.call(resp) if block return resp end |
http_lock
Performes an HTTP Lock request with the given options. If a block is given, it will be passed the response from the HTTP server.
345 346 347 348 349 350 |
# File 'lib/ronin/network/extensions/http/net.rb', line 345 def Net.http_lock(={},&block) resp = Net.http_request(.merge(:method => :lock)) block.call(resp) if block return resp end |
http_mkcol
Performes an HTTP Mkcol request with the given options. If a block is given, it will be passed the response from the HTTP server.
371 372 373 374 375 376 |
# File 'lib/ronin/network/extensions/http/net.rb', line 371 def Net.http_mkcol(={},&block) resp = Net.http_request(.merge(:method => :mkcol)) block.call(resp) if block return resp end |
http_move
Performes an HTTP Move request with the given options. If a block is given, it will be passed the response from the HTTP server.
397 398 399 400 401 402 |
# File 'lib/ronin/network/extensions/http/net.rb', line 397 def Net.http_move(={},&block) resp = Net.http_request(.merge(:method => :move)) block.call(resp) if block return resp end |
http_ok?
Checks if the response has an HTTP OK status code.
284 285 286 |
# File 'lib/ronin/network/extensions/http/net.rb', line 284 def Net.http_ok?(={}) Net.http_head().code == 200 end |
http_options
Performes an HTTP Options request with the given options. If a block is given, it will be passed the response from the HTTP server.
423 424 425 426 427 428 |
# File 'lib/ronin/network/extensions/http/net.rb', line 423 def Net.(={},&block) resp = Net.http_request(.merge(:method => :options)) block.call(resp) if block return resp end |
http_post
Performes an HTTP Post request with the given options. If a block is given, it will be passed the response from the HTTP server.
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(={},&block) = .merge(:method => :post) postdata = .delete(:postdata) if [:url] url = URI([:url].to_s) postdata ||= url.query_params end resp = Net.http_request() do |req,| req.set_form_data(postdata) if postdata end block.call(resp) if block return resp end |
http_post_body
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.
491 492 493 |
# File 'lib/ronin/network/extensions/http/net.rb', line 491 def Net.http_post_body(={},&block) Net.http_post(,&block).body end |
http_powered_by
Sends an HTTP Head request using the given options and returns the HTTP X-Powered-By header.
316 317 318 319 320 321 322 323 324 |
# File 'lib/ronin/network/extensions/http/net.rb', line 316 def Net.http_powered_by(={}) resp = Net.http_head() if resp.code != 200 resp = Net.http_get() end return resp['x-powered-by'] end |
http_prop_find
Performes an HTTP Propfind request with the given options. If a block is given, it will be passed the response from the HTTP server.
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(={},&block) original_headers = [:headers] # set the HTTP Depth header [:headers] = {:depth => '0'} if original_headers [:header].merge!(original_headers) end resp = Net.http_request(.merge(:method => :propfind)) block.call(resp) if block return resp end |
http_prop_patch
Performes an HTTP Proppatch request with the given options. If a block is given, it will be passed the response from the HTTP server.
549 550 551 552 553 554 |
# File 'lib/ronin/network/extensions/http/net.rb', line 549 def Net.http_prop_patch(={},&block) resp = Net.http_request(.merge(:method => :proppatch)) block.call(resp) if block return resp end |
http_request
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.
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(={},&block) resp = nil Net.http_session() do |http,| http_body = .delete(:body) req = Ronin::Network::HTTP.request() if block if block.arity == 2 block.call(req,) else block.call(req) end end resp = http.request(req,http_body) end return resp end |
http_server
Sends a HTTP Head request using the given options and returns the HTTP Server header.
300 301 302 |
# File 'lib/ronin/network/extensions/http/net.rb', line 300 def Net.http_server(={}) Net.http_head()['server'] end |
http_session
Connects to the HTTP server using the given options.
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(={},&block) = Ronin::Network::HTTP.() host = [:host] port = [:port] proxy = [: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,) else block.call(sess) end end return sess end |
http_trace
Performes an HTTP Trace request with the given options. If a block is given, it will be passed the response from the HTTP server.
575 576 577 578 579 580 |
# File 'lib/ronin/network/extensions/http/net.rb', line 575 def Net.http_trace(={},&block) resp = Net.http_request(.merge(:method => :trace)) block.call(resp) if block return resp end |
http_unlock
Performes an HTTP Unlock request with the given options. If a block is given, it will be passed the response from the HTTP server.
601 602 603 604 605 606 |
# File 'lib/ronin/network/extensions/http/net.rb', line 601 def Net.http_unlock(={},&block) resp = Net.http_request(.merge(:method => :unlock)) block.call(resp) if block return resp end |
imap_connect
Creates a connection to the IMAP server.
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,={},&block) port = ([:port] || Ronin::Net::IMAP.default_port) certs = [:certs] auth = [:auth] user = [:user] passwd = [:password] if [:ssl] ssl = true ssl_certs = [:ssl][:certs] ssl_verify = [: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
Starts an IMAP session with the IMAP server.
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,={},&block) Net.imap_connect(host,) do |sess| block.call(sess) if block sess.logout if [:user] sess.close sess.disconnect end return nil end |
pop3_connect
Creates a connection to the POP3 server.
54 55 56 57 58 59 60 61 62 |
# File 'lib/ronin/network/extensions/pop3/net.rb', line 54 def Net.pop3_connect(host,={},&block) port = ([:port] || Ronin::Network::POP3.default_port) user = [:user] password = [:password] sess Net::POP3.start(host,port,user,password) block.call(sess) if block return sess end |
pop3_session
Starts a session with the POP3 server.
80 81 82 83 84 85 86 87 |
# File 'lib/ronin/network/extensions/pop3/net.rb', line 80 def Net.pop3_session(host,={},&block) Net.pop3_connect(host,) do |sess| block.call(sess) if block sess.finish end return nil end |
smtp_connect
Creates a connection to the SMTP server.
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,={},&block) port = ([:port] || Ronin::Network::SMTP.default_port) helo = [:helo] auth = [:auth] user = [:user] password = [:password] sess = Net::SMTP.start(host,port,helo,user,password,auth) block.call(sess) if block return sess end |
smtp_message
29 30 31 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 29 def Net.(={},&block) Ronin::Network::SMTP.(,&block) end |
smtp_session
Starts a session with the SMTP server.
100 101 102 103 104 105 106 107 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 100 def Net.smtp_session(host,={},&block) Net.smtp_connect(host,) do |sess| block.call(sess) if block sess.finish end return nil end |
tcp_banner
tcp_connect
Creates a new TCPSocket object with the specified host, port and the given local_host and local_port.
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
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.
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
Connects to the specified host and port with the given local_host and local_port, sends the specified data and then closes the connection.
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
Creates a new TCPServer listening on the specified host and port.
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
Creates a new TCPServer listening on the specified host and port, passing it to the given block and then closing the server.
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
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.
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
Creates a new TCPServer listening on the specified host and port, then accepts only one client.
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
Creates a new Telnet connection.
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,={},&block) sess_opts = {} sess_opts['Host'] = host sess_opts['Port'] = ([:port] || Ronin::Network::Telnet.default_port) sess_opts['Binmode'] = [:binmode] sess_opts['Output_log'] = [:output_log] sess_opts['Dump_log'] = [:dump_log] sess_opts['Prompt'] = ([:prompt] || Ronin::Network::Telnet.default_prompt) if ([:telnet] && ![:plain]) sess_opts['Telnetmode'] = true end sess_opts['Timeout'] = ([:timeout] || Ronin::Network::Telnet.default_timeout) sess_opts['Waittime'] = [:wait_time] sess_opts['Proxy'] = ([:proxy] || Ronin::Network::Telnet.proxy) user = [:user] passwd = [:passwd] sess = Net::Telnet.new(sess_opts) sess.login(user,passwd) if user block.call(sess) if block return sess end |
telnet_session
Starts a new Telnet session.
143 144 145 146 147 148 149 150 |
# File 'lib/ronin/network/extensions/telnet/net.rb', line 143 def Net.telnet_session(host,={},&block) Net.telnet_connect(host,) do |sess| block.call(sess) if block sess.close end return nil end |
udp_banner
udp_connect
Creates a new UDPSocket object with the specified host, port and the given local_host and local_port.
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
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.
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
Creates a new UDPServer listening on the specified host and port.
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
Creates a new UDPServer listening on the specified host and port, passing it to the given block and then closing the server.
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
Creates a new UDPSocket object with the specified host, port and the given local_host and local_port.
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 |