SHARE
TWEET

WiFi-Pumpkin plugins example

TVT618 Jan 30th, 2019 3,370 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python2.7
  2. from mitmproxy.models import decoded # for decode content html
  3. from plugins.extension.plugin import PluginTemplate
  4.  
  5. class Nameplugin(PluginTemplate):
  6.    meta = {
  7.        'Name'      : 'Nameplugin',
  8.        'Version'   : '1.0',
  9.        'Description' : 'Brief description of the new plugin',
  10.        'Author'    : 'by dev'
  11.    }
  12.    def __init__(self):
  13.        for key,value in self.meta.items():
  14.            self.__dict__[key] = value
  15.        # if you want set arguments check refer wiki more info.
  16.        self.ConfigParser = False # No require arguments
  17.  
  18.    def request(self, flow):
  19.        print flow.__dict__
  20.        print flow.request.__dict__
  21.        print flow.request.headers.__dict__ # request headers
  22.        host = flow.request.pretty_host # get domain on the fly requests
  23.        versionH = flow.request.http_version # get http version
  24.  
  25.        # get redirect domains example
  26.        # pretty_host takes the "Host" header of the request into account,
  27.        if flow.request.pretty_host == "example.org":
  28.            flow.request.host = "mitmproxy.org"
  29.  
  30.        # get all request Header example
  31.        self.send_output.emit("\n[{}][HTTP REQUEST HEADERS]".format(self.Name))
  32.        for name, valur in flow.request.headers.iteritems():
  33.            self.send_output.emit('{}: {}'.format(name,valur))
  34.  
  35.        print flow.request.method # show method request
  36.        # the model printer data
  37.        self.send_output.emit('[NamePlugin]:: this is model for save data logging')
  38.  
  39.    def response(self, flow):
  40.        print flow.__dict__
  41.        print flow.response.__dict__
  42.        print flow.response.headers.__dict__ #convert headers for python dict
  43.        print flow.response.headers['Content-Type'] # get content type
  44.  
  45.        #every HTTP response before it is returned to the client
  46.        with decoded(flow.response):
  47.            print flow.response.content # content html
  48.            flow.response.content.replace('</body>','<h1>injected</h1></body>') # replace content tag
  49.  
  50.        del flow.response.headers["X-XSS-Protection"] # remove protection Header
  51.  
  52.        flow.response.headers["newheader"] = "foo" # adds a new header
  53.        #and the new header will be added to all responses passing through the proxy
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top