FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WeChatOpenDevTools-Python/utils/wechatutils.py at main · BeLinKang/WeChatOpenDevTools-Python · GitHub
BeLinKang
/
WeChatOpenDevTools-Python
Public
forked from
JaveleyQAQ/WeChatOpenDevTools-Python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
WeChatOpenDevTools-Python
/
utils
/
wechatutils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (56 loc) · 3.09 KB
Breadcrumbs
WeChatOpenDevTools-Python
/
utils
/
wechatutils.py
Copy path
File metadata and controls
70 lines (56 loc) · 3.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import
os
,
re
,
winreg
import
psutil
from
utils
.
colors
import
Color
class
WechatUtils
:
def
__init__
(
self
):
self
.
configs_path
=
self
.
get_configs_path
()
self
.
version_list
=
self
.
get_version_list
()
# self.pid , self.version = self.get_wechat_pid_and_version()
# if self.pid is None and self.version is None:
# self.print_process_not_found_message()
def
get_configs_path
(
self
):
current_path
=
os
.
path
.
abspath
(
__file__
)
relative_path
=
'..
\\
configs
\\
'
return
os
.
path
.
join
(
os
.
path
.
dirname
(
current_path
),
relative_path
)
def
get_version_list
(
self
):
configs_path
=
self
.
configs_path
version_list
=
os
.
listdir
(
configs_path
)
versions_list
=
[
int
(
file
.
split
(
'_'
)[
1
])
for
file
in
version_list
if
file
.
startswith
(
'address_'
)]
return
versions_list
def
is_wechatEx_process
(
self
,
cmdline
):
process_name
=
"WeChatAppEx"
return
cmdline
and
process_name
in
cmdline
[
0
]
and
"--type="
not
in
' '
.
join
(
cmdline
)
def
find_installation_path
(
self
,
program_name
):
try
:
reg_path
=
r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
reg_key
=
winreg
.
OpenKey
(
winreg
.
HKEY_LOCAL_MACHINE
,
reg_path
)
for
i
in
range
(
1024
):
try
:
sub_key_name
=
winreg
.
EnumKey
(
reg_key
,
i
)
sub_key
=
winreg
.
OpenKey
(
reg_key
,
sub_key_name
)
display_name
=
winreg
.
QueryValueEx
(
sub_key
,
"DisplayName"
)[
0
]
# 排除企业微信 和 适配英文区域安装的WeChat
if
program_name
==
display_name
or
display_name
==
'WeChat'
:
install_location
=
winreg
.
QueryValueEx
(
sub_key
,
"InstallLocation"
)[
0
]
+
"\WeChat.exe"
print
(
Color
.
GREEN
+
f"[+] 查找到
{
program_name
}
的安装路径是:
{
install_location
}
"
+
Color
.
END
)
print
(
Color
.
GREEN
+
f"[+] 正在尝试重启微信..."
+
Color
.
END
)
return
install_location
except
WindowsError
:
pass
except
Exception
as
e
:
print
(
Color
.
RED
+
f"[-] 查找安装路径时出错:
{
e
}
"
+
Color
.
END
)
def
extract_version_number
(
self
,
cmdline
):
str
=
' '
.
join
(
cmdline
)
version_match
=
re
.
search
(
r'"version":(\d+)'
,
str
)
return
int
(
version_match
.
group
(
1
))
if
version_match
else
None
def
get_wechat_pid_and_version
(
self
):
processes
=
(
proc
.
info
for
proc
in
psutil
.
process_iter
([
'pid'
,
'cmdline'
]))
wechatEx_processes
=
(
p
for
p
in
processes
if
self
.
is_wechatEx_process
(
p
[
'cmdline'
]))
for
process
in
wechatEx_processes
:
pid
=
process
[
'pid'
]
version
=
self
.
extract_version_number
(
process
[
'cmdline'
])
if
version
in
self
.
version_list
:
return
pid
,
version
return
None
,
None
def
print_process_not_found_message
(
self
):
print
(
Color
.
RED
+
"[-] 未找到匹配版本的微信进程或微信未运行"
+
Color
.
END
)
Back
|
FazBrowse Home
|
New Git URL