Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
import hashlib
import requests
import random
import string
import json
import sys
f = open(sys.argv[1])
data = [l.rstrip() for l in f.readlines()]
f.close()
currentSuffix = "P4ssw0rd"
def cpwpow(i):
while True:
rndstr = ''.join(random.choice("abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ") for _ in range(10))
h = hashlib.sha256(i + rndstr).hexdigest()
if h[0:4] == "1337":
return (rndstr,h)
def checkForSuffix(inchar):
while True:
(d,h) = cpwpow(inchar)
r = requests.get("http://web.midnightsunctf.se:8000/pwmeter/" + inchar + "/" + d)
# print r.text
if "suffix" in r.text:
return r.text
def checkActualSuffix(inchars,claimed):
claimedEnd = int(claimed.split(" ")[0])
print "CLAIMED END: %d" % claimedEnd
actualSuffix = 0
for dl in data:
if dl.endswith(inchars):
actualSuffix += 1
if claimedEnd != actualSuffix:
print "password ends with %s" % inchars
return 1
return 0
while True:
lol1 = 0
for i in "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ":
newWord = i + currentSuffix
print "Checking %s" % (newWord)
d = checkForSuffix(newWord)
dx = json.loads(d)
if checkActualSuffix(newWord,dx["analysis"]) == 1:
currentSuffix = i + currentSuffix
lol1 = 1
break
if lol1 == 0:
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment