Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tornado.ioloop
- import tornado.web
- import hashlib
- import httplib, urllib
- import base64
- sha1all = set([])
- sha1cracked = set([])
- sha1uncracked = set([])
- sha1pot = dict()
- userscore = dict()
- inf = open("sha1.hash")
- line = inf.readline()
- while line != "":
- line = line.strip().lower()
- sha1uncracked.add(line)
- sha1all.add(line)
- line = inf.readline()
- inf.close()
- inf = open("users.txt")
- line = inf.readline()
- while line != "":
- data = line.split(" ")
- userscore[data[0]] = data[1]
- line = inf.readline()
- inf.close()
- inf = open("sha1.pot")
- line = inf.readline()
- while line != "":
- try:
- h = line[:line.find(":")].strip().lower()
- sha1pot[h] = line[line.find(":") + 1:].strip("\r\n")
- sha1uncracked.remove(h)
- sha1cracked.add(h)
- except:
- h = ""
- line = inf.readline()
- inf.close()
- print "Finished loading"
- class HashCompetition(tornado.web.RequestHandler):
- def get(self, input):
- global sha1all, sha1cracked, sha1uncracked, userscore
- if input == "cracked":
- inf = open("sha1.pot")
- line = inf.readline()
- while line != "":
- self.write(line)
- line = inf.readline()
- inf.close()
- elif input == "notcracked":
- for h in sha1uncracked:
- self.write(h + "\n")
- else:
- self.write("<html><head><title>@bwallHatesTwits Hash Cracking Competition Platform</title></head>")
- self.write("<body><h2>Submit Hashes</h2><form action='/sha1/query' method='post'><textarea name='hashes'></textarea><br/><input type='submit' value='Submit Hashes'/></form></body></html>")
- def decode_argument(self, value, name = None):
- return str(value)
- def post(self, input):
- global sha1all, sha1cracked, sha1uncracked, sha1pot, userscore
- if input == "submit":
- passwords = self.get_argument("pass").split("\n")
- user = self.get_argument("user")
- submitted = set([])
- added = dict()
- for password in passwords:
- m = hashlib.sha1()
- m.update(password.strip("\n"))
- h = m.hexdigest().lower()
- submitted.add(h)
- added[h] = password.strip("\n")
- correct = sha1uncracked & submitted
- inf = open("sha1.pot", "a")
- for key in correct:
- sha1pot[key] = added[key]
- print>>inf, key + ":" + added[key]
- inf.close()
- self.write(str(len(correct)) + " correct answers")
- sha1uncracked = sha1uncracked - correct
- sha1cracked = sha1cracked | correct
- if input == "query":
- hashes = self.get_argument("hashes").split("\n")
- submitted = set([])
- found = set([])
- for h in hashes:
- h = h.lower().strip()
- if len(h) != 40:
- self.write(h + " is not the right size")
- continue
- if h in sha1pot:
- self.write(sha1pot[h] + "\n")
- continue
- submitted.add(h)
- newhashes = submitted - sha1uncracked
- sha1all = sha1all | newhashes
- sha1uncracked = sha1uncracked | newhashes
- inf = open("sha1.hash", "a")
- for h in newhashes:
- print>>inf, h
- inf.close()
- application = tornado.web.Application([(r"/sha1/(\w*)", HashCompetition),])
- if __name__ == "__main__":
- application.listen(8888)
- tornado.ioloop.IOLoop.instance().start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement