mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-08 05:51:48 -07:00
Added error handling to DNS and SMB servers when port is in use
Added check to see if a plugins options were called without loading the actual plugin
This commit is contained in:
parent
70ec5a2bbc
commit
d3e509d4cd
10 changed files with 45 additions and 23 deletions
|
@ -23,6 +23,11 @@
|
|||
rpcpass = abc123
|
||||
|
||||
[[SMB]]
|
||||
|
||||
#
|
||||
#Here you can configure MITMf's internal SMB server
|
||||
#
|
||||
|
||||
#Set a custom challenge
|
||||
Challenge = 1122334455667788
|
||||
|
||||
|
|
|
@ -474,10 +474,14 @@ class DNSChef(ConfigWatcher):
|
|||
self.onConfigChange()
|
||||
self.startConfigWatch()
|
||||
|
||||
try:
|
||||
if self.config['MITMf']['DNS']['tcp'].lower() == 'on':
|
||||
self.startTCP()
|
||||
else:
|
||||
self.startUDP()
|
||||
except socket.error as e:
|
||||
if "Address already in use" in e:
|
||||
sys.exit("\n[-] Unable to start DNS server on port {}: port already in use".format(self.config['MITMf']['DNS']['port']))
|
||||
|
||||
# Initialize and start the DNS Server
|
||||
def startUDP(self):
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
##################################################################################
|
||||
#SMB stuff starts here
|
||||
##################################################################################
|
||||
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
|
||||
|
||||
|
@ -334,7 +331,3 @@ class SMB1LM(BaseRequestHandler):
|
|||
except Exception:
|
||||
self.request.close()
|
||||
pass
|
||||
|
||||
##################################################################################
|
||||
#SMB Server stuff ends here
|
||||
##################################################################################
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import sys
|
||||
import threading
|
||||
from socket import error as socketerror
|
||||
from impacket import version, smbserver, LOG
|
||||
from core.configwatcher import ConfigWatcher
|
||||
|
||||
|
@ -23,8 +24,12 @@ class SMBserver(ConfigWatcher):
|
|||
|
||||
def __init__(self, listenAddress = '0.0.0.0', listenPort=445, configFile=''):
|
||||
|
||||
try:
|
||||
self.server = smbserver.SimpleSMBServer(listenAddress, listenPort, configFile)
|
||||
self.server.setSMBChallenge(self.config["MITMf"]["SMB"]["Challenge"])
|
||||
except socketerror as e:
|
||||
if "Address already in use" in e:
|
||||
sys.exit("\n[-] Unable to start SMB server on port 445: port already in use")
|
||||
|
||||
def start(self):
|
||||
t = threading.Thread(name='SMBserver', target=self.server.start)
|
||||
|
|
|
@ -16,7 +16,7 @@ class IMAPServer():
|
|||
t = threading.Thread(name="IMAPServer", target=server.serve_forever)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
mitmf_logger.error("[IMAPServer] Error starting on port {}: {}".format(143, e))
|
||||
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
|
||||
|
|
|
@ -20,7 +20,7 @@ class LDAPServer():
|
|||
t = threading.Thread(name="LDAPServer", target=server.serve_forever)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
mitmf_logger.error("[LDAPServer] Error starting on port {}: {}".format(389, e))
|
||||
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
|
||||
|
|
|
@ -19,7 +19,7 @@ class MSSQLServer():
|
|||
t = threading.Thread(name="MSSQLServer", target=server.serve_forever)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
mitmf_logger.error("[MSSQLServer] Error starting on port {}: {}".format(1433, e))
|
||||
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer):
|
||||
|
|
14
mitmf.py
14
mitmf.py
|
@ -69,6 +69,9 @@ try:
|
|||
except Exception as e:
|
||||
print "[-] Failed to load plugin class {}: {}".format(p, e)
|
||||
|
||||
|
||||
arg_dict = dict() #dict containing a plugin's optname with it's relative options
|
||||
|
||||
#Give subgroup to each plugin with options
|
||||
try:
|
||||
for p in plugins:
|
||||
|
@ -81,6 +84,9 @@ try:
|
|||
|
||||
if p.has_opts:
|
||||
p.add_options(sgroup)
|
||||
|
||||
arg_dict[p.optname] = vars(sgroup)['_group_actions']
|
||||
|
||||
except NotImplementedError:
|
||||
sys.exit("[-] {} plugin claimed option support, but didn't have it.".format(p.name))
|
||||
|
||||
|
@ -90,6 +96,14 @@ if len(sys.argv) is 1:
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Definitely a better way to do this, will need to clean this up in the future
|
||||
# Checks to see if we called a plugin's options without first invoking the actual plugin
|
||||
for plugin, options in arg_dict.iteritems():
|
||||
if vars(args)[plugin] is False:
|
||||
for option in options:
|
||||
if vars(args)[option.dest] is True:
|
||||
sys.exit("[-] Called plugin options without invoking --{}".format(plugin))
|
||||
|
||||
#first check to see if we supplied a valid interface
|
||||
myip = SystemConfig.getIP(args.interface)
|
||||
mymac = SystemConfig.getMAC(args.interface)
|
||||
|
|
|
@ -48,7 +48,7 @@ class Responder(Plugin):
|
|||
try:
|
||||
config = self.config['Responder']
|
||||
smbChal = self.config['MITMf']['SMB']['Challenge']
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
sys.exit('[-] Error parsing config for Responder: ' + str(e))
|
||||
|
||||
LANFingerprinter().start(options)
|
||||
|
|
|
@ -22,7 +22,7 @@ import sys
|
|||
import logging
|
||||
|
||||
from plugins.plugin import Plugin
|
||||
from core.utils import IpTables
|
||||
from core.utils import IpTables, SystemConfig
|
||||
from core.sslstrip.URLMonitor import URLMonitor
|
||||
from core.dnschef.DNSchef import DNSChef
|
||||
|
||||
|
@ -37,10 +37,11 @@ class HSTSbypass(Plugin):
|
|||
def initialize(self, options):
|
||||
self.options = options
|
||||
self.manualiptables = options.manualiptables
|
||||
ip_address = SystemConfig.getIP(options.interface)
|
||||
|
||||
if not options.manualiptables:
|
||||
if IpTables.getInstance().dns is False:
|
||||
IpTables.getInstance().DNS(options.ip_address, self.config['MITMf']['DNS']['port'])
|
||||
IpTables.getInstance().DNS(ip_address, self.config['MITMf']['DNS']['port'])
|
||||
|
||||
URLMonitor.getInstance().setHstsBypass()
|
||||
DNSChef.getInstance().setHstsBypass()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue