Modded Responder plugin to accomodate re-write

Started converting all string formatting to format() API
This commit is contained in:
byt3bl33d3r 2015-04-13 20:25:14 +02:00
parent 4dd497d8b9
commit 460399541f
3 changed files with 34 additions and 38 deletions

@ -1 +1 @@
Subproject commit e7a69e46c13f77c90300965a0897d13de6437f78 Subproject commit 137e8eea61ef3c3d0426312a72894d6a4ed32cef

View file

@ -52,7 +52,7 @@ Banners().printBanner()
if os.geteuid() != 0: if os.geteuid() != 0:
sys.exit("[-] When man-in-the-middle you want, run as r00t you will, hmm?") sys.exit("[-] When man-in-the-middle you want, run as r00t you will, hmm?")
parser = argparse.ArgumentParser(description="MITMf v%s - Framework for MITM attacks" % mitmf_version, version=mitmf_version, usage='', epilog="Use wisely, young Padawan.",fromfile_prefix_chars='@') parser = argparse.ArgumentParser(description="MITMf v{} - Framework for MITM attacks".format(mitmf_version), version=mitmf_version, usage='', epilog="Use wisely, young Padawan.",fromfile_prefix_chars='@')
#add MITMf options #add MITMf options
mgroup = parser.add_argument_group("MITMf", "Options for MITMf") mgroup = parser.add_argument_group("MITMf", "Options for MITMf")
mgroup.add_argument("--log-level", type=str,choices=['debug', 'info'], default="info", help="Specify a log level [default: info]") mgroup.add_argument("--log-level", type=str,choices=['debug', 'info'], default="info", help="Specify a log level [default: info]")
@ -80,29 +80,29 @@ try:
for p in plugin_classes: for p in plugin_classes:
plugins.append(p()) plugins.append(p())
except: except:
print "Failed to load plugin class %s" % str(p) print "Failed to load plugin class {}".format(p)
#Give subgroup to each plugin with options #Give subgroup to each plugin with options
try: try:
for p in plugins: for p in plugins:
if p.desc == "": if p.desc == "":
sgroup = parser.add_argument_group("%s" % p.name,"Options for %s." % p.name) sgroup = parser.add_argument_group(p.name,"Options for {}.".format(p.name))
else: else:
sgroup = parser.add_argument_group("%s" % p.name, p.desc) sgroup = parser.add_argument_group(p.name, p.desc)
sgroup.add_argument("--%s" % p.optname, action="store_true",help="Load plugin %s" % p.name) sgroup.add_argument("--{}".format(p.optname), action="store_true",help="Load plugin {}".format(p.name))
if p.has_opts: if p.has_opts:
p.add_options(sgroup) p.add_options(sgroup)
except NotImplementedError: except NotImplementedError:
sys.exit("[-] %s plugin claimed option support, but didn't have it." % p.name) sys.exit("[-] {} plugin claimed option support, but didn't have it.".format(p.name))
args = parser.parse_args() args = parser.parse_args()
try: try:
configfile = ConfigObj(args.configfile) configfile = ConfigObj(args.configfile)
except Exception, e: except Exception, e:
sys.exit("[-] Error parsing config file: " + str(e)) sys.exit("[-] Error parsing config file: {}".format(e))
config_args = configfile['MITMf']['args'] config_args = configfile['MITMf']['args']
if config_args: if config_args:
@ -117,14 +117,14 @@ if config_args:
try: try:
args.ip_address = get_if_addr(args.interface) args.ip_address = get_if_addr(args.interface)
if (args.ip_address == "0.0.0.0") or (args.ip_address is None): if (args.ip_address == "0.0.0.0") or (args.ip_address is None):
sys.exit("[-] Interface %s does not have an assigned IP address" % args.interface) sys.exit("[-] Interface {} does not have an assigned IP address".format(args.interface))
except Exception, e: except Exception, e:
sys.exit("[-] Error retrieving interface IP address: %s" % e) sys.exit("[-] Error retrieving interface IP address: {}".format(e))
try: try:
args.mac_address = get_if_hwaddr(args.interface) args.mac_address = get_if_hwaddr(args.interface)
except Exception, e: except Exception, e:
sys.exit("[-] Error retrieving interface MAC address: %s" % e) sys.exit("[-] Error retrieving interface MAC address: {}".format(e))
args.configfile = configfile #so we can pass the configobj down to all the plugins args.configfile = configfile #so we can pass the configobj down to all the plugins
@ -144,18 +144,17 @@ mitmf_logger.addHandler(fileHandler)
##################################################################################################### #####################################################################################################
#All our options should be loaded now, pass them onto plugins #All our options should be loaded now, pass them onto plugins
print "[*] MITMf v%s online... initializing plugins" % mitmf_version print "[*] MITMf v{} online... initializing plugins".format(mitmf_version)
load = [] load = []
for p in plugins: for p in plugins:
try:
if vars(args)[p.optname] is True: if vars(args)[p.optname] is True:
print "|_ %s v%s" % (p.name, p.version) print "|_ {} v{}".format(p.name, p.version)
if hasattr(p, 'tree_output') and p.tree_output: if hasattr(p, 'tree_output') and p.tree_output:
for line in p.tree_output: for line in p.tree_output:
print "| |_ %s" % line print "| |_ {}".format(line)
p.tree_output.remove(line) p.tree_output.remove(line)
if getattr(args, p.optname): if getattr(args, p.optname):
@ -165,10 +164,7 @@ for p in plugins:
if vars(args)[p.optname] is True: if vars(args)[p.optname] is True:
if hasattr(p, 'tree_output') and p.tree_output: if hasattr(p, 'tree_output') and p.tree_output:
for line in p.tree_output: for line in p.tree_output:
print "| |_ %s" % line print "| |_ {}".format(line)
except Exception:
print "[-] Error loading plugin %s: %s" % (p.name, PrintException())
#Plugins are ready to go, start MITMf #Plugins are ready to go, start MITMf
if args.disproxy: if args.disproxy:
@ -204,9 +200,9 @@ else:
p.plugin_reactor(strippingFactory) #we pass the default strippingFactory, so the plugins can use it p.plugin_reactor(strippingFactory) #we pass the default strippingFactory, so the plugins can use it
print "|" print "|"
print "|_ Sergio-Proxy v%s online" % sergio_version print "|_ Sergio-Proxy v{} online".format(sergio_version)
print "|_ SSLstrip v%s by Moxie Marlinspike online" % sslstrip_version print "|_ SSLstrip v{} by Moxie Marlinspike online".format(sslstrip_version)
print "|_ DNSChef v%s online\n" % dnschef_version print "|_ DNSChef v{} online\n".format(dnschef_version)
reactor.run() reactor.run()

