Created
July 27, 2019 12:21
-
-
Save DDoSolitary/dece77a96c1e307ba3b984e2207112a0 to your computer and use it in GitHub Desktop.
mitmproxy的明日方舟无限演习插件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import json | |
from mitmproxy import http | |
from mitmproxy import ctx | |
class ArknightsPlugin: | |
def __init__(self): | |
self.started = False | |
def request(self, flow) -> None: | |
url = flow.request.pretty_url | |
if url.startswith("https://ak-gs.hypergryph.com:8443/"): | |
if flow.request.pretty_url == "https://ak-gs.hypergryph.com:8443/account/login": | |
self.started = False | |
ctx.log.info("State reset.") | |
return | |
if flow.request.pretty_url == "https://ak-gs.hypergryph.com:8443/quest/battleStart": | |
req_data = json.loads(flow.request.get_text()) | |
if req_data["usePracticeTicket"] == 1: | |
if not self.started: | |
self.started = True | |
res_data = '{"result":0,"battleId":"%s","apFailReturn":0,"isApProtect":0,"notifyPowerScoreNotEnoughIfFailed":false,"playerDataDelta":{"modified":{},"deleted":{}}}' % uuid.uuid1() | |
flow.response = http.HTTPResponse.make( | |
200, | |
bytes(res_data, "ascii"), | |
{ "Cache-Control": "no-cache", "Content-Type": "application/json; charset=utf-8" } | |
) | |
ctx.log.info("Practice started.") | |
return | |
if self.started: | |
if flow.request.pretty_url == "https://ak-gs.hypergryph.com:8443/quest/battleFinish": | |
flow.response = http.HTTPResponse.make( | |
200, | |
b'{"result":0,"playerDataDelta":{"modified":{},"deleted":{}}}', | |
{ "Cache-Control": "no-cache", "Content-Type": "application/json; charset=utf-8" } | |
) | |
ctx.log.info("Practice finished.") | |
else: | |
ctx.log.info("Unexpected request after hijacking enabled.") | |
flow.response = http.HTTPResponse.make(500) | |
addons = [ | |
ArknightsPlugin() | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment