(home | about | stats)

pwyky: FindProxies

Quick Python script to print the unique proxies that your users are hiding behind (assuming the "Via" HTTP header is the last entry in your web logs):

#!/usr/bin/python2

# Pull proxy info from current.log.

import fileinput
import string
import sys

proxies = []

def parse_proxy(line):
    q = string.rfind(line, "\"")
    m = string.rfind(line, "-")
    if m > q:
        return

    q2 = string.rfind(line, "\"",0, q - 1)
    proxy_name = line[q2 + 1:q]
    if proxy_name not in proxies:
        proxies.append(proxy_name)
        print proxy_name

for line in fileinput.input(sys.argv[1]):
    parse_proxy(line)
www.mobilitytech.com owner. This is a pwyky site.