Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
heroku tcp information leak demonstration
require 'ipaddr'
def draw(s)
ip, port = s.split(':')
ip = ip.scan(/(..)/).reverse.join('')
ip = ip.to_i(16)
ip = IPAddr.new(ip, Socket::AF_INET).to_s
port = port.to_i(16)
"#{ip}:#{port}"
end
File.read('/proc/net/tcp').each_line do |l|
toks = l.split
next if toks[0] == "sl"
src = toks[1]
dst = toks[2]
puts "#{draw(src)} -> #{draw(dst)}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment