Last active
September 20, 2023 07:40
-
-
Save xperylab/1e743a06411666d2b21ae9e16a408120 to your computer and use it in GitHub Desktop.
PM : bruteforce PIN code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import itertools | |
from tqdm.contrib.concurrent import process_map | |
charset="1234567890" | |
salt = keychainVal['PinProtection.salt'] | |
encMainKey = keychainVal['PinProtection'] | |
IVsize = 16 | |
# Number of digits of the PIN | |
numCar = 6 | |
def worker(pin): | |
ikey = hashlib.scrypt(pin, salt=salt, n=32768, r=8, p=1, maxmem=33*1024*1024, dklen=32) | |
cipher = AES.new(ikey, AES.MODE_CTR, initial_value=encMainKey[:IVsize], nonce=b'') | |
mainKey = cipher.decrypt(encMainKey[IVsize:]) | |
if b'bplist' in mainKey: | |
print('found :%s'%(pin)) | |
return | |
def iterator(numCar): | |
start = 0 | |
for n in range(0,10**numCar): | |
formatstring = '{'+':0{}d'.format(numCar)+'}' | |
yield(bytes(formatstring.format(n).encode('utf8'))) | |
with multiprocessing.Pool(10) as workers: | |
total = 10**numCar | |
candidates = itertools.product(charset, repeat=6) | |
r = process_map(worker, | |
iterator(numCar), | |
max_workers=10, | |
chunksize=100, | |
total=total | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment