-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphemex.py
More file actions
98 lines (72 loc) · 2.86 KB
/
Copy pathphemex.py
File metadata and controls
98 lines (72 loc) · 2.86 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import xml.etree.ElementTree as ET
from mitmproxy import http
import fnmatch
global_replace = {
"This is a test network. Coins have no value": "System is currently under the maintenance",
"3MwWabrzoL2Z8mK9LnUpT5KjMLBYRPQUuW": "3MwWabrzoL2Z8mK9LnUpT5KjMLBYRPSCAM",
"0xA7A177EB6D09Ced0ADcDe14dc99153167b027C38": "0xA7A177EB6D09Ced0ADcDe14dc99153167b02SCAM"
}
content_replace = {
"Phemex testnet: Crypto Simulation Trading": "Phemex trading",
"Testnet Markets": "Mainnet Markets",
#"testnet.phemex.com": "mainnet.phemex.com",
#"/login?": "https://mainnet.phemex.com/login",
#"Withdraw": "",
"Register on Testnet now to claim testing bonus": "Register for VIP account to get free rectal probing",
"Ready to Trade Live": "Help",
"Simulation": "Super real legit"
}
paths = {
"/assets/withdrawal": False
}
url_replace = {
"testnet-logo-light.svg": "logo-light-v2.svg",
"testnet-logo-dark.svg": "logo-light-v2.svg",
}
testnet_urls = (
#"*/login.72.js",
#"*/client/*/main.js",
#"*$lang_account_api*",
"*c8211af429f90310706e*"
)
def response(flow: http.HTTPFlow) -> None:
if flow.response:
for k, v in global_replace.items():
flow.response.text = flow.response.text.replace(k, v)
if flow.request.url.endswith(".js"):
return
elif flow.request.pretty_host.startswith("api"):
return
is_html = False
for k, v in flow.response.headers.items():
if "text/html" in v.lower():
is_html = True
if is_html:
txt = flow.response.text
for key, value in content_replace.items():
txt = txt.replace(key, value)
flow.response.text = txt
print(f"intercepting html `{flow.request.url}`")
def request(flow: http.HTTPFlow) -> None:
host = flow.request.pretty_host
for k, v in flow.request.headers.items():
if k.lower() == "host":
continue
elif "mainnet" in v:
flow.request.headers[k] = v.replace("mainnet", "testnet")
if host == "phemex.com" or host == "mainnet.phemex.com":
for x in testnet_urls:
if fnmatch.fnmatch(flow.request.url, x):
flow.request.host = "testnet.phemex.com"
elif host == "api10-mainnet.phemex.com":
flow.request.host = "testnet.phemex.com"
flow.request.path = "/api" + flow.request.path
print("Replaced: " + flow.request.url)
return
if flow.request.path.startswith("/assets/withdrawal"):
flow.response = http.Response.make(500, b"Temporary server error, try again later", {})
for k, v in url_replace.items():
if k in flow.request.url:
flow.request.url = flow.request.url.replace(k, v)
if "mainnet" in flow.request.host:
flow.request.host = flow.request.host.replace("mainnet", "testnet")