Skip to content

Instantly share code, notes, and snippets.

@brianjolly
Last active September 28, 2015 03:37
Show Gist options
  • Select an option

  • Save brianjolly/1378120 to your computer and use it in GitHub Desktop.

Select an option

Save brianjolly/1378120 to your computer and use it in GitHub Desktop.
omniture sniffer
#!/usr/bin/env ruby
require 'uri'
require 'cgi'
require 'iconv'
require 'date'
tracking_server = "your tracking server"
IO.popen("sudo tcpdump -i en1 -s 0 -l -w - port 80 and host #{tracking_server}").each do |line|
begin
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
valid_string = ic.iconv(line + ' ')[0..-2]
rescue Iconv::InvalidCharacter=>e
puts e
end
if valid_string
match = valid_string.match(/GET (.*) HTTP/)
end
if match
uri = URI.parse "#{tracking_server}#{match[1]}"
uri_params = CGI.parse(uri.query)
uri_params.each_key { |key| puts "#{key} : #{uri_params[key]}" }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment