我尝试使用以下脚本但收到错误。
#!/usr/bin/env python3
def request(flow: http.HTTPFlow) -> None:
if flow.request.method == "POST" or flow.request.method == "PUT":
logger.info("Sensitive pattern found")
flow.kill()
logger.info("Am I killed part 1")
答案 0 :(得分:0)
它需要导入 http 模块以使用HTTPFlow。对于日志记录,可以使用ctx.log,例如:
ctx.log.info("This is some informative text.")
ctx.log.warn("This is a warning.")
ctx.log.error("This is an error.")
因此,脚本看起来像:
#!/usr/bin/env python3
from mitmproxy import http
from mitmproxy import ctx
def request(flow: http.HTTPFlow) -> None:
if flow.request.method == "POST" or flow.request.method == "PUT":
ctx.log.info("Sensitive pattern found")
flow.kill()
ctx.log.info("Am I killed part 1")