Advertisement
FlyFar

crack_enmicromsg_db_(C_version).py

Oct 28th, 2023
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | Cybersecurity | 0 0
  1. # 1. install openssl dev package:
  2. #    $ sudo apt-get install libssl-dev
  3.  
  4. # 2. compile password_cracker.c:
  5. #    $ gcc password_cracker.c  -l crypto -o password_cracker.o
  6.  
  7. # 3. modify following parameters in this file and then run.
  8.  
  9. db_file_name = 'EnMicroMsg.db'
  10. pass_file_name = 'pass.txt'
  11. process_no = 4
  12.  
  13. pass_start = 0x0000000
  14. pass_end =   0xfffffff
  15. pass_truck_size = 4000
  16.  
  17.  
  18. # ====================================
  19.  
  20.  
  21. import threading
  22. import time, os
  23. import Queue, subprocess
  24.  
  25. pass_seg = Queue.Queue()
  26. bin_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'password_cracker.o')
  27.  
  28. class workerThread(threading.Thread):
  29.     def __init__(self, threadID, name, pass_seg_):
  30.         threading.Thread.__init__(self)
  31.         self.threadID = threadID
  32.         self.name = name
  33.         self.pass_seg = pass_seg_
  34.  
  35.     def run(self):
  36.         print('Thread %d started...' % (self.threadID))
  37.         while not pass_seg.empty():
  38.             sn_start, sn_end = self.pass_seg.get()
  39.             if sn_start is None:
  40.                 break
  41.             if os.path.exists(pass_file_name):
  42.                 break
  43.             print(subprocess.check_output([bin_path, db_file_name,
  44.                                            pass_file_name,
  45.                                           hex(sn_start), hex(sn_end)]))
  46.  
  47.  
  48. if os.path.exists(pass_file_name):
  49.     print('Pls delete %s and then try again.' % (pass_file_name))
  50.     exit(0)
  51.  
  52. if not os.path.exists(bin_path):
  53.     print('Code has NOT been complied. Pls complie it first.')
  54.     exit(0)
  55.  
  56. while pass_start<= pass_end:
  57.     pass_seg.put((pass_start,min(pass_start+pass_truck_size-1, pass_end)))
  58.     pass_start += pass_truck_size
  59.  
  60. thread_pool =[]
  61. for i in range(process_no):
  62.     thread_pool.append( workerThread(i, 'Worker %d' % i, pass_seg))
  63.  
  64. [x.start() for x  in thread_pool]
  65.  
  66. [x.join() for x in thread_pool]
  67.  
  68. print("Exiting Main Thread")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement