-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdecrypt.py
38 lines (26 loc) · 1.05 KB
/
decrypt.py
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
import re
import base64
from urllib.parse import urljoin
_pattern = re.compile(r"dynamicurl\|(?P<path>.+?)\|wzwsquestion\|(?P<question>.+?)\|wzwsfactor\|(?P<factor>\d+)")
def decrypt_wzws(text: str) -> str:
# noinspection PyBroadException
try:
return _decrypt_by_python(text)
except Exception:
print("解析html错误")
def _decrypt_by_python(text: str) -> str:
base_url = "http://wenshu.court.gov.cn"
group_dict = _pattern.search(text).groupdict()
question = group_dict["question"]
factor = int(group_dict["factor"])
path = group_dict["path"]
label = "WZWS_CONFIRM_PREFIX_LABEL{}".format(sum(ord(i) for i in question) * factor + 111111)
challenge = base64.b64encode(label.encode()).decode()
dynamic_url = urljoin(base_url, path)
dynamic_url = "{url}?{query}".format(url=dynamic_url, query="wzwschallenge={}".format(challenge))
return dynamic_url
if __name__ == "__main__":
with open("demo.html") as f:
_content = f.read()
_resp = decrypt_wzws(_content)
print(_resp)