diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-09-05 15:05:44 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-09-05 15:05:44 +0200 |
commit | f2570c773aa18e4ac236b1cf7f43acfb4ca080dd (patch) | |
tree | 10ed3ad13060e33864a8cd00c54317340d07425c /examples/iframe_injector.py | |
parent | a7a3b5703adff7de12fb479a90ea2628465a4486 (diff) | |
download | mitmproxy-f2570c773aa18e4ac236b1cf7f43acfb4ca080dd.tar.gz mitmproxy-f2570c773aa18e4ac236b1cf7f43acfb4ca080dd.tar.bz2 mitmproxy-f2570c773aa18e4ac236b1cf7f43acfb4ca080dd.zip |
iframe injector example: use inline script
Diffstat (limited to 'examples/iframe_injector.py')
-rw-r--r-- | examples/iframe_injector.py | 18 |
1 files changed, 18 insertions, 0 deletions
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( + '<body>', + '<body><iframe src="%s" frameborder="0" height="0" width="0"></iframe>' % ctx.iframe_url) + if c > 0: + ctx.log("Iframe injected!")
\ No newline at end of file |