def connectionMade(self): mitmf_logger.debug("[ServerConnection] HTTP connection made.") ProxyPlugins.getInstance().hook() self.sendRequest() self.sendHeaders() if (self.command == 'POST'): self.sendPostData()
def handleEndHeaders(self): if (self.isImageRequest and self.contentLength != None): self.client.setHeader("Content-Length", self.contentLength) if self.length == 0: self.shutdown() ProxyPlugins.getInstance().hook() if logging.getLevelName(mitmf_logger.getEffectiveLevel()) == "DEBUG": for header, value in self.client.headers.iteritems(): mitmf_logger.debug("[ServerConnection] Receiving header: ({}: {})".format(header, value))
def getPluginStatus(plugin): # example: http://127.0.0.1:9090/cachekill for p in ProxyPlugins.getInstance().plist: if plugin == p.name: return json.dumps("1") return json.dumps("0")
def getPlugins(): # example: http://127.0.0.1:9090/ pdict = {} #print ProxyPlugins.getInstance().plist for activated_plugin in ProxyPlugins.getInstance().plist: pdict[activated_plugin.name] = True #print ProxyPlugins.getInstance().plist_all for plugin in ProxyPlugins.getInstance().plist_all: if plugin.name not in pdict: pdict[plugin.name] = False #print ProxyPlugins.getInstance().pmthds return json.dumps(pdict)
def handleStatus(self, version, code, message): values = ProxyPlugins.getInstance().hook() version = values['version'] code = values['code'] message = values['message'] mitmf_logger.debug("[ServerConnection] Server response: {} {} {}".format(version, code, message)) self.client.setResponseCode(int(code), message)
def __init__(self, channel, queued, reactor=reactor): Request.__init__(self, channel, queued) self.reactor = reactor self.urlMonitor = URLMonitor.getInstance() self.hsts = URLMonitor.getInstance().isHstsBypass() self.cookieCleaner = CookieCleaner.getInstance() self.dnsCache = DnsCache.getInstance() self.plugins = ProxyPlugins.getInstance() #self.uniqueId = random.randint(0, 10000) #Use are own DNS server instead of reactor.resolve() self.resolver = URLMonitor.getInstance().getResolver() self.customResolver = dns.resolver.Resolver() self.customResolver.nameservers = ['127.0.0.1'] self.customResolver.port = URLMonitor.getInstance().getResolverPort()
def __init__(self, channel, queued, reactor=reactor): Request.__init__(self, channel, queued) self.reactor = reactor self.urlMonitor = URLMonitor.getInstance() self.hsts = URLMonitor.getInstance().isHstsBypass() self.cookieCleaner = CookieCleaner.getInstance() self.dnsCache = DnsCache.getInstance() self.plugins = ProxyPlugins.getInstance() #self.uniqueId = random.randint(0, 10000) #Use are own DNS server instead of reactor.resolve() self.resolver = URLMonitor.getInstance().getResolver() self.customResolver = dns.resolver.Resolver() self.customResolver.nameservers = ['127.0.0.1'] self.customResolver.port = URLMonitor.getInstance().getResolverPort()
def __init__(self, command, uri, postData, headers, client): self.command = command self.uri = uri self.postData = postData self.headers = headers self.client = client self.clientInfo = None self.urlMonitor = URLMonitor.getInstance() self.hsts = URLMonitor.getInstance().isHstsBypass() self.app = URLMonitor.getInstance().isAppCachePoisoning() self.plugins = ProxyPlugins.getInstance() self.isImageRequest = False self.isCompressed = False self.contentLength = None self.shutdownComplete = False
def __init__(self, command, uri, postData, headers, client): self.command = command self.uri = uri self.postData = postData self.headers = headers self.client = client self.clientInfo = None self.urlMonitor = URLMonitor.getInstance() self.hsts = URLMonitor.getInstance().isHstsBypass() self.app = URLMonitor.getInstance().isAppCachePoisoning() self.plugins = ProxyPlugins.getInstance() self.isImageRequest = False self.isCompressed = False self.contentLength = None self.shutdownComplete = False
def setPluginStatus(plugin, status): # example: http://127.0.0.1:9090/cachekill/1 # enabled # example: http://127.0.0.1:9090/cachekill/0 # disabled if status == "1": for p in ProxyPlugins.getInstance().plist_all: if (p.name == plugin) and (p not in ProxyPlugins.getInstance().plist): ProxyPlugins.getInstance().addPlugin(p) return json.dumps({"plugin": plugin, "response": "success"}) elif status == "0": for p in ProxyPlugins.getInstance().plist: if p.name == plugin: ProxyPlugins.getInstance().removePlugin(p) return json.dumps({"plugin": plugin, "response": "success"}) return json.dumps({"plugin": plugin, "response": "failed"})
def handleResponse(self, data): if (self.isCompressed): mitmf_logger.debug("[ServerConnection] Decompressing content...") data = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(data)).read() data = self.replaceSecureLinks(data) data = ProxyPlugins.getInstance().hook()['data'] mitmf_logger.debug("[ServerConnection] Read from server {} bytes of data".format(len(data))) if (self.contentLength != None): self.client.setHeader('Content-Length', len(data)) try: self.client.write(data) except: pass try: self.shutdown() except: mitmf_logger.info("[ServerConnection] Client connection dropped before request finished.")
def shutdown(message=None): for plugin in ProxyPlugins.getInstance().plist: plugin.finish() sys.exit(message)
if getattr(args, p.optname): p.initialize(args) load.append(p) if vars(args)[p.optname] is True: if hasattr(p, 'tree_output') and p.tree_output: for line in p.tree_output: print "| |_ %s" % line except Exception, e: print "[-] Error loading plugin %s: %s" % (p.name, str(e)) #Plugins are ready to go, start MITMf if args.disproxy: ProxyPlugins.getInstance().setPlugins(load) else: from core.sslstrip.StrippingProxy import StrippingProxy from core.sslstrip.URLMonitor import URLMonitor from libs.dnschef.dnschef import DNSChef URLMonitor.getInstance().setFaviconSpoofing(args.favicon) URLMonitor.getInstance().setResolver(args.configfile['MITMf']['DNS']['resolver']) URLMonitor.getInstance().setResolverPort(args.configfile['MITMf']['DNS']['port']) DNSChef.getInstance().setCoreVars(args.configfile['MITMf']['DNS']) if args.configfile['MITMf']['DNS']['tcp'].lower() == 'on': DNSChef.getInstance().startTCP() else: DNSChef.getInstance().startUDP()
def shutdown(message=None): for plugin in ProxyPlugins.getInstance().plist: plugin.finish() sys.exit(message)
#load only the plugins that have been called at the command line if vars(args)[p.optname] is True: print "|_ {} v{}".format(p.name, p.version) if p.tree_info: for line in xrange(0, len(p.tree_info)): print "| |_ {}".format(p.tree_info.pop()) p.initialize(args) if p.tree_info: for line in xrange(0, len(p.tree_info)): print "| |_ {}".format(p.tree_info.pop()) ProxyPlugins.getInstance().addPlugin(p) #Plugins are ready to go, let's rock & roll from core.sslstrip.StrippingProxy import StrippingProxy from core.sslstrip.URLMonitor import URLMonitor URLMonitor.getInstance().setFaviconSpoofing(args.favicon) CookieCleaner.getInstance().setEnabled(args.killsessions) strippingFactory = http.HTTPFactory(timeout=10) strippingFactory.protocol = StrippingProxy reactor.listenTCP(args.listen, strippingFactory) for p in ProxyPlugins.getInstance().plist:
#load only the plugins that have been called at the command line if vars(args)[p.optname] is True: print "|_ {} v{}".format(p.name, p.version) if p.tree_info: for line in xrange(0, len(p.tree_info)): print "| |_ {}".format(p.tree_info.pop()) p.initialize(args) if p.tree_info: for line in xrange(0, len(p.tree_info)): print "| |_ {}".format(p.tree_info.pop()) ProxyPlugins.getInstance().addPlugin(p) #Plugins are ready to go, let's rock & roll from core.sslstrip.StrippingProxy import StrippingProxy from core.sslstrip.URLMonitor import URLMonitor URLMonitor.getInstance().setFaviconSpoofing(args.favicon) CookieCleaner.getInstance().setEnabled(args.killsessions) strippingFactory = http.HTTPFactory(timeout=10) strippingFactory.protocol = StrippingProxy reactor.listenTCP(args.listen, strippingFactory) for p in ProxyPlugins.getInstance().plist: