mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-08-19 13:10:03 -07:00
initial dynamic config support
added configwatcher.py
This commit is contained in:
parent
96eb4e2fa6
commit
663f38e732
26 changed files with 1187 additions and 281 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
import re, os
|
||||
import logging
|
||||
from core.ConfigWatcher import ConfigWatcher
|
||||
|
||||
mitmf_logger = logging.getLogger('mimtf')
|
||||
|
||||
|
@ -31,8 +32,6 @@ class URLMonitor:
|
|||
# Start the arms race, and end up here...
|
||||
javascriptTrickery = [re.compile("http://.+\.etrade\.com/javascript/omntr/tc_targeting\.html")]
|
||||
_instance = None
|
||||
sustitucion = {} # LEO: diccionario host / sustitucion
|
||||
real = {} # LEO: diccionario host / real
|
||||
patchDict = {
|
||||
'https:\/\/fbstatic-a.akamaihd.net':'http:\/\/webfbstatic-a.akamaihd.net',
|
||||
'https:\/\/www.facebook.com':'http:\/\/social.facebook.com',
|
||||
|
@ -46,9 +45,6 @@ class URLMonitor:
|
|||
self.faviconReplacement = False
|
||||
self.hsts = False
|
||||
self.app = False
|
||||
self.hsts_config = None
|
||||
self.resolver = 'dnschef'
|
||||
self.resolverport = 53
|
||||
|
||||
@staticmethod
|
||||
def getInstance():
|
||||
|
@ -57,21 +53,13 @@ class URLMonitor:
|
|||
|
||||
return URLMonitor._instance
|
||||
|
||||
#This is here because I'm lazy
|
||||
def setResolver(self, resolver):
|
||||
self.resolver = str(resolver).lower()
|
||||
|
||||
#This is here because I'm lazy
|
||||
def getResolver(self):
|
||||
return self.resolver
|
||||
|
||||
#This is here because I'm lazy
|
||||
def setResolverPort(self, port):
|
||||
self.resolverport = int(port)
|
||||
return ConfigWatcher.getInstance().getConfig()['MITMf']['DNS']['resolver'].lower()
|
||||
|
||||
#This is here because I'm lazy
|
||||
def getResolverPort(self):
|
||||
return self.resolverport
|
||||
return int(ConfigWatcher.getInstance().getConfig()['MITMf']['DNS']['port'])
|
||||
|
||||
def isSecureLink(self, client, url):
|
||||
for expression in URLMonitor.javascriptTrickery:
|
||||
|
@ -92,7 +80,7 @@ class URLMonitor:
|
|||
s.add(to_url)
|
||||
return
|
||||
url_set = set([from_url, to_url])
|
||||
mitmf_logger.debug("[URLMonitor][AppCachePoison] Set redirection: %s" % url_set)
|
||||
mitmf_logger.debug("[URLMonitor][AppCachePoison] Set redirection: {}".format(url_set))
|
||||
self.redirects.append(url_set)
|
||||
|
||||
def getRedirectionSet(self, url):
|
||||
|
@ -123,15 +111,15 @@ class URLMonitor:
|
|||
port = 443
|
||||
|
||||
if self.hsts:
|
||||
if not self.sustitucion.has_key(host):
|
||||
if not self.getHstsConfig[1].has_key(host):
|
||||
lhost = host[:4]
|
||||
if lhost=="www.":
|
||||
self.sustitucion[host] = "w"+host
|
||||
self.real["w"+host] = host
|
||||
self.getHstsConfig[1][host] = "w"+host
|
||||
self.getHstsConfig[0]["w"+host] = host
|
||||
else:
|
||||
self.sustitucion[host] = "web"+host
|
||||
self.real["web"+host] = host
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] SSL host (%s) tokenized (%s)" % (host,self.sustitucion[host]) )
|
||||
self.getHstsConfig[1][host] = "web"+host
|
||||
self.getHstsConfig[0]["web"+host] = host
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] SSL host ({}) tokenized ({})".format(host, self.getHstsConfig[1][host]))
|
||||
|
||||
url = 'http://' + host + path
|
||||
#mitmf_logger.debug("HSTS stripped URL: %s %s"%(client, url))
|
||||
|
@ -139,7 +127,7 @@ class URLMonitor:
|
|||
self.strippedURLs.add((client, url))
|
||||
self.strippedURLPorts[(client, url)] = int(port)
|
||||
|
||||
return 'http://'+ self.sustitucion[host] + path
|
||||
return 'http://'+ self.getHstsConfig[1][host] + path
|
||||
|
||||
else:
|
||||
url = method + host + path
|
||||
|
@ -150,40 +138,35 @@ class URLMonitor:
|
|||
def setFaviconSpoofing(self, faviconSpoofing):
|
||||
self.faviconSpoofing = faviconSpoofing
|
||||
|
||||
def setHstsBypass(self, hstsconfig):
|
||||
self.hsts = True
|
||||
self.hsts_config = hstsconfig
|
||||
def getHstsConfig(self):
|
||||
sustitucion = dict()
|
||||
real = dict()
|
||||
|
||||
for k,v in self.hsts_config.iteritems():
|
||||
self.sustitucion[k] = v
|
||||
self.real[v] = k
|
||||
for k,v in ConfigWatcher.getInstance().getConfig()['SSLstrip+']:
|
||||
sustitucion[k] = v
|
||||
real[v] = k
|
||||
|
||||
return (real, sustitucion)
|
||||
|
||||
def setHstsBypass(self):
|
||||
self.hsts = True
|
||||
|
||||
def setAppCachePoisoning(self):
|
||||
self.app = True
|
||||
|
||||
def setClientLogging(self, clientLogging):
|
||||
self.clientLogging = clientLogging
|
||||
|
||||
def isFaviconSpoofing(self):
|
||||
return self.faviconSpoofing
|
||||
|
||||
def isClientLogging(self):
|
||||
return self.clientLogging
|
||||
|
||||
def isHstsBypass(self):
|
||||
return self.hsts
|
||||
|
||||
def isAppCachePoisoning(self):
|
||||
return self.app
|
||||
|
||||
def isSecureFavicon(self, client, url):
|
||||
return ((self.faviconSpoofing == True) and (url.find("favicon-x-favicon-x.ico") != -1))
|
||||
|
||||
def URLgetRealHost(self, host):
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Parsing host: %s"% host)
|
||||
if self.real.has_key(host):
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Found host in list: %s"% self.real[host])
|
||||
return self.real[host]
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Parsing host: {}".format(host))
|
||||
|
||||
if self.getHstsConfig()[0].has_key(host):
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Found host in list: {}".format(self.getHstsConfig()[0][host]))
|
||||
return self.getHstsConfig()[0][host]
|
||||
|
||||
else:
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Host not in list: %s"% host)
|
||||
mitmf_logger.debug("[URLMonitor][HSTS] Host not in list: {}".format(host))
|
||||
return host
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue