diff --git a/config/mitmf.conf b/config/mitmf.conf index 0f97ca9..40c105a 100644 --- a/config/mitmf.conf +++ b/config/mitmf.conf @@ -37,7 +37,7 @@ nameservers = 8.8.8.8 [[[A]]] # Queries for IPv4 address records - *.butt.org=192.168.178.27 + *.thesprawl.org=192.168.178.27 [[[AAAA]]] # Queries for IPv6 address records *.thesprawl.org=2001:db8::1 diff --git a/core/configwatcher.py b/core/configwatcher.py index 81a06c9..7f7b955 100644 --- a/core/configwatcher.py +++ b/core/configwatcher.py @@ -17,24 +17,27 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # - -from watchdog.observers import Observer -from watchdog.events import FileSystemEventHandler +import pyinotify +import threading from configobj import ConfigObj -class ConfigWatcher(FileSystemEventHandler): +class ConfigWatcher(pyinotify.ProcessEvent): @property def config(self): return ConfigObj("./config/mitmf.conf") - def on_modified(self, event): + def process_IN_MODIFY(self, event): self.on_config_change() def start_config_watch(self): - observer = Observer() - observer.schedule(self, path='./config', recursive=False) - observer.start() + wm = pyinotify.WatchManager() + wm.add_watch('./config/mitmf.conf', pyinotify.IN_MODIFY) + notifier = pyinotify.Notifier(wm, self) + + t = threading.Thread(name='ConfigWatcher', target=notifier.loop) + t.setDaemon(True) + t.start() def on_config_change(self): """ We can subclass this function to do stuff after the config file has been modified""" diff --git a/mitmf.py b/mitmf.py index 37663b8..08a8b73 100755 --- a/mitmf.py +++ b/mitmf.py @@ -21,7 +21,6 @@ import logging logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #Gets rid of IPV6 Error when importing scapy logging.getLogger("requests").setLevel(logging.WARNING) #Disables "Starting new HTTP Connection (1)" log message -logging.getLogger("watchdog").setLevel(logging.ERROR) #Disables watchdog's debug messages import argparse import sys @@ -29,6 +28,7 @@ import os import threading import core.responder.settings as settings +from argparse import RawTextHelpFormatter from twisted.web import http from twisted.internet import reactor from core.logger import logger @@ -46,7 +46,8 @@ if os.geteuid() != 0: parser = argparse.ArgumentParser(description="MITMf v{} - '{}'".format(mitmf_version, mitmf_codename), version="{} - '{}'".format(mitmf_version, mitmf_codename), usage='mitmf.py -i interface [mitmf options] [plugin name] [plugin options]', - epilog="Use wisely, young Padawan.") + epilog="Use wisely, young Padawan.", + formatter_class=RawTextHelpFormatter) #add MITMf options sgroup = parser.add_argument_group("MITMf", "Options for MITMf") diff --git a/plugins/beefautorun.py b/plugins/beefautorun.py index 5970bf2..0892427 100644 --- a/plugins/beefautorun.py +++ b/plugins/beefautorun.py @@ -18,12 +18,11 @@ # USA # import os +import pyinotify from plugins.plugin import Plugin from plugins.inject import Inject from core.beefapi import BeefAPI -from watchdog.observers import Observer -from watchdog.events import FileSystemEventHandler class BeefAutorun(Inject, Plugin): name = "BeEFAutoloader" @@ -52,14 +51,14 @@ class BeefAutorun(Inject, Plugin): def options(self, options): pass -class RuleWatcher(FileSystemEventHandler): +class RuleWatcher(pyinotify.ProcessEvent): def __init__(self, beef, logger): - FileSystemEventHandler.__init__(self) + pyinotify.ProcessEvent.__init__(self) self.beef = beef self.log = logger - def on_modified(self, event): + def process_IN_MODIFY(self, event): self.log.debug('Detected ARE rule change!') for rule in self.beef.are_rules.list(): self.log.debug('Deleting rule id: {} name: {}'.format(rule.id, rule.name)) @@ -74,6 +73,10 @@ class RuleWatcher(FileSystemEventHandler): self.beef.are_rules.add(rule_path) def start(self): - observer = Observer() - observer.schedule(self, path='./config/beef_arerules/enabled', recursive=False) - observer.start() \ No newline at end of file + wm = pyinotify.WatchManager() + wm.add_watch('./config/beef_arerules/enabled', pyinotify.IN_MODIFY) + notifier = pyinotify.Notifier(wm, self) + + t = threading.Thread(name='RuleWatcher', target=notifier.loop) + t.setDaemon(True) + t.start() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 9e9b87c..39e3952 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ git+git://github.com/kti/python-netfilterqueue -git+git://github.com/gorakhargosh/watchdog +pyinotify pycrypto>=2.6 pyasn1>=0.1.7 cryptography