Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 7th, 2020 209 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def encrypt(key, msg):
  2.     key = list(key)
  3.     msg = list(msg)
  4.     for char_key in key:
  5.         for i in range(len(msg)):
  6.             if i == 0:
  7.                 tmp = ord(msg[i]) + ord(char_key) + ord(msg[-1])
  8.             else:
  9.                 tmp = ord(msg[i]) + ord(char_key) + ord(msg[i-1])
  10.  
  11.             while tmp > 255:
  12.                 tmp -= 256
  13.             msg[i] = chr(tmp)
  14.     return ''.join(msg)
  15.  
  16. def decrypt(key, msg):
  17.     key = list(key)
  18.     msg = list(msg)
  19.     for char_key in reversed(key):
  20.         for i in reversed(range(len(msg))):
  21.             if i == 0:
  22.                 tmp = ord(msg[i]) - (ord(char_key) + ord(msg[-1]))
  23.             else:
  24.                 tmp = ord(msg[i]) - (ord(char_key) + ord(msg[i-1]))
  25.             while tmp < 0:
  26.                 tmp += 256
  27.             msg[i] = chr(tmp)
  28.     return ''.join(msg)
  29.  
  30.  
  31. def bruteforce():
  32.     cipherfile = open('ciphertext', 'rb')
  33.     ciphertext = cipherfile.read()
  34.     wordlist = open('/usr/share/wordlists/rockyou.txt', 'r')
  35.     out = open("dec.txt", 'w+')
  36.     for w in wordlist:
  37.         # print('testing ->' + w.strip())
  38.         dec = decrypt(w.strip(), ciphertext)
  39.         try:
  40.             decoded = dec.decode('utf-8')
  41.             print('found possible key-> {0}'.format(w.strip()))
  42.             out.write(decoded)
  43.         except:
  44.             continue
  45.     out.close()
  46.  
  47.  
  48. if __name__ == '__main__':
  49.     bruteforce()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top