-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_extract_api_paths.py
More file actions
35 lines (31 loc) · 1.38 KB
/
Copy path_extract_api_paths.py
File metadata and controls
35 lines (31 loc) · 1.38 KB
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
import re
from collections import Counter
from urllib.request import Request, urlopen
ua = "Mozilla/5.0"
url = "https://m.mobilelegends.com/assets/index-06f6d0af.js"
body = urlopen(Request(url, headers={"User-Agent": ua}), timeout=30).read().decode("utf-8", "ignore")
# quoted path-like strings
paths = re.findall(r'["\'](/[A-Za-z0-9_./-]{3,80})["\']', body)
c = Counter(paths)
interesting = []
for p, n in c.most_common():
if any(k in p.lower() for k in ("api", "base", "battle", "report", "season", "match", "user", "act", "gms", "source", "gateway", "stat", "hero", "friend", "privacy")):
interesting.append((n, p))
print("interesting paths:", len(interesting))
for n, p in interesting[:120]:
print(f"{n:4d} {p}")
# url: "..." patterns near request helpers
print("\nurl fields:")
for m in re.finditer(r'url\s*:\s*["\']([^"\']+)["\']', body):
u = m.group(1)
if u.startswith("/") or "http" in u or "base" in u or "battle" in u or "report" in u:
print(" ", u)
# also concat patterns Wt.api+"/..."
print("\nWt.api concatenations:")
for m in re.finditer(r'Wt\.api\s*\+\s*["\']([^"\']+)["\']', body):
print(" ", m.group(1))
print("\nWt.baseURL concatenations:")
for m in re.finditer(r'(?:Wt\.baseURL|V1)\s*\+\s*["\']([^"\']+)["\']', body):
print(" ", m.group(1))
for m in re.finditer(r'baseURL.*?["\'](/[^"\']+)["\']', body):
print(" baseURL nearby", m.group(1)[:100])