Skip to content

Instantly share code, notes, and snippets.

@johnl
Created September 4, 2012 15:37
Show Gist options
  • Save johnl/e5249e7754a977dc7b43 to your computer and use it in GitHub Desktop.
Save johnl/e5249e7754a977dc7b43 to your computer and use it in GitHub Desktop.
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