View file

@ -45,25 +45,25 @@ class Responder(Plugin):
except Exception, e: except Exception, e:
sys.exit('[-] Error parsing config for Responder: ' + str(e)) sys.exit('[-] Error parsing config for Responder: ' + str(e))
if options.Analyse: if options.Analyze:
self.tree_output.append("Responder is in analyze mode. No NBT-NS, LLMNR, MDNS requests will be poisoned") self.tree_output.append("Responder is in analyze mode. No NBT-NS, LLMNR, MDNS requests will be poisoned")
resp = ResponderMITMf() resp = ResponderMITMf(options, config)
resp.setCoreVars(options, config) #resp.setCoreVars(options, config)
result = resp.AnalyzeICMPRedirect() result = resp.AnalyzeICMPRedirect(options.Analyze)
if result: if result:
for line in result: for line in result:
self.tree_output.append(line) self.tree_output.append(line)
resp.printDebugInfo() #resp.printDebugInfo()
resp.start() resp.start()
def plugin_reactor(self, strippingFactory): def plugin_reactor(self, strippingFactory):
reactor.listenTCP(3141, strippingFactory) reactor.listenTCP(3141, strippingFactory)
def add_options(self, options): def add_options(self, options):
options.add_argument('--analyze', dest="Analyse", action="store_true", help="Allows you to see NBT-NS, BROWSER, LLMNR requests from which workstation to which workstation without poisoning") options.add_argument('--analyze', dest="Analyze", action="store_true", help="Allows you to see NBT-NS, BROWSER, LLMNR requests from which workstation to which workstation without poisoning")
options.add_argument('--basic', dest="Basic", default=False, action="store_true", help="Set this if you want to return a Basic HTTP authentication. If not set, an NTLM authentication will be returned") options.add_argument('--basic', dest="Basic", default=False, action="store_true", help="Set this if you want to return a Basic HTTP authentication. If not set, an NTLM authentication will be returned")
options.add_argument('--wredir', dest="Wredirect", default=False, action="store_true", help="Set this to enable answers for netbios wredir suffix queries. Answering to wredir will likely break stuff on the network (like classics 'nbns spoofer' would). Default value is therefore set to False") options.add_argument('--wredir', dest="Wredirect", default=False, action="store_true", help="Set this to enable answers for netbios wredir suffix queries. Answering to wredir will likely break stuff on the network (like classics 'nbns spoofer' would). Default value is therefore set to False")
options.add_argument('--nbtns', dest="NBTNSDomain", default=False, action="store_true", help="Set this to enable answers for netbios domain suffix queries. Answering to domain suffixes will likely break stuff on the network (like a classic 'nbns spoofer' would). Default value is therefore set to False") options.add_argument('--nbtns', dest="NBTNSDomain", default=False, action="store_true", help="Set this to enable answers for netbios domain suffix queries. Answering to domain suffixes will likely break stuff on the network (like a classic 'nbns spoofer' would). Default value is therefore set to False")