mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-08-20 21:43:28 -07:00
revamped appoison plugin and fixed some bugs
This commit is contained in:
parent
ca28de91f6
commit
0defaf7b86
12 changed files with 223 additions and 333 deletions
|
@ -105,8 +105,12 @@ class ClientRequest(Request):
|
|||
pass
|
||||
|
||||
url = 'http://' + host + path
|
||||
self.uri = url # set URI to absolute
|
||||
|
||||
self.dnsCache.cacheResolution(host, address)
|
||||
#self.dnsCache.cacheResolution(host, address)
|
||||
|
||||
hostparts = host.split(':')
|
||||
self.dnsCache.cacheResolution(hostparts[0], address)
|
||||
|
||||
if (not self.cookieCleaner.isClean(self.method, client, host, headers)):
|
||||
logging.debug("Sending expired cookies...")
|
||||
|
@ -121,7 +125,12 @@ class ClientRequest(Request):
|
|||
self.urlMonitor.getSecurePort(client, url))
|
||||
else:
|
||||
logging.debug("Sending request via HTTP...")
|
||||
self.proxyViaHTTP(address, self.method, path, postData, headers)
|
||||
#self.proxyViaHTTP(address, self.method, path, postData, headers)
|
||||
port = 80
|
||||
if len(hostparts) > 1:
|
||||
port = int(hostparts[1])
|
||||
|
||||
self.proxyViaHTTP(address, self.method, path, postData, headers, port)
|
||||
|
||||
def handleHostResolvedError(self, error):
|
||||
logging.warning("Host resolution error: " + str(error))
|
||||
|
@ -143,15 +152,18 @@ class ClientRequest(Request):
|
|||
def process(self):
|
||||
logging.debug("Resolving host: %s" % (self.getHeader('host')))
|
||||
host = self.getHeader('host')
|
||||
deferred = self.resolveHost(host)
|
||||
#deferred = self.resolveHost(host)
|
||||
hostparts = host.split(':')
|
||||
deferred = self.resolveHost(hostparts[0])
|
||||
|
||||
deferred.addCallback(self.handleHostResolvedSuccess)
|
||||
deferred.addErrback(self.handleHostResolvedError)
|
||||
|
||||
def proxyViaHTTP(self, host, method, path, postData, headers):
|
||||
def proxyViaHTTP(self, host, method, path, postData, headers, port):
|
||||
connectionFactory = ServerConnectionFactory(method, path, postData, headers, self)
|
||||
connectionFactory.protocol = ServerConnection
|
||||
self.reactor.connectTCP(host, 80, connectionFactory)
|
||||
#self.reactor.connectTCP(host, 80, connectionFactory)
|
||||
self.reactor.connectTCP(host, port, connectionFactory)
|
||||
|
||||
def proxyViaSSL(self, host, method, path, postData, headers, port):
|
||||
clientContextFactory = ssl.ClientContextFactory()
|
||||
|
|
|
@ -20,7 +20,6 @@ import logging, re, string, random, zlib, gzip, StringIO, sys
|
|||
import plugins
|
||||
|
||||
from twisted.web.http import HTTPClient
|
||||
from libs.sslstripkoto.ResponseTampererFactory import ResponseTampererFactory
|
||||
from URLMonitor import URLMonitor
|
||||
from libs.sergioproxy.ProxyPlugins import ProxyPlugins
|
||||
|
||||
|
@ -43,7 +42,6 @@ class ServerConnection(HTTPClient):
|
|||
self.headers = headers
|
||||
self.client = client
|
||||
self.urlMonitor = URLMonitor.getInstance()
|
||||
self.responseTamperer = ResponseTampererFactory.getTampererInstance()
|
||||
self.plugins = ProxyPlugins.getInstance()
|
||||
self.isImageRequest = False
|
||||
self.isCompressed = False
|
||||
|
@ -88,7 +86,7 @@ class ServerConnection(HTTPClient):
|
|||
|
||||
def sendHeaders(self):
|
||||
for header, value in self.headers.items():
|
||||
logging.debug("Sending header: %s : %s" % (header, value))
|
||||
logging.debug("Sending header: (%s => %s)" % (header, value))
|
||||
self.sendHeader(header, value)
|
||||
|
||||
self.endHeaders()
|
||||
|
@ -145,6 +143,8 @@ class ServerConnection(HTTPClient):
|
|||
else:
|
||||
self.client.setHeader(key, value)
|
||||
|
||||
logging.debug("Receiving header: (%s => %s)" % (key, value))
|
||||
|
||||
def handleEndHeaders(self):
|
||||
if (self.isImageRequest and self.contentLength != None):
|
||||
self.client.setHeader("Content-Length", self.contentLength)
|
||||
|
@ -175,11 +175,6 @@ class ServerConnection(HTTPClient):
|
|||
logging.debug("Read from server:\n" + data)
|
||||
|
||||
data = self.replaceSecureLinks(data)
|
||||
|
||||
#Hook the ResponseTampererFactory
|
||||
if self.responseTamperer:
|
||||
data = self.responseTamperer.tamper(self.client.uri, data, self.client.responseHeaders, self.client.getAllHeaders(), self.client.getClientIP())
|
||||
|
||||
res = self.plugins.hook()
|
||||
data = res['data']
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ class URLMonitor:
|
|||
def __init__(self):
|
||||
self.strippedURLs = set()
|
||||
self.strippedURLPorts = {}
|
||||
self.redirects = []
|
||||
self.faviconReplacement = False
|
||||
|
||||
def isSecureLink(self, client, url):
|
||||
|
@ -66,6 +67,19 @@ class URLMonitor:
|
|||
else:
|
||||
return 443
|
||||
|
||||
def addRedirection(self, from_url, to_url):
|
||||
for s in self.redirects:
|
||||
if from_url in s:
|
||||
s.add(to_url)
|
||||
return
|
||||
self.redirects.append(set([from_url,to_url]))
|
||||
|
||||
def getRedirectionSet(self, url):
|
||||
for s in self.redirects:
|
||||
if url in s:
|
||||
return s
|
||||
return set([url])
|
||||
|
||||
def addSecureLink(self, client, url):
|
||||
methodIndex = url.find("//") + 2
|
||||
method = url[0:methodIndex]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue