Skip to content

Instantly share code, notes, and snippets.

@AlekseyCherepanov
Created October 13, 2017 18:49
Show Gist options
  • Save AlekseyCherepanov/7e481f95c9ca5afa206ed6667162b7d6 to your computer and use it in GitHub Desktop.
Save AlekseyCherepanov/7e481f95c9ca5afa206ed6667162b7d6 to your computer and use it in GitHub Desktop.
Custom validation utility for PCrack contest at SAINTCON
# -*- coding: utf-8 -*-
# Validating utility for sets of plaintexts ordered as original set of hashes.
# Usage: python validate.py < sub_cracks
# Copyright © 2017 Aleksey Cherepanov <lyosha@openwall.com>
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
import sys
import hashlib
k = 0
with open('pcrack.master.hashed') as f:
while True:
c = sys.stdin.readline()
if c == '':
print 'success:', k
exit(0)
c = c[ : -1]
h = hashlib.sha1(c).hexdigest()
h += '\n'
while True:
t = f.readline()
if t == '':
print 'failure:',
print 'c:', repr(c)
print 'h:', repr(h)
exit(1)
if t == h:
k += 1
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment