Module: Net
- Defined in:
- lib/ronin/network/extensions/ssl/net.rb,
lib/ronin/network/extensions/tcp/net.rb,
lib/ronin/network/extensions/udp/net.rb,
lib/ronin/network/extensions/http/net.rb,
lib/ronin/network/extensions/imap/net.rb,
lib/ronin/network/extensions/pop3/net.rb,
lib/ronin/network/extensions/smtp/net.rb,
lib/ronin/network/extensions/esmtp/net.rb,
lib/ronin/network/extensions/telnet/net.rb
Class Method Summary collapse
-
.esmtp_connect(host, options = {}) {|session| ... } ⇒ Net::SMTP
Creates a connection to the ESMTP server.
- .esmtp_message(options = {}, &block) ⇒ Object
-
.esmtp_session(host, options = {}) {|session| ... } ⇒ Object
Starts an ESMTP session with the ESMTP enabled server.
-
.http_connect(options = {}) {|session| ... } ⇒ Net::HTTP
Starts a HTTP connection with the server.
-
.http_copy(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Copy request.
-
.http_delete(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Delete request.
-
.http_get(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Get request.
-
.http_get_body(options = {}) ⇒ String
Performs an HTTP Get request and returns the Respond Body.
-
.http_get_headers(options = {}) ⇒ Hash{String => Array<String>}
Performs an HTTP Get request and returns the Response Headers.
-
.http_head(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Head request.
-
.http_lock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Lock request.
-
.http_mkcol(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Mkcol request.
-
.http_move(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Move request.
-
.http_ok?(options = {}) ⇒ Boolean
Checks if the response has an HTTP OK status code.
-
.http_options(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Options request.
-
.http_post(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Post request.
-
.http_post_body(options = {}) ⇒ String
Performs an HTTP Post request and returns the Response Body.
-
.http_post_headers(options = {}) ⇒ Hash{String => Array<String>}
Performs an HTTP Post request and returns the Response Headers.
-
.http_powered_by(options = {}) ⇒ String
Sends an HTTP Head request and returns the HTTP X-Powered-By header.
-
.http_prop_find(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Propfind request.
-
.http_prop_patch(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Proppatch request.
-
.http_request(options = {}) {|request, (options)| ... } ⇒ Net::HTTP::Response
Connects to the HTTP server and sends an HTTP Request.
-
.http_server(options = {}) ⇒ String
Sends a HTTP Head request and returns the HTTP Server header.
-
.http_session(options = {}) {|session| ... } ⇒ nil
Creates a new temporary HTTP session with the server.
-
.http_status(options = {}) ⇒ Integer
Returns the Status Code of the Response.
-
.http_trace(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Trace request.
-
.http_unlock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Unlock request.
-
.imap_connect(host, options = {}) {|session| ... } ⇒ Net::IMAP
Creates a connection to the IMAP server.
-
.imap_session(host, options = {}) {|session| ... } ⇒ nil
Starts an IMAP session with the IMAP server.
-
.pop3_connect(host, options = {}) {|session| ... } ⇒ Net::POP3
Creates a connection to the POP3 server.
-
.pop3_session(host, options = {}) {|session| ... } ⇒ nil
Starts a session with the POP3 server.
-
.smtp_connect(host, options = {}) {|session| ... } ⇒ Net::SMTP
Creates a connection to the SMTP server.
-
.smtp_message(options = {}) {|email| ... } ⇒ Object
Creates a new email message.
- .smtp_send_message(host, options = {}) {|email| ... } ⇒ Object
-
.smtp_session(host, options = {}) {|session| ... } ⇒ Object
Starts a session with the SMTP server.
-
.ssl_connect(host, port, options = {}) {|ssl_socket| ... } ⇒ OpenSSL::SSL::SSLSocket
Establishes a SSL connection.
-
.ssl_session(host, port) {|ssl_socket| ... } ⇒ nil
Creates a new temporary SSL connection.
-
.tcp_banner(host, port, local_host = nil, local_port = nil) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
-
.tcp_connect(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ TCPSocket
Creates a new TCPSocket object connected to a given host and port.
-
.tcp_connect_and_send(data, host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ Object
Creates a new TCPSocket object, connected to a given host and port.
-
.tcp_send(data, host, port, local_host = nil, local_port = nil) ⇒ true
Connects to a specified host and port, sends the given data and then closes the connection.
-
.tcp_server(port, host = '0.0.0.0') {|server| ... } ⇒ TCPServer
Creates a new TCPServer listening on a given host and port.
-
.tcp_server_session(port, host = '0.0.0.0') {|server| ... } ⇒ nil
Creates a new temporary TCPServer listening on a host and port.
-
.tcp_session(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ nil
Creates a new temporary TCPSocket object, connected to the given host and port.
-
.tcp_single_server(port, host = '0.0.0.0') {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepts only one client and then stops listening.
-
.telnet_connect(host, options = {}) {|session| ... } ⇒ Net::Telnet
Creates a new Telnet connection.
-
.telnet_session(host, options = {}) {|session| ... } ⇒ nil
Starts a new Telnet session.
-
.udp_banner(host, port, local_host = nil, local_port = nil) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
-
.udp_connect(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ UDPSocket
Creates a new UDPSocket object connected to a given host and port.
-
.udp_connect_and_send(data, host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ UDPSocket
Creates a new UDPSocket object, connected to a given host and port.
-
.udp_server(port, host = '0.0.0.0') {|server| ... } ⇒ UDPServer
Creates a new UDPServer listening on a given host and port.
-
.udp_server_session(port, host = '0.0.0.0') {|server| ... } ⇒ nil
Creates a new temporary UDPServer listening on a given host and port.
-
.udp_session(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ nil
Creates a new temporary UDPSocket object, connected to the given host and port.
Class Method Details
.esmtp_connect(host, options = {}) {|session| ... } ⇒ Net::SMTP
Creates a connection to the ESMTP server.
69 70 71 72 73 74 75 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 69 def Net.esmtp_connect(host,={}) session = Net.smtp_connect(host,) session.esmtp = true yield session if block_given? return session end |
.esmtp_message(options = {}, &block) ⇒ Object
28 29 30 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 28 def Net.(={},&block) Net.(,&block) end |
.esmtp_session(host, options = {}) {|session| ... } ⇒ Object
Starts an ESMTP session with the ESMTP enabled server.
97 98 99 100 101 102 103 |
# File 'lib/ronin/network/extensions/esmtp/net.rb', line 97 def Net.esmtp_session(host,={}) Net.smtp_session(host,) do |session| session.esmtp = true yield session if block_given? end end |
.http_connect(options = {}) {|session| ... } ⇒ Net::HTTP
Starts a HTTP connection with the server.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ronin/network/extensions/http/net.rb', line 74 def Net.http_connect(={},&block) = Ronin::Network::HTTP.() host = [:host].to_s port = [:port] proxy = [:proxy] proxy_host = if (proxy && proxy[:host]) proxy[:host].to_s end sess = Net::HTTP::Proxy( proxy_host, proxy[:port], proxy[:user], proxy[:password] ).new(host.to_s,port) if [:ssl] sess.use_ssl = true sess.verify_mode = Ronin::Network::SSL::VERIFY[[:ssl][:verify]] end sess.start() if block if block.arity == 2 block.call(sess,) else block.call(sess) end end return sess end |
.http_copy(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Copy request.
330 331 332 333 334 335 |
# File 'lib/ronin/network/extensions/http/net.rb', line 330 def Net.http_copy(={}) resp = Net.http_request(.merge(:method => :copy)) yield resp if block_given? return resp end |
.http_delete(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Delete request.
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/ronin/network/extensions/http/net.rb', line 357 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)) yield resp if block_given? return resp end |
.http_get(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Get request.
393 394 395 396 397 398 |
# File 'lib/ronin/network/extensions/http/net.rb', line 393 def Net.http_get(={},&block) resp = Net.http_request(.merge(:method => :get)) yield resp if block_given? return resp end |
.http_get_body(options = {}) ⇒ String
Performs an HTTP Get request and returns the Respond Body.
432 433 434 |
# File 'lib/ronin/network/extensions/http/net.rb', line 432 def Net.http_get_body(={}) Net.http_get().body end |
.http_get_headers(options = {}) ⇒ Hash{String => Array<String>}
Performs an HTTP Get request and returns the Response Headers.
415 416 417 |
# File 'lib/ronin/network/extensions/http/net.rb', line 415 def Net.http_get_headers(={}) Net.http_get().to_hash end |
.http_head(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Head request.
456 457 458 459 460 461 |
# File 'lib/ronin/network/extensions/http/net.rb', line 456 def Net.http_head(={},&block) resp = Net.http_request(.merge(:method => :head)) yield resp if block_given? return resp end |
.http_lock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Lock request.
483 484 485 486 487 488 |
# File 'lib/ronin/network/extensions/http/net.rb', line 483 def Net.http_lock(={},&block) resp = Net.http_request(.merge(:method => :lock)) yield resp if block_given? return resp end |
.http_mkcol(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Mkcol request.
510 511 512 513 514 515 |
# File 'lib/ronin/network/extensions/http/net.rb', line 510 def Net.http_mkcol(={},&block) resp = Net.http_request(.merge(:method => :mkcol)) yield resp if block_given? return resp end |
.http_move(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Move request.
537 538 539 540 541 542 |
# File 'lib/ronin/network/extensions/http/net.rb', line 537 def Net.http_move(={},&block) resp = Net.http_request(.merge(:method => :move)) yield resp if block_given? return resp end |
.http_ok?(options = {}) ⇒ Boolean
Checks if the response has an HTTP OK status code.
262 263 264 |
# File 'lib/ronin/network/extensions/http/net.rb', line 262 def Net.http_ok?(={}) Net.http_status() == 200 end |
.http_options(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Options request.
564 565 566 567 568 569 |
# File 'lib/ronin/network/extensions/http/net.rb', line 564 def Net.(={},&block) resp = Net.http_request(.merge(:method => :options)) yield resp if block_given? return resp end |
.http_post(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Post request.
594 595 596 597 598 599 |
# File 'lib/ronin/network/extensions/http/net.rb', line 594 def Net.http_post(={},&block) resp = Net.http_request(.merge(:method => :post)) yield resp if block_given? return resp end |
.http_post_body(options = {}) ⇒ String
Performs an HTTP Post request and returns the Response Body.
639 640 641 |
# File 'lib/ronin/network/extensions/http/net.rb', line 639 def Net.http_post_body(={}) Net.http_post().body end |
.http_post_headers(options = {}) ⇒ Hash{String => Array<String>}
Performs an HTTP Post request and returns the Response Headers.
619 620 621 |
# File 'lib/ronin/network/extensions/http/net.rb', line 619 def Net.http_post_headers(={}) Net.http_post().to_hash end |
.http_powered_by(options = {}) ⇒ String
Sends an HTTP Head request and returns the HTTP X-Powered-By header.
304 305 306 307 308 |
# File 'lib/ronin/network/extensions/http/net.rb', line 304 def Net.http_powered_by(={}) = {:method => :get}.merge() return Net.http_request()['x-powered-by'] end |
.http_prop_find(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Propfind request.
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'lib/ronin/network/extensions/http/net.rb', line 663 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)) yield resp if block_given? return resp end |
.http_prop_patch(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Proppatch request.
699 700 701 702 703 704 |
# File 'lib/ronin/network/extensions/http/net.rb', line 699 def Net.http_prop_patch(={},&block) resp = Net.http_request(.merge(:method => :proppatch)) yield resp if block_given? return resp end |
.http_request(options = {}) {|request, (options)| ... } ⇒ Net::HTTP::Response
Connects to the HTTP server and sends an HTTP Request.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ronin/network/extensions/http/net.rb', line 202 def Net.http_request(={},&block) resp = nil Net.http_session() do |http,| req = Ronin::Network::HTTP.request() if block if block.arity == 2 block.call(req,) else block.call(req) end end resp = http.request(req) end return resp end |
.http_server(options = {}) ⇒ String
Sends a HTTP Head request and returns the HTTP Server header.
282 283 284 285 286 |
# File 'lib/ronin/network/extensions/http/net.rb', line 282 def Net.http_server(={}) = {:method => :head}.merge() return Net.http_request()['server'] end |
.http_session(options = {}) {|session| ... } ⇒ nil
Creates a new temporary HTTP session with the server.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/ronin/network/extensions/http/net.rb', line 152 def Net.http_session(={},&block) Net.http_connect() do |sess,| if block if block.arity == 2 block.call(sess,) else block.call(sess) end end sess.finish end return nil end |
.http_status(options = {}) ⇒ Integer
Returns the Status Code of the Response.
240 241 242 243 244 |
# File 'lib/ronin/network/extensions/http/net.rb', line 240 def Net.http_status(={}) = {:method => :head}.merge() return Net.http_request().code.to_i end |
.http_trace(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Trace request.
726 727 728 729 730 731 |
# File 'lib/ronin/network/extensions/http/net.rb', line 726 def Net.http_trace(={},&block) resp = Net.http_request(.merge(:method => :trace)) yield resp if block_given? return resp end |
.http_unlock(options = {}) {|response| ... } ⇒ Net::HTTP::Response
Performs an HTTP Unlock request.
753 754 755 756 757 758 |
# File 'lib/ronin/network/extensions/http/net.rb', line 753 def Net.http_unlock(={},&block) resp = Net.http_request(.merge(:method => :unlock)) yield resp if block_given? return resp end |
.imap_connect(host, options = {}) {|session| ... } ⇒ Net::IMAP
Creates a connection to the IMAP server.
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 90 91 92 |
# File 'lib/ronin/network/extensions/imap/net.rb', line 63 def Net.imap_connect(host,={}) host = host.to_s port = ([:port] || Ronin::Network::IMAP.default_port) certs = [:certs] auth = [:auth] user = [:user] passwd = [:password] if [:ssl] ssl = true ssl_certs = [:ssl][:certs] ssl_verify = Ronin::Network::SSL::VERIFY[[:ssl][:verify]] else ssl = false ssl_verify = false end session = Net::IMAP.new(host,port,ssl,ssl_certs,ssl_verify) if user if auth == :cram_md5 session.authenticate('CRAM-MD5',user,passwd) else session.authenticate('LOGIN',user,passwd) end end yield session if block_given? return session end |
.imap_session(host, options = {}) {|session| ... } ⇒ nil
Starts an IMAP session with the IMAP server.
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ronin/network/extensions/imap/net.rb', line 116 def Net.imap_session(host,={}) session = Net.imap_connect(host,) yield session if block_given? session.logout if [:user] session.close session.disconnect return nil end |
.pop3_connect(host, options = {}) {|session| ... } ⇒ Net::POP3
Creates a connection to the POP3 server.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ronin/network/extensions/pop3/net.rb', line 54 def Net.pop3_connect(host,={}) host = host.to_s port = ([:port] || Ronin::Network::POP3.default_port) user = [:user] password = [:password] session = Net::POP3.start(host,port,user,password) yield session if block_given? return session end |
.pop3_session(host, options = {}) {|session| ... } ⇒ nil
Starts a session with the POP3 server.
86 87 88 89 90 91 92 93 |
# File 'lib/ronin/network/extensions/pop3/net.rb', line 86 def Net.pop3_session(host,={}) session = Net.pop3_connect(host,) yield session if block_given? session.finish return nil end |
.smtp_connect(host, options = {}) {|session| ... } ⇒ Net::SMTP
Creates a connection to the SMTP server.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 85 def Net.smtp_connect(host,={}) host = host.to_s port = ([:port] || Ronin::Network::SMTP.default_port) helo = [:helo] auth = [:auth] user = [:user] password = [:password] session = Net::SMTP.start(host,port,helo,user,password,auth) yield session if block_given? return session end |
.smtp_message(options = {}) {|email| ... } ⇒ Object
Creates a new email message.
42 43 44 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 42 def Net.(={},&block) Ronin::Network::SMTP::Email.new(,&block) end |
.smtp_send_message(host, options = {}) {|email| ... } ⇒ Object
172 173 174 175 176 177 178 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 172 def Net.(host,={},&block) email = Net.(,&block) Net.smtp_session(host,) do |smtp| smtp.(email.to_s, email.from, email.to) end end |
.smtp_session(host, options = {}) {|session| ... } ⇒ Object
Starts a session with the SMTP server.
126 127 128 129 130 131 132 133 |
# File 'lib/ronin/network/extensions/smtp/net.rb', line 126 def Net.smtp_session(host,={}) session = Net.smtp_connect(host,) yield session if block_given? session.finish return nil end |
.ssl_connect(host, port, options = {}) {|ssl_socket| ... } ⇒ OpenSSL::SSL::SSLSocket
Establishes a SSL connection.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/ronin/network/extensions/ssl/net.rb', line 76 def Net.ssl_connect(host,port,={}) local_host = [:local_host] local_port = [:local_port] socket = Net.tcp_connect(host,port,local_host,local_port) ssl_context = OpenSSL::SSL::SSLContext.new() ssl_context.verify_mode = Ronin::Network::SSL::VERIFY[[:verify]] if [:cert] cert_file = File.new([:cert]) ssl_context.cert = OpenSSL::X509::Certificate.new(cert_file) end if [:key] key_file = File.new([:key]) ssl_context.key = OpenSSL::PKey::RSA.new(key_file) end ssl_socket = OpenSSL::SSL::SSLSocket.new(socket,ssl_context) ssl_socket.sync_close = true ssl_socket.connect yield ssl_socket if block_given? return ssl_socket end |
.ssl_session(host, port) {|ssl_socket| ... } ⇒ nil
Creates a new temporary SSL connection.
147 148 149 150 151 152 153 154 |
# File 'lib/ronin/network/extensions/ssl/net.rb', line 147 def Net.ssl_session(host,port) ssl_socket = Net.ssl_connect(host,port) yield ssl_socket if block_given? ssl_socket.close return nil end |
.tcp_banner(host, port, local_host = nil, local_port = nil) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
172 173 174 175 176 177 178 179 180 181 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 172 def Net.(host,port,local_host=nil,local_port=nil) = nil Net.tcp_session(host,port,local_host,local_port) do |sock| = sock.readline.strip end yield if block_given? return end |
.tcp_connect(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ TCPSocket
Creates a new TCPSocket object connected to a given host and port.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 59 def Net.tcp_connect(host,port,local_host=nil,local_port=nil) host = host.to_s local_host = if local_host local_host.to_s end sock = TCPSocket.new(host,port,local_host,local_port) yield sock if block_given? return sock end |
.tcp_connect_and_send(data, host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ Object
Creates a new TCPSocket object, connected to a given host and port. The given data will then be written to the newly created TCPSocket.
98 99 100 101 102 103 104 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 98 def Net.tcp_connect_and_send(data,host,port,local_host=nil,local_port=nil) sock = Net.tcp_connect(host,port,local_host,local_port) sock.write(data) yield sock if block_given? return sock end |
.tcp_send(data, host, port, local_host = nil, local_port = nil) ⇒ true
Connects to a specified host and port, sends the given data and then closes the connection.
212 213 214 215 216 217 218 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 212 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(port, host = '0.0.0.0') {|server| ... } ⇒ TCPServer
Creates a new TCPServer listening on a given host and port.
237 238 239 240 241 242 243 244 245 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 237 def Net.tcp_server(port,host='0.0.0.0') host = host.to_s server = TCPServer.new(host,port) server.listen(3) yield server if block_given? return server end |
.tcp_server_session(port, host = '0.0.0.0') {|server| ... } ⇒ nil
Creates a new temporary TCPServer listening on a host and port.
278 279 280 281 282 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 278 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(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ nil
Creates a new temporary TCPSocket object, connected to the given host and port.
133 134 135 136 137 138 139 140 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 133 def Net.tcp_session(host,port,local_host=nil,local_port=nil) sock = Net.tcp_connect(host,port,local_host,local_port) yield sock if block_given? sock.close return nil end |
.tcp_single_server(port, host = '0.0.0.0') {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepts only one client and then stops listening.
304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/ronin/network/extensions/tcp/net.rb', line 304 def Net.tcp_single_server(port,host='0.0.0.0') host = host.to_s server = TCPServer.new(host,port) server.listen(1) client = server.accept yield client if block_given? client.close server.close return nil end |
.telnet_connect(host, options = {}) {|session| ... } ⇒ Net::Telnet
Creates a new Telnet connection.
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 118 119 120 |
# File 'lib/ronin/network/extensions/telnet/net.rb', line 93 def Net.telnet_connect(host,={}) host = host.to_s = {} ['Host'] = host ['Port'] = ([:port] || Ronin::Network::Telnet.default_port) ['Binmode'] = [:binmode] ['Output_log'] = [:output_log] ['Dump_log'] = [:dump_log] ['Prompt'] = ([:prompt] || Ronin::Network::Telnet.default_prompt) if ([:telnet] && ![:plain]) ['Telnetmode'] = true end ['Timeout'] = ([:timeout] || Ronin::Network::Telnet.default_timeout) ['Waittime'] = [:wait_time] ['Proxy'] = ([:proxy] || Ronin::Network::Telnet.proxy) user = [:user] passwd = [:passwd] session = Net::Telnet.new() session.login(user,passwd) if user yield session if block_given? return session end |
.telnet_session(host, options = {}) {|session| ... } ⇒ nil
Starts a new Telnet session.
150 151 152 153 154 155 156 157 |
# File 'lib/ronin/network/extensions/telnet/net.rb', line 150 def Net.telnet_session(host,={}) session = Net.telnet_connect(host,) yield session if block_given? session.close return nil end |
.udp_banner(host, port, local_host = nil, local_port = nil) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 170 def Net.(host,port,local_host=nil,local_port=nil) = nil Net.udp_session(host,port,local_host,local_port) do |sock| = sock.readline end yield if block_given? return end |
.udp_connect(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ UDPSocket
Creates a new UDPSocket object connected to a given host and port.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 58 def Net.udp_connect(host,port,local_host=nil,local_port=nil) host = host.to_s local_host = if local_host local_host.to_s end sock = UDPSocket.new(host,port,local_host,local_port) yield sock if block_given? return sock end |
.udp_connect_and_send(data, host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ UDPSocket
Creates a new UDPSocket object, connected to a given host and port. The given data will then be written to the newly created UDPSocket.
100 101 102 103 104 105 106 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 100 def Net.udp_connect_and_send(data,host,port,local_host=nil,local_port=nil) sock = Net.udp_connect(host,port,local_host,local_port) sock.write(data) yield sock if block_given? return sock end |
.udp_server(port, host = '0.0.0.0') {|server| ... } ⇒ UDPServer
Creates a new UDPServer listening on a given host and port.
198 199 200 201 202 203 204 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 198 def Net.udp_server(port,host='0.0.0.0') host = host.to_s server = UDPServer.new(host,port) yield server if block_given? return server end |
.udp_server_session(port, host = '0.0.0.0') {|server| ... } ⇒ nil
Creates a new temporary UDPServer listening on a given host and port.
231 232 233 234 235 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 231 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(host, port, local_host = nil, local_port = nil) {|socket| ... } ⇒ nil
Creates a new temporary UDPSocket object, connected to the given host and port.
135 136 137 138 139 140 141 142 |
# File 'lib/ronin/network/extensions/udp/net.rb', line 135 def Net.udp_session(host,port,local_host=nil,local_port=nil) sock = Net.udp_connect(host,port,local_host,local_port) yield sock if block_given? sock.close return nil end |