proxy.py 2.13 KB
Newer Older
Jaida Wu's avatar
Jaida Wu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
##
#
#   Copyright (C) 2002-2022 MlgmXyysd All Rights Reserved.
#
##

##
#
#   Genshin Impact script for mitmproxy
#
#   https://github.com/MlgmXyysd/
#
#   *Original fiddler script from https://github.lunatic.moe/fiddlerscript
#
#   Environment requirement:
#     - mitmdump from mitmproxy
#
#   @author MlgmXyysd
19
#   @version 1.1
Jaida Wu's avatar
Jaida Wu committed
20
21
22
#
##

23
from mitmproxy import http
24
from proxy_config import USE_SSL
Jaida Wu's avatar
Jaida Wu committed
25
from proxy_config import REMOTE_HOST
26
from proxy_config import REMOTE_PORT
Jaida Wu's avatar
Jaida Wu committed
27
28
29

class MlgmXyysd_Genshin_Impact_Proxy:

Jaida Wu's avatar
Jaida Wu committed
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
    LIST_DOMAINS = [
        "api-os-takumi.mihoyo.com",
        "hk4e-api-os-static.mihoyo.com",
        "hk4e-sdk-os.mihoyo.com",
        "dispatchosglobal.yuanshen.com",
        "osusadispatch.yuanshen.com",
        "account.mihoyo.com",
        "log-upload-os.mihoyo.com",
        "dispatchcntest.yuanshen.com",
        "devlog-upload.mihoyo.com",
        "webstatic.mihoyo.com",
        "log-upload.mihoyo.com",
        "hk4e-sdk.mihoyo.com",
        "api-beta-sdk.mihoyo.com",
        "api-beta-sdk-os.mihoyo.com",
        "cnbeta01dispatch.yuanshen.com",
        "dispatchcnglobal.yuanshen.com",
        "cnbeta02dispatch.yuanshen.com",
        "sdk-os-static.mihoyo.com",
        "webstatic-sea.mihoyo.com",
        "webstatic-sea.hoyoverse.com",
        "hk4e-sdk-os-static.hoyoverse.com",
        "sdk-os-static.hoyoverse.com",
        "api-account-os.hoyoverse.com",
        "hk4e-sdk-os.hoyoverse.com",
        "overseauspider.yuanshen.com",
        "gameapi-account.mihoyo.com",
        "minor-api.mihoyo.com",
        "public-data-api.mihoyo.com",
        "uspider.yuanshen.com",
Jaida Wu's avatar
Jaida Wu committed
60
61
62
        "sdk-static.mihoyo.com",
        "abtest-api-data-sg.hoyoverse.com",
        "log-upload-os.hoyoverse.com"
Jaida Wu's avatar
Jaida Wu committed
63
64
    ]

Jaida Wu's avatar
Jaida Wu committed
65
    def request(self, flow: http.HTTPFlow) -> None:
Jaida Wu's avatar
Jaida Wu committed
66
        if flow.request.host in self.LIST_DOMAINS:
67
68
69
70
            if USE_SSL:
                flow.request.scheme = "https"
            else:
                flow.request.scheme = "http"
Jaida Wu's avatar
Jaida Wu committed
71
            flow.request.host = REMOTE_HOST
72
            flow.request.port = REMOTE_PORT
Jaida Wu's avatar
Jaida Wu committed
73
74
75

addons = [
	MlgmXyysd_Genshin_Impact_Proxy()
76
]