#!/usr/bin/env python # This script shows how many bad passwords each user has entered for HTTP # authentication. (use CommonWebLog instead of CombinedWebLog as necessary) # # usage: cat [logfile] | ./bad_passwords.py > [outfile] import sys from weblog import combined log = combined.Parser(sys.stdin) bad_pw = {} while log.getlogent(): if (log.status == 401 or log.status == 403 ) and log.authuser != '-': bad_pw[log.authuser] = bad_pw.get(log.authuser, 0) + 1 for (user, num_bad) in bad_pw.items(): print "%s %s" % (num_bad, user)