完善项目,添加 数据库解密脚本,添加自动获取当前登录微信的数据库并解密,增加偏移地址脚本获取方式,可以一件获取偏移。
This commit is contained in:
1 parent
6bccd9a9d5
commit
ab17f7fe64
9 files changed
+1091
-638
No files matched your search
@@ -0,0 +1,280 @@
|
||||
# -*- coding: utf-8 -*-#
|
||||
# -------------------------------------------------------------------------------
|
||||
# Name: get_base_addr.py
|
||||
# Description:
|
||||
# Author: xaoyaoo
|
||||
# Date: 2023/08/22
|
||||
# -------------------------------------------------------------------------------
|
||||
import argparse
|
||||
import ctypes
|
||||
import json
|
||||
import re
|
||||
|
||||
import psutil
|
||||
import win32api
|
||||
|
||||
|
||||
def hex2dec(hex):
|
||||
return int(hex, 16)
|
||||
|
||||
|
||||
def dec2hex(dec):
|
||||
return hex(dec)
|
||||
|
||||
|
||||
def hex_add(hex1, hex2, base1=16, base2=16):
|
||||
"""
|
||||
两个任意进制数相加
|
||||
:param hex1:
|
||||
:param hex2:
|
||||
:return:
|
||||
"""
|
||||
return hex(int(hex1, base1) + int(hex2, base2))
|
||||
|
||||
|
||||
def hex_sub(hex1, hex2, base1=16, base2=16):
|
||||
"""
|
||||
两个任意进制数相减
|
||||
:param hex1:
|
||||
:param hex2:
|
||||
:return:
|
||||
"""
|
||||
return hex(int(hex1, base1) - int(hex2, base2))
|
||||
|
||||
|
||||
def get_pid(keyword):
|
||||
"""
|
||||
获取进程id
|
||||
:param keyword: 关键字
|
||||
:return:
|
||||
"""
|
||||
pids = {}
|
||||
for proc in psutil.process_iter():
|
||||
if keyword in proc.name():
|
||||
pids[proc.pid] = proc
|
||||
return pids
|
||||
|
||||
|
||||
class BaseAddr:
|
||||
def __init__(self, pid, proc_module_name="WeChatWin.dll"):
|
||||
self.pid = pid
|
||||
self.module_name = proc_module_name
|
||||
self.proc = psutil.Process(self.pid)
|
||||
self.version = self.get_app_version(self.proc.exe())
|
||||
self.base_address = 0
|
||||
self.end_address = 0
|
||||
self.batch = 0
|
||||
|
||||
self.key_start_addr = 0
|
||||
self.key_end_addr = 0
|
||||
|
||||
self.mobile_addr = []
|
||||
self.name_addr = []
|
||||
self.account_addr = []
|
||||
# self.key_addr = []
|
||||
|
||||
self.get_base_addr()
|
||||
|
||||
def get_app_version(self, executable_path):
|
||||
info = win32api.GetFileVersionInfo(executable_path, "\\")
|
||||
version = info['FileVersionMS'] >> 16, info['FileVersionMS'] & 0xFFFF, \
|
||||
info['FileVersionLS'] >> 16, info['FileVersionLS'] & 0xFFFF
|
||||
version_str = ".".join(map(str, version))
|
||||
|
||||
return version_str
|
||||
|
||||
def get_base_addr(self):
|
||||
"""
|
||||
获取模块基址
|
||||
:param pid: 进程id
|
||||
:param module_name: 模块名
|
||||
:return:
|
||||
"""
|
||||
base_address = 0
|
||||
end_address = 0
|
||||
batch = 0
|
||||
n = 0
|
||||
for module in self.proc.memory_maps(grouped=False):
|
||||
if self.module_name in module.path:
|
||||
if n == 0:
|
||||
base_address = int(module.addr, 16)
|
||||
batch = module.rss
|
||||
n += 1
|
||||
end_address = int(module.addr, 16) + module.rss
|
||||
|
||||
self.base_address = base_address
|
||||
self.end_address = end_address
|
||||
self.batch = batch
|
||||
# self.batch = end_address - base_address
|
||||
|
||||
def find_all(self, c, string):
|
||||
"""
|
||||
查找字符串中所有子串的位置
|
||||
:param c: 子串 b'123'
|
||||
:param string: 字符串 b'123456789123'
|
||||
:return:
|
||||
"""
|
||||
return [m.start() for m in re.finditer(re.escape(c), string)]
|
||||
|
||||
# 搜索内存地址范围内的值
|
||||
def search_memory_value(self, mobile, name, account):
|
||||
mobile = mobile.encode("utf-8")
|
||||
name = name.encode("utf-8")
|
||||
account = account.encode("utf-8")
|
||||
|
||||
Handle = ctypes.windll.kernel32.OpenProcess(0x1F0FFF, False, self.pid)
|
||||
|
||||
mobile_addr = []
|
||||
name_addr = []
|
||||
account_addr = []
|
||||
|
||||
array = ctypes.create_string_buffer(self.batch)
|
||||
for i in range(self.base_address, self.end_address, self.batch):
|
||||
if ctypes.windll.kernel32.ReadProcessMemory(Handle, ctypes.c_void_p(i), array, self.batch, None) == 0:
|
||||
continue
|
||||
|
||||
hex_string = array.raw # 读取到的内存数据
|
||||
|
||||
if mobile in hex_string:
|
||||
mobile_addr = mobile_addr + [m.start() + i for m in re.finditer(re.escape(mobile), hex_string)]
|
||||
if name in hex_string:
|
||||
name_addr = name_addr + [m.start() + i for m in re.finditer(re.escape(name), hex_string)]
|
||||
if account in hex_string:
|
||||
account_addr = account_addr + [m.start() + i for m in re.finditer(re.escape(account), hex_string)]
|
||||
|
||||
self.mobile_addr = mobile_addr
|
||||
self.name_addr = name_addr
|
||||
self.account_addr = account_addr
|
||||
return mobile_addr, name_addr, account_addr
|
||||
|
||||
def get_key_addr(self, key):
|
||||
"""
|
||||
获取key的地址
|
||||
:param key:
|
||||
:return:
|
||||
"""
|
||||
key = bytes.fromhex(key)
|
||||
|
||||
module_start_addr = 34199871460642
|
||||
module_end_addr = 0
|
||||
for module in self.proc.memory_maps(grouped=False):
|
||||
if "WeChat" in module.path:
|
||||
start_addr = int(module.addr, 16)
|
||||
end_addr = start_addr + module.rss
|
||||
|
||||
if module_start_addr > start_addr:
|
||||
module_start_addr = start_addr
|
||||
if module_end_addr < end_addr:
|
||||
module_end_addr = end_addr
|
||||
|
||||
Handle = ctypes.windll.kernel32.OpenProcess(0x1F0FFF, False, self.pid)
|
||||
array = ctypes.create_string_buffer(self.batch)
|
||||
|
||||
for i in range(module_start_addr, module_end_addr, self.batch):
|
||||
if ctypes.windll.kernel32.ReadProcessMemory(Handle, ctypes.c_void_p(i), array, self.batch, None) == 0:
|
||||
continue
|
||||
|
||||
hex_string = array.raw # 读取到的内存数据
|
||||
if key in hex_string:
|
||||
self.key_addr_tmp = i + hex_string.find(key)
|
||||
break
|
||||
|
||||
array_key = []
|
||||
for i in range(8):
|
||||
byte_value = (self.key_addr_tmp >> (i * 8)) & 0xFF
|
||||
hex_string = format(byte_value, '02x')
|
||||
byte_obj = bytes.fromhex(hex_string)
|
||||
array_key.append(byte_obj)
|
||||
# 合并数组
|
||||
array_key = b''.join(array_key)
|
||||
|
||||
array = ctypes.create_string_buffer(self.batch)
|
||||
for i in range(self.base_address, self.end_address, self.batch):
|
||||
if ctypes.windll.kernel32.ReadProcessMemory(Handle, ctypes.c_void_p(i), array, self.batch, None) == 0:
|
||||
continue
|
||||
|
||||
hex_string = array.raw # 读取到的内存数据
|
||||
if array_key in hex_string:
|
||||
self.key_addr = i + hex_string.find(array_key)
|
||||
return self.key_addr
|
||||
|
||||
def calculate_offset(self, addr):
|
||||
"""
|
||||
计算偏移量
|
||||
:param addr:
|
||||
:return:
|
||||
"""
|
||||
offset = addr - self.base_address
|
||||
return offset
|
||||
|
||||
def get_offset(self):
|
||||
"""
|
||||
计算偏移量
|
||||
:param addr:
|
||||
:return:
|
||||
"""
|
||||
mobile_offset = 0
|
||||
name_offset = 0
|
||||
account_offset = 0
|
||||
key_offset = 0
|
||||
if len(self.mobile_addr) >= 1:
|
||||
mobile_offset = self.calculate_offset(self.mobile_addr[0])
|
||||
if len(self.name_addr) >= 1:
|
||||
name_offset = self.calculate_offset(self.name_addr[0])
|
||||
if len(self.account_addr) >= 1:
|
||||
account_offset = self.calculate_offset(self.account_addr[1])
|
||||
|
||||
key_offset = self.calculate_offset(self.key_addr)
|
||||
|
||||
self.key_offset = key_offset
|
||||
self.mobile_offset = mobile_offset
|
||||
self.name_offset = name_offset
|
||||
self.account_offset = account_offset
|
||||
return name_offset, account_offset, mobile_offset, 0, key_offset
|
||||
|
||||
|
||||
def run(mobile, name, account, key):
|
||||
proc_name = "WeChat.exe"
|
||||
proc_module_name = "WeChatWin.dll"
|
||||
|
||||
pids = get_pid(proc_name)
|
||||
for pid, proc in pids.items():
|
||||
ba = BaseAddr(pid, proc_module_name)
|
||||
ba.search_memory_value(mobile, name, account)
|
||||
ba.get_key_addr(key)
|
||||
name_offset, account_offset, mobile_offset, _, key_offset = ba.get_offset()
|
||||
rdata = {ba.version: [name_offset, account_offset, mobile_offset, 0, key_offset]}
|
||||
return rdata
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 创建命令行参数解析器
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--mobile", type=str, help="手机号")
|
||||
parser.add_argument("--name", type=str, help="微信昵称")
|
||||
parser.add_argument("--account", type=str, help="微信账号")
|
||||
parser.add_argument("--key", type=str, help="密钥")
|
||||
|
||||
# 解析命令行参数
|
||||
args = parser.parse_args()
|
||||
|
||||
# 检查是否缺少必要参数,并抛出错误
|
||||
if not args.mobile or not args.name or not args.account or not args.key:
|
||||
raise ValueError("缺少必要的命令行参数!请提供手机号、微信昵称、微信账号和密钥。")
|
||||
|
||||
# 从命令行参数获取值
|
||||
mobile = args.mobile
|
||||
name = args.name
|
||||
account = args.account
|
||||
key = args.key
|
||||
|
||||
# 调用 run 函数,并传入参数
|
||||
rdata = run(mobile, name, account, key)
|
||||
print(rdata)
|
||||
|
||||
# 添加到version_list.json
|
||||
with open("version_list.json", "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
data.update(rdata)
|
||||
with open("version_list.json", "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||
+10
-8
@@ -8,7 +8,7 @@
|
||||
import binascii
|
||||
import json
|
||||
import ctypes
|
||||
|
||||
import win32api
|
||||
import psutil
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ def get_account(pid, base_address, n_size=100):
|
||||
null_index = i
|
||||
break
|
||||
text = ctypes.string_at(ctypes.byref(array), null_index).decode('utf-8', errors='ignore')
|
||||
|
||||
return text
|
||||
|
||||
|
||||
@@ -85,6 +84,7 @@ def get_hex(h_process, lp_base_address):
|
||||
|
||||
num = 32
|
||||
array2 = (ctypes.c_ubyte * num)()
|
||||
|
||||
lp_base_address2 = (
|
||||
(int(binascii.hexlify(array[7]), 16) << 56) +
|
||||
(int(binascii.hexlify(array[6]), 16) << 48) +
|
||||
@@ -95,17 +95,15 @@ def get_hex(h_process, lp_base_address):
|
||||
(int(binascii.hexlify(array[1]), 16) << 8) +
|
||||
int(binascii.hexlify(array[0]), 16)
|
||||
)
|
||||
|
||||
if ctypes.windll.kernel32.ReadProcessMemory(h_process, ctypes.c_void_p(lp_base_address2), ctypes.byref(array2), num,
|
||||
0) == 0:
|
||||
return ""
|
||||
|
||||
hex_string = binascii.hexlify(bytes(array2))
|
||||
return hex_string.decode('utf-8')
|
||||
|
||||
|
||||
def get_file_version(file_path):
|
||||
import win32api
|
||||
|
||||
info = win32api.GetFileVersionInfo(file_path, "\\")
|
||||
ms = info['FileVersionMS']
|
||||
ls = info['FileVersionLS']
|
||||
@@ -113,6 +111,9 @@ def get_file_version(file_path):
|
||||
# version = parse(file_version)
|
||||
return file_version
|
||||
|
||||
# def get_wx_id(h_process, lp_base_address):
|
||||
|
||||
|
||||
|
||||
def read_info(version_list):
|
||||
support_list = None
|
||||
@@ -121,7 +122,7 @@ def read_info(version_list):
|
||||
rd = []
|
||||
|
||||
for process in psutil.process_iter(['name', 'exe', 'pid', 'cmdline']):
|
||||
if process.info['name'] == 'WeChat.exe':
|
||||
if process.name() == 'WeChat.exe':
|
||||
tmp_rd = {}
|
||||
wechat_process = process
|
||||
tmp_rd['pid'] = wechat_process.pid
|
||||
@@ -186,11 +187,12 @@ def read_info(version_list):
|
||||
return "[-] WeChat No Run"
|
||||
return rd
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
version_list = json.load(open("../version_list.json", "r", encoding="utf-8"))
|
||||
version_list = json.load(open("version_list.json", "r", encoding="utf-8"))
|
||||
rd = read_info(version_list)
|
||||
# print(rd)
|
||||
for i in rd:
|
||||
for k, v in i.items():
|
||||
print(f"[+] {k}: {v}")
|
||||
|
||||
print("=====================================")
|
||||
@@ -0,0 +1,303 @@
|
||||
{
|
||||
"3.2.1.154": [
|
||||
328121948,
|
||||
328122328,
|
||||
328123056,
|
||||
328121976,
|
||||
328123020
|
||||
],
|
||||
"3.3.0.115": [
|
||||
31323364,
|
||||
31323744,
|
||||
31324472,
|
||||
31323392,
|
||||
31324436
|
||||
],
|
||||
"3.3.0.84": [
|
||||
31315212,
|
||||
31315592,
|
||||
31316320,
|
||||
31315240,
|
||||
31316284
|
||||
],
|
||||
"3.3.0.93": [
|
||||
31323364,
|
||||
31323744,
|
||||
31324472,
|
||||
31323392,
|
||||
31324436
|
||||
],
|
||||
"3.3.5.34": [
|
||||
30603028,
|
||||
30603408,
|
||||
30604120,
|
||||
30603056,
|
||||
30604100
|
||||
],
|
||||
"3.3.5.42": [
|
||||
30603012,
|
||||
30603392,
|
||||
30604120,
|
||||
30603040,
|
||||
30604084
|
||||
],
|
||||
"3.3.5.46": [
|
||||
30578372,
|
||||
30578752,
|
||||
30579480,
|
||||
30578400,
|
||||
30579444
|
||||
],
|
||||
"3.4.0.37": [
|
||||
31608116,
|
||||
31608496,
|
||||
31609224,
|
||||
31608144,
|
||||
31609188
|
||||
],
|
||||
"3.4.0.38": [
|
||||
31604044,
|
||||
31604424,
|
||||
31605152,
|
||||
31604072,
|
||||
31605116
|
||||
],
|
||||
"3.4.0.50": [
|
||||
31688500,
|
||||
31688880,
|
||||
31689608,
|
||||
31688528,
|
||||
31689572
|
||||
],
|
||||
"3.4.0.54": [
|
||||
31700852,
|
||||
31701248,
|
||||
31700920,
|
||||
31700880,
|
||||
31701924
|
||||
],
|
||||
"3.4.5.27": [
|
||||
32133788,
|
||||
32134168,
|
||||
32134896,
|
||||
32133816,
|
||||
32134860
|
||||
],
|
||||
"3.4.5.45": [
|
||||
32147012,
|
||||
32147392,
|
||||
32147064,
|
||||
32147040,
|
||||
32148084
|
||||
],
|
||||
"3.5.0.20": [
|
||||
35494484,
|
||||
35494864,
|
||||
35494536,
|
||||
35494512,
|
||||
35495556
|
||||
],
|
||||
"3.5.0.29": [
|
||||
35507980,
|
||||
35508360,
|
||||
35508032,
|
||||
35508008,
|
||||
35509052
|
||||
],
|
||||
"3.5.0.33": [
|
||||
35512140,
|
||||
35512520,
|
||||
35512192,
|
||||
35512168,
|
||||
35513212
|
||||
],
|
||||
"3.5.0.39": [
|
||||
35516236,
|
||||
35516616,
|
||||
35516288,
|
||||
35516264,
|
||||
35517308
|
||||
],
|
||||
"3.5.0.42": [
|
||||
35512140,
|
||||
35512520,
|
||||
35512192,
|
||||
35512168,
|
||||
35513212
|
||||
],
|
||||
"3.5.0.44": [
|
||||
35510836,
|
||||
35511216,
|
||||
35510896,
|
||||
35510864,
|
||||
35511908
|
||||
],
|
||||
"3.5.0.46": [
|
||||
35506740,
|
||||
35507120,
|
||||
35506800,
|
||||
35506768,
|
||||
35507812
|
||||
],
|
||||
"3.6.0.18": [
|
||||
35842996,
|
||||
35843376,
|
||||
35843048,
|
||||
35843024,
|
||||
35844068
|
||||
],
|
||||
"3.6.5.7": [
|
||||
35864356,
|
||||
35864736,
|
||||
35864408,
|
||||
35864384,
|
||||
35865428
|
||||
],
|
||||
"3.6.5.16": [
|
||||
35909428,
|
||||
35909808,
|
||||
35909480,
|
||||
35909456,
|
||||
35910500
|
||||
],
|
||||
"3.7.0.26": [
|
||||
37105908,
|
||||
37106288,
|
||||
37105960,
|
||||
37105936,
|
||||
37106980
|
||||
],
|
||||
"3.7.0.29": [
|
||||
37105908,
|
||||
37106288,
|
||||
37105960,
|
||||
37105936,
|
||||
37106980
|
||||
],
|
||||
"3.7.0.30": [
|
||||
37118196,
|
||||
37118576,
|
||||
37118248,
|
||||
37118224,
|
||||
37119268
|
||||
],
|
||||
"3.7.5.11": [
|
||||
37883280,
|
||||
37884088,
|
||||
37883136,
|
||||
37883008,
|
||||
37884052
|
||||
],
|
||||
"3.7.5.23": [
|
||||
37895736,
|
||||
37896544,
|
||||
37895592,
|
||||
37883008,
|
||||
37896508
|
||||
],
|
||||
"3.7.5.27": [
|
||||
37895736,
|
||||
37896544,
|
||||
37895592,
|
||||
37895464,
|
||||
37896508
|
||||
],
|
||||
"3.7.5.31": [
|
||||
37903928,
|
||||
37904736,
|
||||
37903784,
|
||||
37903656,
|
||||
37904700
|
||||
],
|
||||
"3.7.6.24": [
|
||||
38978840,
|
||||
38979648,
|
||||
38978696,
|
||||
38978604,
|
||||
38979612
|
||||
],
|
||||
"3.7.6.29": [
|
||||
38986376,
|
||||
38987184,
|
||||
38986232,
|
||||
38986104,
|
||||
38987148
|
||||
],
|
||||
"3.7.6.44": [
|
||||
39016520,
|
||||
39017328,
|
||||
39016376,
|
||||
38986104,
|
||||
39017292
|
||||
],
|
||||
"3.8.0.31": [
|
||||
46064088,
|
||||
46064912,
|
||||
46063944,
|
||||
38986104,
|
||||
46064876
|
||||
],
|
||||
"3.8.0.33": [
|
||||
46059992,
|
||||
46060816,
|
||||
46059848,
|
||||
38986104,
|
||||
46060780
|
||||
],
|
||||
"3.8.0.41": [
|
||||
46064024,
|
||||
46064848,
|
||||
46063880,
|
||||
38986104,
|
||||
46064812
|
||||
],
|
||||
"3.8.1.26": [
|
||||
46409448,
|
||||
46410272,
|
||||
46409304,
|
||||
38986104,
|
||||
46410236
|
||||
],
|
||||
"3.9.0.28": [
|
||||
48418376,
|
||||
48419280,
|
||||
48418232,
|
||||
38986104,
|
||||
48419244
|
||||
],
|
||||
"3.9.2.23": [
|
||||
50320784,
|
||||
50321712,
|
||||
50320640,
|
||||
38986104,
|
||||
50321676
|
||||
],
|
||||
"3.9.2.26": [
|
||||
50329040,
|
||||
50329968,
|
||||
50328896,
|
||||
38986104,
|
||||
50329932
|
||||
],
|
||||
"3.9.5.91": [
|
||||
61654904,
|
||||
61654680,
|
||||
61654712,
|
||||
38986104,
|
||||
61656176
|
||||
],
|
||||
"3.9.6.19": [
|
||||
61997688,
|
||||
61997464,
|
||||
61997496,
|
||||
38986104,
|
||||
61998960
|
||||
],
|
||||
"3.9.6.33": [
|
||||
62030600,
|
||||
62031936,
|
||||
62030408,
|
||||
0,
|
||||
62031872
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user