Re: WeChat Decoder

From Jittery Dove, 6 Years ago, written in XML, viewed 682 times. This paste is a reply to WeChat Decoder from fauzimd - view diff
URL https://code.nat.moe/view/d991795a Embed
Download Paste or View Raw
  1. from os.path import isfile
  2. from pysqlcipher import dbapi2 as sqlite
  3. import hashlib
  4. import sys
  5. import time
  6. import logging
  7. import re
  8.  
  9. SCRIPTNAME = "fmd_wechatdecipher.py"
  10. logging.basicConfig(filename='EnMicroMsg-decrypted.log', format="%(asctime)s %(levelname)s: %(message)s", datefmt="%d-%b-%Y %I:%M:%S %p", level=logging.DEBUG)
  11.  
  12. def decrypt( key ):
  13.         logging.info( "Connecting database..." )
  14.         conn = sqlite.connect( "EnMicroMsg.db" )
  15.         c = conn.cursor()              
  16.         c.execute( "PRAGMA key = '" + key + "';" )
  17.         c.execute( "PRAGMA cipher_use_hmac = OFF;" )
  18.         c.execute( "PRAGMA cipher_page_size = 1024;" )
  19.         c.execute( "PRAGMA kdf_iter = 4000;" )
  20.         try:
  21.                 logging.info( "Decrypting..." )
  22.                 c.execute( "ATTACH DATABASE 'EnMicroMsg-decrypted.db' AS wechatdecrypted KEY '';" )
  23.                 c.execute( "SELECT sqlcipher_export( 'wechatdecrypted' );" )
  24.                 c.execute( "DETACH DATABASE wechatdecrypted;" )
  25.                 logging.info( "Detaching database..." )
  26.                 c.close()
  27.                 status = 1
  28.         except:
  29.                 c.close()
  30.                 status = 0
  31.         return status
  32.        
  33.        
  34. def generate_key():
  35.         imei = input( "IMEI: " )
  36.         logging.info( "IMEI: " + str( imei ))
  37.         uin = get_uin()
  38.         logging.info( "UIN: " + str( uin ))
  39.         logging.info( "Generating key..." )    
  40.         key = hashlib.md5( str( imei ) + str( uin )).hexdigest()[ 0:7 ]
  41.         logging.info( "Key: " + key )
  42.         return key
  43.        
  44.  
  45. def db_hash():
  46.         f = open( 'EnMicroMsg-decrypted.db', 'rb' ).read()
  47.         logging.info( "Generating hash values..." )    
  48.         if len( f ) > 0:
  49.                 db_md5 = hashlib.md5( f ).hexdigest()
  50.                 logging.info( "EnMicroMsg-decrypted.db MD5: " + db_md5 )
  51.                 db_sha1 = hashlib.sha1( f ).hexdigest()
  52.                 logging.info( "EnMicroMsg-decrypted.db SHA1: " + db_sha1 )
  53.                 return
  54.                
  55.  
  56. def get_uin():
  57.         f = open( 'system_config_prefs.xml', 'r' ).read()
  58.         uin = re.findall( 'name="default_uin" value="([\-?[0-9]+)"', f )
  59.         return uin[ 0 ] if uin else 0
  60.  
  61.  
  62. def main():    
  63.         if not ( isfile( "EnMicroMsg.db" ) and isfile( "system_config_prefs.xml" )):
  64.                 print "##########"
  65.                 print "'EnMicroMsg.db' or 'system_config_prefs.xml' not found!"
  66.                 print "Script exiting..."
  67.                 print "##########"
  68.                 sys.exit()
  69.                
  70.         logging.info( "Script starting..." )
  71.         key = generate_key()
  72.         status = decrypt( key )
  73.         if status == 1:
  74.                 db_hash()
  75.                 print "##########"
  76.                 print "Decryption successful!"
  77.                 print "Decrypted file: EnMicroMsg-decrypted.db"
  78.                 print "Log file: EnMicroMsg-decrypted.log"
  79.                 print "##########"
  80.                 logging.info( "Decryption successful!" )
  81.                 logging.info( "Decrypted filename: EnMicroMsg-decrypted.db" )
  82.         else:
  83.                 print "##########"
  84.                 print "Decryption failed!"
  85.                 print "Make sure you input correct IMEI number!"
  86.                 print "Log file: EnMicroMsg-decrypted.log"
  87.                 print "##########"
  88.                 logging.info( "Decryption failed!" )
  89.                 logging.warning( "Make sure you input correct IMEI number!" )
  90.         logging.info( "Script exiting..." )
  91.  
  92.  
  93. main()

Replies to Re: WeChat Decoder rss

Title Name Language When
Re: Re: WeChat Decoder Stained Agouti xml 5 Years ago.

Reply to "Re: WeChat Decoder"

Here you can reply to the paste above

captcha