Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 29 lines (24 sloc) 698 Bytes
#!/usr/bin/env ruby
#
# Usage: sudo tshark-http INTERFACE
#
# Outputs a list of HTTP GET and PUT requests to STDOUT, where
# INTERFACE is the name of the network interface to listen on.
#
# Written in 2010 by Suraj N. Kurapati <https://github.com/sunaku>
iface = ARGV.shift or raise ArgumentError
IO.popen %{tshark -i #{iface} -f 'tcp port http' -l -T pdml | egrep '<field name="http.(host|request.uri)"'} do |stream|
while line = stream.gets
case line
when /Host: (.*?)\\r\\n/
host = $1
when /Request URI: ([^"]*)/
if host
uri = $1
puts "http://#{host}#{uri}"
# prepare to detect next link
host = uri = nil
end
end
end
end