Skip to content

Instantly share code, notes, and snippets.

@brianjolly
Last active September 28, 2015 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjolly/1378120 to your computer and use it in GitHub Desktop.
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'
require 'rubygems'
require 'colorize'
device = 'en3'
tracking_server = "your.tracking.server.com"
IO.popen("sudo tcpdump -i #{device} -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)
puts " "
puts "--------------------------------------------------------------------------------"
#uri_params.each_key { |key| puts "#{key} : #{uri_params[key]}" }
uri_params.each_key { |key|
case key
when "t"
puts "#{key} : #{uri_params[key]}".green
when "c15"
puts "#{key} : #{uri_params[key]}".yellow
when "c35"
puts "#{key} : #{uri_params[key]}".yellow
when "c36"
puts "#{key} : #{uri_params[key]}".yellow
when "c37"
puts "#{key} : #{uri_params[key]}".yellow
when "events"
puts "#{key} : #{uri_params[key]}".yellow
when "pageName"
puts "#{key} : #{uri_params[key]}".yellow
when "pe"
puts "#{key} : #{uri_params[key]}".yellow
else
puts "#{key} : #{uri_params[key]}"
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment