Skip to content

Instantly share code, notes, and snippets.

@bensonk
Created May 6, 2012 20:27
Show Gist options
  • Save bensonk/2624224 to your computer and use it in GitHub Desktop.
Save bensonk/2624224 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
parser = re.compile(r'(.*?);(.*?);(.{3});(.*?);(.*?);')
def parse_line(l):
res = parser.match(l)
if res:
values = res.groups()
credential = {}
credential['username'] = values[0]
credential['hash'] = values[1]
credential['salt'] = values[2]
credential['email'] = values[3]
credential['ip_addr'] = values[4]
return credential
else:
return None
if __name__ == "__main__":
from pprint import pprint
from sys import argv
for fname in argv[1:]:
for credential in filter(lambda x: x, ( parse_line(l) for l in open(fname) )):
pprint(credential)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment