Advertisement
FlyFar

tools/decrypt_db_with_password.py

Oct 28th, 2023
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | Cybersecurity | 0 0
  1. #!/usr/bin/env python2
  2.  
  3. from pysqlcipher import dbapi2 as sqlite
  4.  
  5. db = 'EnMicroMsg.db'
  6. # db = 'output_encrypted_db.db'
  7. output = 'output_db.db'
  8.  
  9. key = '0123456'
  10.  
  11. print "Please change the 'key', 'db', and 'output' first!"
  12. print "key='"+key+"'"
  13.  
  14.  
  15. try:
  16.     conn = sqlite.connect(db)
  17.     c = conn.cursor()
  18.  
  19.     c.execute("PRAGMA key = '" + key + "';")
  20.     c.execute("PRAGMA cipher_use_hmac = OFF;")
  21.     c.execute("PRAGMA cipher_page_size = 1024;")
  22.     c.execute("PRAGMA kdf_iter = 4000;")
  23.     c.execute("SELECT name FROM sqlite_master WHERE type='table'")
  24.  
  25.     c.execute("ATTACH DATABASE '" + output + "' AS db KEY '';")
  26.     c.execute("SELECT sqlcipher_export('db');")
  27.     c.execute("DETACH DATABASE db;")
  28.     print "Decrypt and dump database to {} ... ".format(output)
  29.     print key
  30.     print('OK!!!!!!!!!')
  31.     # with open('CRACKED_PASS.txt', 'a') as f:
  32.     #     f.write(key)
  33.     #     f.write('\n')
  34. except Exception as e:
  35.     print(str(e))
  36. finally:
  37.     conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement