lib/ronin/network/extensions/tcp/net.rb in ronin-0.1.2 vs lib/ronin/network/extensions/tcp/net.rb in ronin-0.1.3

- old
+ new

@@ -1,11 +1,11 @@ # #-- # Ronin - A Ruby platform designed for information security and data # exploration tasks. # -# Copyright (c) 2006-2008 Hal Brodigan (postmodern.mod3 at gmail.com) +# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. @@ -88,7 +88,23 @@ banner = sock.readline.strip end block.call(banner) if block return banner + end + + # + # Connects to the specified _rhost_ and _rport_ with the given _lhost_ + # and _lport_, sends the specified _data_ and then closes the connection. + # Returns +true+ if the _data_ was successfully sent. + # + # buffer = "GET /" + ('A' * 4096) + "\n\r" + # Net.tcp_send(buffer,'victim.com',80) + # + def Net.tcp_send(data,rhost,rport,lhost=nil,lport=nil) + Net.tcp_session(rhost,rport,lhost,lport) do |sock| + sock.write(data) + end + + return true end end