Module: Ronin::Support::Network::TCP::Mixin
- Included in:
- Mixin
- Defined in:
- lib/ronin/support/network/tcp/mixin.rb
Overview
Provides helper methods for using the TCP protocol.
Instance Method Summary collapse
-
#tcp_accept(**kwargs) {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepts only one client and then stops listening.
-
#tcp_banner(host, port, **kwargs) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
-
#tcp_connect(host, port, **kwargs) {|socket| ... } ⇒ TCPSocket?
Creates a new TCP socket connected to a given host and port.
-
#tcp_connect_and_send(data, host, port, **kwargs) {|socket| ... } ⇒ TCPSocket
Creates a new TCPSocket object, connected to a given host and port.
-
#tcp_open?(host, port, **kwargs) ⇒ Boolean?
Tests whether a remote TCP port is open.
-
#tcp_send(data, host, port, **kwargs) ⇒ true
Connects to a specified host and port, sends the given data and then closes the connection.
-
#tcp_server(**kwargs) {|server| ... } ⇒ TCPServer
Creates a new TCPServer listening on a given host and port.
-
#tcp_server_loop(**kwargs) {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepting clients in a loop.
-
#tcp_server_session(**kwargs) {|server| ... } ⇒ nil
Creates a new temporary TCPServer listening on a host and port.
Instance Method Details
#tcp_accept(**kwargs) {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepts only one client and then stops listening.
393 394 395 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 393 def tcp_accept(**kwargs,&block) TCP.accept(**kwargs,&block) end |
#tcp_banner(host, port, **kwargs) {|banner| ... } ⇒ String
Reads the banner from the service running on the given host and port.
194 195 196 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 194 def (host,port,**kwargs,&block) TCP.(host,port,**kwargs,&block) end |
#tcp_connect(host, port, **kwargs) {|socket| ... } ⇒ TCPSocket?
Creates a new TCP socket connected to a given host and port.
117 118 119 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 117 def tcp_connect(host,port,**kwargs,&block) TCP.connect(host,port,**kwargs,&block) end |
#tcp_connect_and_send(data, host, port, **kwargs) {|socket| ... } ⇒ TCPSocket
Creates a new TCPSocket object, connected to a given host and port. The given data will then be written to the newly created TCPSocket.
154 155 156 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 154 def tcp_connect_and_send(data,host,port,**kwargs,&block) TCP.connect_and_send(data,host,port,**kwargs,&block) end |
#tcp_open?(host, port, **kwargs) ⇒ Boolean?
Tests whether a remote TCP port is open.
68 69 70 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 68 def tcp_open?(host,port,**kwargs) TCP.open?(host,port,**kwargs) end |
#tcp_send(data, host, port, **kwargs) ⇒ true
Connects to a specified host and port, sends the given data and then closes the connection.
232 233 234 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 232 def tcp_send(data,host,port,**kwargs) TCP.send(data,host,port,**kwargs) end |
#tcp_server(**kwargs) {|server| ... } ⇒ TCPServer
Creates a new TCPServer listening on a given host and port.
269 270 271 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 269 def tcp_server(**kwargs,&block) TCP.server(**kwargs,&block) end |
#tcp_server_loop(**kwargs) {|client| ... } ⇒ nil
Creates a new TCPServer listening on a given host and port, accepting clients in a loop.
352 353 354 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 352 def tcp_server_loop(**kwargs,&block) TCP.server_loop(**kwargs,&block) end |
#tcp_server_session(**kwargs) {|server| ... } ⇒ nil
Creates a new temporary TCPServer listening on a host and port.
312 313 314 |
# File 'lib/ronin/support/network/tcp/mixin.rb', line 312 def tcp_server_session(**kwargs,&block) TCP.server_session(**kwargs,&block) end |