lib/ronin/network/extensions/tcp/net.rb in ronin-support-0.1.0 vs lib/ronin/network/extensions/tcp/net.rb in ronin-support-0.2.0.rc1
- old
+ new
@@ -52,10 +52,12 @@
# sock.write("GET /\n\n")
# puts sock.readlines
# sock.close
# end
#
+ # @api public
+ #
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
@@ -89,10 +91,12 @@
# If a block is given, it will be passed the newly created socket.
#
# @yieldparam [TCPsocket] socket
# The newly created TCPSocket object.
#
+ # @api public
+ #
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?
@@ -122,10 +126,12 @@
# @yieldparam [TCPsocket] socket
# The newly created TCPSocket object.
#
# @return [nil]
#
+ # @api public
+ #
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?
@@ -159,10 +165,12 @@
#
# @example
# Net.tcp_banner('pop.gmail.com',25)
# # => "220 mx.google.com ESMTP c20sm3096959rvf.1"
#
+ # @api public
+ #
def Net.tcp_banner(host,port,local_host=nil,local_port=nil)
banner = nil
Net.tcp_session(host,port,local_host,local_port) do |sock|
banner = sock.readline.strip
@@ -197,10 +205,12 @@
# @example
# buffer = "GET /" + ('A' * 4096) + "\n\r"
# Net.tcp_send(buffer,'victim.com',80)
# # => true
#
+ # @api public
+ #
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
@@ -220,10 +230,12 @@
# The new TCP server.
#
# @example
# Net.tcp_server(1337)
#
+ # @api public
+ #
def Net.tcp_server(port,host='0.0.0.0')
host = host.to_s
server = TCPServer.new(host,port)
server.listen(3)
@@ -259,10 +271,12 @@
#
# client1.close
# client2.close
# end
#
+ # @api public
+ #
def Net.tcp_server_session(port,host='0.0.0.0',&block)
server = Net.tcp_server(port,host,&block)
server.close()
return nil
end
@@ -282,9 +296,11 @@
#
# @example
# Net.tcp_single_server(1337) do |client|
# client.puts 'lol'
# end
+ #
+ # @api public
#
def Net.tcp_single_server(port,host='0.0.0.0')
host = host.to_s
server = TCPServer.new(host,port)