from mitmproxy import http from mitmproxy import ctx from mitmproxy.proxy import layer, layers
defload(loader): # ctx.options.web_open_browser = False # We change the connection strategy to lazy so that next_layer happens before we actually connect upstream. ctx.options.connection_strategy = "lazy" ctx.options.upstream_cert = False ctx.options.ssl_insecure = True defnext_layer(nextlayer: layer.NextLayer): # ctx.log( # f"{nextlayer.context=}\n" # f"{nextlayer.data_client()[:70]=}\n" # ) sni = nextlayer.context.client.sni if sni and (sni.endswith("yuanshen.com") or sni.endswith("mihoyo.com") or sni.endswith("hoyoverse.com") or sni.endswith("starrails.com") or sni.endswith("bhsr.com") or sni.endswith("kurogame.com") or sni.endswith("zenlesszonezero.com") or sni.endswith("api.g3.proletariat.com") or sni.endswith("global01.os.honkaiimpact3.com") or sni.endswith("overseas01-appsflyer-report.honkaiimpact3.com") or sni.endswith("westglobal01.honkaiimpact3.com") or sni.endswith("bh3.com") andnot (sni.endswith("bundle.bh3.com") or sni.endswith("qcloud.bh3.com") or sni.endswith("bh3rd-beta.bh3.com"))): ctx.log('sni:' + sni) nextlayer.context.server.address = ("127.0.0.1", 443)
defrequest(flow: http.HTTPFlow) -> None: # flow.request.scheme = "http" # pretty_host takes the "Host" header of the request into account if flow.request.pretty_url.startswith('http://global01.west.honkaiimpact3.com'): flow.request.host = "127.0.0.1" flow.request.headers["Host"] = "127.0.0.1" if flow.request.pretty_url.startswith('http://log-upload-os.mihoyo.com') or flow.request.pretty_url.startswith('http://client-report.bh3.com'): flow.response = http.Response.make( 200, # (optional) status code b"404 not found", # (optional) content {"Content-Type": "text/html"} # (optional) headers ) return
20:11:18 <HTTP> 200 GET /query_dispatch 20:11:18 <HTTP> 200 GET /query_gateway 20:11:18 <HTTP> 404 POST /crashdump/dataUpload 20:11:18 <HTTP> 404 POST /crashdump/dataUpload 20:11:18 <HTTP> 404 POST /crashdump/dataUpload 20:11:18 <HTTP> 200 GET /admin/mi18n/plat_oversea/m2020030410/m2020030410-version.json 20:11:18 <HTTP> 200 GET /admin/mi18n/plat_os/m09291531181441/m09291531181441-version.json 20:11:18 <HTTP> 200 POST /sdk/dataUpload 20:11:18 <HTTP> 200 POST /sdk/dataUpload 20:11:18 <HTTP> 200 GET /bh3_os/combo/granter/api/getConfig 20:11:18 <HTTP> 200 GET /device-fp/api/getExtList 20:11:18 <HTTP> 200 GET /combo/box/api/config/sdk/combo 20:11:18 <HTTP> 200 GET /bh3_os/mdk/shield/api/loadConfig 20:11:18 <HTTP> 200 POST /bh3_os/combo/granter/api/compareProtocolVersion 20:11:18 <HTTP> 200 POST /sdk/dataUpload 20:11:18 <HTTP> 200 POST /sdk/dataUpload 20:11:18 <HTTP> 200 POST /device-fp/api/getFp 20:11:18 <HTTP> 200 POST /sdk/dataUpload 20:11:19 <HTTP> 200 POST /sdk/dataUpload 20:11:19 <HTTP> 200 POST /sdk/dataUpload 20:11:23 <HTTP> 200 POST /sdk/dataUpload 20:11:23 <HTTP> 200 GET /combo/box/api/config/sw/precache 20:11:23 <HTTP> 200 POST /sdk/dataUpload 20:11:23 <HTTP> 200 GET /sw.html 20:11:24 <HTTP> 404 POST /apm/dataUpload 20:11:24 <HTTP> 200 POST /common/h5log/log/batch 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /bh3_os/mdk/shield/api/verify 20:11:27 <HTTP20:11:27 > 200 POST /sdk/dataUpload <HTTP> 200 POST /account/device/api/listNewerDevices 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /sdk/dataUpload 20:11:27 <HTTP> 200 POST /data_abtest_api/config/experiment/list 20:11:27 <HTTP> 200 POST /bh3_os/combo/granter/login/v2/login 20:11:28 <HTTP> 200 POST /sdk/dataUpload 20:11:28 <HTTP> 200 GET /bh3_os/mdk/agreement/api/getAgreementInfos 20:11:28 <HTTP> 200 POST /sdk/dataUpload 20:11:30 <HTTP> 404 POST /apm/dataUpload 20:11:30 <HTTP> 200 POST /common/h5log/log/batch