Skip to content

Instantly share code, notes, and snippets.

@danielribeiro
Created July 26, 2017 01:34
Show Gist options
  • Save danielribeiro/975fbfe2ec867b5f68b1dcb0ba2c6f66 to your computer and use it in GitHub Desktop.
Save danielribeiro/975fbfe2ec867b5f68b1dcb0ba2c6f66 to your computer and use it in GitHub Desktop.
mitmproxyexample
"""
Saves all webp images
"""
import io
from mitmproxy import http
def response(flow: http.HTTPFlow) -> None:
if flow.response.headers.get("content-type", "").startswith("image/webp"):
s = flow.response.content
name = flow.request.pretty_url.replace('/', '_').replace(':', '_').replace('http', 'req').replace('?', '_').replace('&', '_')
f = open("~/mitm/%s.webp" % name, "wb")
f.write(s)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment