Created
May 11, 2012 03:12
-
-
Save postmodern/2657303 to your computer and use it in GitHub Desktop.
Example of Ronin::Network::TCP::Proxy
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
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