From 9e5c1902af7144814c9c20bbad25110179dd1e76 Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Tue, 2 Jan 2024 10:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A1=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BF=9D=E5=AD=98info=E4=BF=A1=E6=81=AF=E5=88=B0json=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/cli.py | 23 +++++++---------------- pywxdump/wx_info/get_wx_info.py | 14 +++++++++++--- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pywxdump/cli.py b/pywxdump/cli.py index 83c2a7e..93d4709 100644 --- a/pywxdump/cli.py +++ b/pywxdump/cli.py @@ -62,7 +62,7 @@ class MainWxInfo(): sb_wx_info = parser.add_parser(self.mode, help="获取微信信息") sb_wx_info.add_argument("-vlp", '--version_list_path', metavar="", type=str, help="(可选)微信版本偏移文件路径", default=VERSION_LIST_PATH) - sb_wx_info.add_argument("-s", '--save_path', metavar="", type=str, help="(可选)保存路径") + sb_wx_info.add_argument("-s", '--save_path', metavar="", type=str, help="(可选)保存路径【json文件】") return sb_wx_info def run(self, args): @@ -70,15 +70,7 @@ class MainWxInfo(): path = args.version_list_path save_path = args.save_path version_list = json.load(open(path, "r", encoding="utf-8")) - result = read_info(version_list, True) # 读取微信信息 - if save_path: - try: - infos = json.load(open(save_path, "r", encoding="utf-8")) if os.path.exists(save_path) else [] - except: - infos = [] - with open(save_path, "w", encoding="utf-8") as f: - infos += result - json.dump(infos, f, ensure_ascii=False, indent=4) + result = read_info(version_list, True, save_path) # 读取微信信息 return result @@ -290,11 +282,13 @@ class MainAll(): self.mode = "all" # 添加 'all' 子命令解析器 sb_all = parser.add_parser(self.mode, help="获取微信信息,解密微信数据库,查看聊天记录") + sb_all.add_argument("-s", '--save_path', metavar="", type=str, help="(可选)wx_info保存路径【json文件】") return sb_all def run(self, args): # 获取微信信息 - WxInfo = read_info(VERSION_LIST, True) + save_path = args.save_path + WxInfo = read_info(VERSION_LIST, True, save_path) for user in WxInfo: key = user.get("key", "") @@ -313,7 +307,7 @@ class MainAll(): print("[-] 未获取到数据库路径") return - wxdbpaths = [i for i in wxdbpaths if "Backup.db" not in i and "xInfo.db" not in i] # 过滤掉无需解密的数据库 + wxdbpaths = [i for i in wxdbpaths if "Backup.db" not in i and "xInfo.db" not in i] # 过滤掉无需解密的数据库 wxdblen = len(wxdbpaths) print(f"[+] 共发现 {wxdblen} 个微信数据库") print("=" * 32) @@ -374,15 +368,12 @@ class MainAll(): # # 查看聊天记录 args.msg_path = merge_save_path - args.micro_path =merge_save_path + args.micro_path = merge_save_path args.media_path = merge_save_path args.filestorage_path = FileStorage_path MainShowChatRecords().run(args) -PYWXDUMP_VERSION = pywxdump.__version__ - - class CustomArgumentParser(argparse.ArgumentParser): def format_help(self): # 首先显示软件简介 diff --git a/pywxdump/wx_info/get_wx_info.py b/pywxdump/wx_info/get_wx_info.py index 390a589..024fa15 100644 --- a/pywxdump/wx_info/get_wx_info.py +++ b/pywxdump/wx_info/get_wx_info.py @@ -6,13 +6,14 @@ # Date: 2023/08/21 # ------------------------------------------------------------------------------- import ctypes +import json import os import re import winreg import psutil import pymem from typing import List, Union -from .utils import pattern_scan_all,verify_key,get_exe_version,get_exe_bit +from .utils import pattern_scan_all, verify_key, get_exe_version, get_exe_bit ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory void_p = ctypes.c_void_p @@ -139,7 +140,7 @@ def get_key(pid, db_path, addr_len): # 读取微信信息(account,mobile,name,mail,wxid,key) -def read_info(version_list, is_logging=False): +def read_info(version_list: dict, is_logging: bool = False, save_path: str = None): wechat_process = [] result = [] error = "" @@ -207,7 +208,14 @@ def read_info(version_list, is_logging=False): print(f"[+] {k:>8}: {v}") print(end="-" * 32 + "\n" if i != len(result) - 1 else "") print("=" * 32) - + if save_path: + try: + infos = json.load(open(save_path, "r", encoding="utf-8")) if os.path.exists(save_path) else [] + except: + infos = [] + with open(save_path, "w", encoding="utf-8") as f: + infos += result + json.dump(infos, f, ensure_ascii=False, indent=4) return result