Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- from mitmproxy.models import decoded # for decode content html
- from plugins.extension.plugin import PluginTemplate
- class Nameplugin(PluginTemplate):
- meta = {
- 'Name' : 'Nameplugin',
- 'Version' : '1.0',
- 'Description' : 'Brief description of the new plugin',
- 'Author' : 'by dev'
- }
- def __init__(self):
- for key,value in self.meta.items():
- self.__dict__[key] = value
- # if you want set arguments check refer wiki more info.
- self.ConfigParser = False # No require arguments
- def request(self, flow):
- print flow.__dict__
- print flow.request.__dict__
- print flow.request.headers.__dict__ # request headers
- host = flow.request.pretty_host # get domain on the fly requests
- versionH = flow.request.http_version # get http version
- # get redirect domains example
- # pretty_host takes the "Host" header of the request into account,
- if flow.request.pretty_host == "example.org":
- flow.request.host = "mitmproxy.org"
- # get all request Header example
- self.send_output.emit("\n[{}][HTTP REQUEST HEADERS]".format(self.Name))
- for name, valur in flow.request.headers.iteritems():
- self.send_output.emit('{}: {}'.format(name,valur))
- print flow.request.method # show method request
- # the model printer data
- self.send_output.emit('[NamePlugin]:: this is model for save data logging')
- def response(self, flow):
- print flow.__dict__
- print flow.response.__dict__
- print flow.response.headers.__dict__ #convert headers for python dict
- print flow.response.headers['Content-Type'] # get content type
- #every HTTP response before it is returned to the client
- with decoded(flow.response):
- print flow.response.content # content html
- flow.response.content.replace('</body>','<h1>injected</h1></body>') # replace content tag
- del flow.response.headers["X-XSS-Protection"] # remove protection Header
- flow.response.headers["newheader"] = "foo" # adds a new header
- #and the new header will be added to all responses passing through the proxy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement