Skip to content

Commit 81f6558

Browse files
5858
authored andcommitted
指定pid
1 parent d0d2e39 commit 81f6558

File tree

4 files changed

+32
-51
lines changed

4 files changed

+32
-51
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

main.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@
33
from utils.commons import Commons
44
from utils.banner import generate_banner
55
from utils.colors import Color
6-
6+
import argparse
77

88

99
def print_colored_message(message, color):
1010
print(color + message + Color.END)
1111

1212
def main():
13-
commons.load_wechatEx_configs()
13+
HELPALL = """
14+
请选择要执行的方法:
15+
[+] python main.py -h 查看帮助
16+
[+] python main.py -p 指定pid
17+
18+
"""
19+
parser = argparse.ArgumentParser(description=HELPALL, formatter_class=RawTextHelpFormatter)
20+
parser.add_argument('-p', help='指定pid',dest="pid", type=int)
21+
args = parser.parse_args()
22+
23+
if args.pid:
24+
commons.load_wechatEx_configs_pid(args.pid)
25+
else:
26+
commons.load_wechatEx_configs()
1427

1528
if __name__ == "__main__":
1629
generate_banner()

utils/commons.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ def load_wechatEx_configs(self):
4040
else:
4141
self.wechatutils_instance.print_process_not_found_message()
4242

43+
def load_wechatEx_configs_pid(self,pid):
44+
path = self.wechatutils_instance.get_configs_path()
45+
version = self.wechatutils_instance.get_wechat_version_mac()
46+
if pid or version is not None:
47+
wehcatEx_hookcode = open(path + "../scripts/hook.js", "r", encoding="utf-8").read()
48+
wechatEx_addresses = open(path + "../configs/address_{}_arm.json".format(version)).read()
49+
wehcatEx_hookcode = "var address=" + wechatEx_addresses + wehcatEx_hookcode
50+
self.inject_wehcatEx(pid, wehcatEx_hookcode)
51+
else:
52+
self.wechatutils_instance.print_process_not_found_message()

utils/wechatutils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ def get_wechat_pid_and_version_mac(self):
8282
except subprocess.CalledProcessError as e:
8383
return e.stderr
8484

85+
def get_wechat_version_mac(self):
86+
try:
87+
version_command = "ps aux | grep 'WeChatAppEx' | grep -v 'grep' | grep ' --client_version' | grep '-user-agent=' | grep -oE 'MacWechat/([0-9]+\.)+[0-9]+\(0x\d+\)' | grep -oE '(0x\d+)' | sed 's/0x//g' | head -n 1"
88+
version = subprocess.run(version_command, shell=True, check=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.replace("\n","")
89+
return version
90+
except subprocess.CalledProcessError as e:
91+
return e.stderr

0 commit comments

Comments
 (0)