Advertisement
FlyFar

tools/extract_key_from_cfg_files.py

Oct 28th, 2023
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | Cybersecurity | 0 0
  1. #!/usr/bin/env python3
  2.  
  3.  
  4. # ======================= Edit search_path==========
  5. search_path = './'
  6. # ==================================================
  7.  
  8.  
  9. import glob,struct,os,hashlib
  10. for filename in glob.iglob(os.path.join(search_path,'./**/systemInfo.cfg'),
  11.                            recursive=True):
  12.     print(filename)
  13.     int_object_header = b'\x73\x71\x00\x7e\x00\x02'
  14.     with open(filename, 'rb') as f:
  15.         s = f.read()
  16.     idx = s.find(int_object_header) + len(int_object_header)
  17.     uin = struct.unpack('>i',s[idx :idx + 4])[0]
  18.     uin = str(uin)
  19.     print('\t'+'uin:  ',uin)
  20.    
  21.     for filename in glob.iglob(os.path.join(search_path,'./**/CompatibleInfo.cfg'),
  22.                                recursive=True):
  23.         print('\t'+filename)  
  24.         str_object_header = b'\x74\x00\x10'
  25.         with open(filename, 'rb') as f:
  26.             s = f.read()
  27.         idx = 0
  28.         for _ in range(2):
  29.             # get the second string
  30.             idx = s.find(str_object_header,idx) + len(str_object_header)
  31.         idx_end = s.find(int_object_header,idx)
  32.         IMEI = s[idx:idx_end].decode('ascii')
  33.         print('\t\t'+'IMEI: ',IMEI)
  34.        
  35.         password = hashlib.md5((IMEI+uin).encode()).hexdigest()[:7]
  36.         print('\t\t'+'pass: ',password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement