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.

Revisions

  1. brianjolly revised this gist Jun 10, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    require 'colorize'

    device = 'en3'
    tracking_server = "t.herceptin.com"
    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
  2. brianjolly revised this gist Jun 10, 2013. 1 changed file with 37 additions and 9 deletions.
    46 changes: 37 additions & 9 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,57 @@
    #!/usr/bin/env ruby
    #!/usr/bin/env ruby

    require 'uri'
    require 'cgi'
    require 'iconv'
    require 'date'
    require 'rubygems'
    require 'colorize'

    tracking_server = "your tracking server"

    IO.popen("sudo tcpdump -i en1 -s 0 -l -w - port 80 and host #{tracking_server}").each do |line|
    device = 'en3'
    tracking_server = "t.herceptin.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
    end

    if valid_string
    match = valid_string.match(/GET (.*) HTTP/)
    end
    end

    if match
    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

    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
  3. brianjolly created this gist Nov 18, 2011.
    29 changes: 29 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/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