Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Crypto.Cipher import AES
- from Crypto.Hash import MD5
- import struct
- import hashlib
- class brute:
- def __init__(self):
- self.goal = 'ce975cc4578f4a7005f22ad7182a4d7640a00bd18c6f27c479cebfb1d1778c8b'
- self.choices = list('QWERTZUIOPASDFGHJKLYXCVBNM1234567890')
- self.index = {'1a' : 0, '1b' : 0, '1c' : 0, '1d' : 0, '2a' : 0, '2b' : 0, '2c' : 0, '2d' : 0}
- self.winners = []
- self.won = False
- self.allDone = False
- self.mainLoop()
- def buildKey1(self, one, two, three, four):
- key = '8643-' + one + '120-' + two + 'D' + three + '3-' + four + '893'
- return key
- def buildKey2(self, one, two, three, four):
- key = 'E5' + one + 'D-' + two + '722-' + three + '2E8-6' + four + '85'
- return key
- def createCipher(self, key1, key2):
- key = key1
- blanks = '\0' * 16
- h = MD5.new()
- h.update(key2)
- IV = h.digest() # Initialization vector: discussed later
- mode = AES.MODE_CBC
- encryptor = AES.new(key, mode, IV=IV)
- ciphertext = encryptor.encrypt(blanks)
- return ciphertext
- def checkCorrect(self, ciphertext):
- if ciphertext.encode('hex') == self.goal[:32]:
- return True
- else:
- #print ciphertext.encode('hex') + ' failed!'
- return False
- def mainLoop(self):
- while not self.won:
- #1A
- if self.allDone:
- print 'Whole index was searched!'
- #2B
- if self.index['2a'] == 35:
- self.index['2a'] = 0
- self.index['2b'] = self.index['2b'] + 1
- else:
- self.index['2a'] = self.index['2a'] + 1
- if self.index['2b'] == 35:
- self.index['2b'] = 0
- self.index['2c'] = self.index['2c'] + 1
- if self.index['2c'] == 35:
- self.index['2c'] = 0
- self.index['2d'] = self.index['2d'] + 1
- if self.index['2d'] == 35:
- self.index['2d'] = 0
- self.allDone = True
- sha = hashlib.sha1()
- sha.update('8643-C120-EDA3-F893')
- before = sha.digest()
- key1 = before[:16]
- key2 = self.buildKey2(self.choices[self.index['2a']], self.choices[self.index['2b']], self.choices[self.index['2c']], self.choices[self.index['2d']])
- result = self.createCipher(key1, key2)
- victory = self.checkCorrect(result)
- if victory == True:
- self.won = True
- self.winners.append('8643-C120-EDA3-F893')
- self.winners.append(key2)
- else:
- #print self.choices[self.index['2a']], self.choices[self.index['2b']], self.choices[self.index['2c']], self.choices[self.index['2d']]
- pass
- print 'Keys found!'
- print self.winners
- brute = brute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement