Replace upsidedown with mirror reflection

This commit is contained in:
Miroslav 2018-02-25 21:17:08 +02:00
parent eee109117f
commit 3b134df77f
2 changed files with 9 additions and 16 deletions

View File

@ -0,0 +1,9 @@
"""
This script reflects all content passing through the proxy.
"""
from mitmproxy import http
def response(flow: http.HTTPFlow) -> None:
reflector = b"<style>body {transform: scaleX(-1);}</style></head>"
flow.response.content = flow.response.content.replace(b"</head>", reflector)

View File

@ -1,16 +0,0 @@
"""
This script rotates all images passing through the proxy by 180 degrees.
"""
import io
from PIL import Image
from mitmproxy import http
def response(flow: http.HTTPFlow) -> None:
if flow.response.headers.get("content-type", "").startswith("image"):
s = io.BytesIO(flow.response.content)
img = Image.open(s).rotate(180)
s2 = io.BytesIO()
img.save(s2, "png")
flow.response.content = s2.getvalue()
flow.response.headers["content-type"] = "image/png"