Skip to content

Instantly share code, notes, and snippets.

@postmodern
Created May 11, 2012 03:12
Show Gist options
  • Save postmodern/2657303 to your computer and use it in GitHub Desktop.
Save postmodern/2657303 to your computer and use it in GitHub Desktop.
Example of Ronin::Network::TCP::Proxy
require 'ronin/network/tcp/proxy'
require 'hexdump'
Ronin::Network::TCP::Proxy.start(:port => 1337, :server => ['www.wired.com', 80]) do |proxy|
address = lambda { |socket|
addrinfo = socket.peeraddr
"#{addrinfo[3]}:#{addrinfo[1]}"
}
hex = Hexdump::Dumper.new
proxy.on_client_data do |client,server,data|
puts "#{address[client]} -> #{proxy}"
hex.dump(data)
end
proxy.on_client_connect do |client|
puts "#{address[client]} -> #{proxy} [connected]"
end
proxy.on_client_disconnect do |client,server|
puts "#{address[client]} <- #{proxy} [disconnected]"
end
proxy.on_server_data do |client,server,data|
proxy.close! if data =~ /QUIT/
puts "#{address[client]} <- #{proxy}"
hex.dump(data)
end
proxy.on_server_connect do |client,server|
puts "#{address[client]} <- #{proxy} [connected]"
end
proxy.on_server_disconnect do |client,server|
puts "#{address[client]} <- #{proxy} [disconnected]"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment