From f2570c773aa18e4ac236b1cf7f43acfb4ca080dd Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Fri, 5 Sep 2014 15:05:44 +0200 Subject: iframe injector example: use inline script --- examples/iframe_injector.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/iframe_injector.py (limited to 'examples/iframe_injector.py') diff --git a/examples/iframe_injector.py b/examples/iframe_injector.py new file mode 100644 index 00000000..7042dbab --- /dev/null +++ b/examples/iframe_injector.py @@ -0,0 +1,18 @@ +# Usage: mitmdump -s "iframe_injector.py url" +# (this script works best with --anticache) +from libmproxy.protocol.http import decoded + + +def start(ctx, argv): + if len(argv) != 2: + raise ValueError('Usage: -s "iframe_injector.py url"') + ctx.iframe_url = argv[1] + + +def handle_response(ctx, flow): + with decoded(flow.response): # Remove content encoding (gzip, ...) + c = flow.response.replace( + '', + '' % ctx.iframe_url) + if c > 0: + ctx.log("Iframe injected!") \ No newline at end of file -- cgit v1.2.3