使用python重构

This commit is contained in:
xaoyo committed 2023-08-21 23:55:59 +08:00
1 parent 6bc3ea3ba9
commit 140cbe61ed
8 files changed
+523 -877

No files matched your search

+196
View File
@@ -0,0 +1,196 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: getwxinfo.py
# Description:
# Author: xaoyaoo
# Date: 2023/08/21
# -------------------------------------------------------------------------------
import binascii
import json
import ctypes
import psutil
def get_name(pid, base_address, n_size=100):
array = (ctypes.c_byte * n_size)()
if ctypes.windll.kernel32.ReadProcessMemory(ctypes.c_void_p(pid), ctypes.c_void_p(base_address), array, n_size,
0) == 0:
return ""
null_index = n_size
for i in range(n_size):
if array[i] == 0:
null_index = i
break
text = ctypes.string_at(ctypes.byref(array), null_index).decode('utf-8', errors='ignore')
return text
def get_account(pid, base_address, n_size=100):
array = (ctypes.c_byte * n_size)()
if ctypes.windll.kernel32.ReadProcessMemory(ctypes.c_void_p(pid), ctypes.c_void_p(base_address), array, n_size,
0) == 0:
return ""
null_index = n_size
for i in range(n_size):
if array[i] == 0:
null_index = i
break
text = ctypes.string_at(ctypes.byref(array), null_index).decode('utf-8', errors='ignore')
return text
def get_mobile(pid, base_address, n_size=100):
array = (ctypes.c_byte * n_size)()
if ctypes.windll.kernel32.ReadProcessMemory(ctypes.c_void_p(pid), ctypes.c_void_p(base_address), array, n_size,
0) == 0:
return ""
null_index = n_size
for i in range(n_size):
if array[i] == 0:
null_index = i
break
text = ctypes.string_at(ctypes.byref(array), null_index).decode('utf-8', errors='ignore')
return text
def get_mail(pid, base_address, n_size=100):
array = (ctypes.c_byte * n_size)()
if ctypes.windll.kernel32.ReadProcessMemory(ctypes.c_void_p(pid), ctypes.c_void_p(base_address), array, n_size,
0) == 0:
return ""
null_index = n_size
for i in range(n_size):
if array[i] == 0:
null_index = i
break
text = ctypes.string_at(ctypes.byref(array), null_index).decode('utf-8', errors='ignore')
return text
def get_hex(h_process, lp_base_address):
array = ctypes.create_string_buffer(8)
if ctypes.windll.kernel32.ReadProcessMemory(h_process, ctypes.c_void_p(lp_base_address), array, 8, 0) == 0:
return ""
num = 32
array2 = (ctypes.c_ubyte * num)()
lp_base_address2 = (
(int(binascii.hexlify(array[7]), 16) << 56) +
(int(binascii.hexlify(array[6]), 16) << 48) +
(int(binascii.hexlify(array[5]), 16) << 40) +
(int(binascii.hexlify(array[4]), 16) << 32) +
(int(binascii.hexlify(array[3]), 16) << 24) +
(int(binascii.hexlify(array[2]), 16) << 16) +
(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']
file_version = f"{win32api.HIWORD(ms)}.{win32api.LOWORD(ms)}.{win32api.HIWORD(ls)}.{win32api.LOWORD(ls)}"
# version = parse(file_version)
return file_version
def read_test(version_list):
support_list = None
wechat_process = None
rd = []
for process in psutil.process_iter(['name', 'exe', 'pid', 'cmdline']):
if process.info['name'] == 'WeChat.exe':
tmp_rd = {}
wechat_process = process
tmp_rd['pid'] = wechat_process.pid
# print("[+] WeChatProcessPID: " + str(wechat_process.info['pid']))
wechat_win_base_address = 0
for module in wechat_process.memory_maps(grouped=False):
if module.path and 'WeChatWin.dll' in module.path:
wechat_win_base_address = module.addr
wechat_win_base_address = int(wechat_win_base_address, 16)
file_version = get_file_version(module.path)
file_version_str = str(file_version)
tmp_rd['version'] = file_version_str
# print("[+] WeChatVersion: " + file_version_str)
if file_version_str not in version_list:
return "[-] WeChat Current Version Is: " + file_version_str + " Not Supported"
else:
support_list = version_list[file_version_str]
support_list = list(support_list)
break
Handle = ctypes.windll.kernel32.OpenProcess(0x1F0FFF, False, wechat_process.pid)
if support_list is None:
return "[-] WeChat Base Address Get Failed"
else:
wechat_key = wechat_win_base_address + support_list[4]
hex_key = get_hex(Handle, wechat_key)
tmp_rd['key'] = hex_key.strip()
if hex_key.strip() == "":
return "[-] WeChat Is Running, But Maybe Not Logged In"
else:
wechat_name = wechat_win_base_address + support_list[0]
tmp_rd['name'] = get_name(Handle, wechat_name, 100).strip()
wechat_account = wechat_win_base_address + support_list[1]
account = get_account(Handle, wechat_account, 100).strip()
if account.strip() == "":
tmp_rd['account'] = "None"
else:
tmp_rd['account'] = account
wechat_mobile = wechat_win_base_address + support_list[2]
mobile = get_mobile(Handle, wechat_mobile, 100).strip()
if mobile.strip() == "":
tmp_rd['mobile'] = "None"
else:
tmp_rd['mobile'] = mobile
wechat_mail = wechat_win_base_address + support_list[3]
mail = get_mail(Handle, wechat_mail, 100).strip()
if mail.strip() != "":
tmp_rd['mail'] = mail
else:
tmp_rd['mail'] = "None"
rd.append(tmp_rd)
if wechat_process is None:
return "[-] WeChat No Run"
return rd
if __name__ == "__main__":
version_list = json.load(open("version_list.json", "r", encoding="utf-8"))
rd = read_test(version_list)
for i in rd:
for k, v in i.items():
print(f"[+] {k}: {v}")
print("=====================================")
+11
View File
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Author: xaoyaoo
# Date: 2023/08/21
# -------------------------------------------------------------------------------
if __name__ == '__main__':
pass
+303
View File
@@ -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,
38986104,
62031872
]
}