mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-08-19 21:13:26 -07:00
replaced watchdog with pyinotify
This commit is contained in:
parent
d535c8796c
commit
885ecc3a4e
5 changed files with 27 additions and 20 deletions
|
@ -37,7 +37,7 @@
|
||||||
nameservers = 8.8.8.8
|
nameservers = 8.8.8.8
|
||||||
|
|
||||||
[[[A]]] # Queries for IPv4 address records
|
[[[A]]] # Queries for IPv4 address records
|
||||||
*.butt.org=192.168.178.27
|
*.thesprawl.org=192.168.178.27
|
||||||
|
|
||||||
[[[AAAA]]] # Queries for IPv6 address records
|
[[[AAAA]]] # Queries for IPv6 address records
|
||||||
*.thesprawl.org=2001:db8::1
|
*.thesprawl.org=2001:db8::1
|
||||||
|
|
|
@ -17,24 +17,27 @@
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
# USA
|
# USA
|
||||||
#
|
#
|
||||||
|
import pyinotify
|
||||||
from watchdog.observers import Observer
|
import threading
|
||||||
from watchdog.events import FileSystemEventHandler
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
|
||||||
class ConfigWatcher(FileSystemEventHandler):
|
class ConfigWatcher(pyinotify.ProcessEvent):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
return ConfigObj("./config/mitmf.conf")
|
return ConfigObj("./config/mitmf.conf")
|
||||||
|
|
||||||
def on_modified(self, event):
|
def process_IN_MODIFY(self, event):
|
||||||
self.on_config_change()
|
self.on_config_change()
|
||||||
|
|
||||||
def start_config_watch(self):
|
def start_config_watch(self):
|
||||||
observer = Observer()
|
wm = pyinotify.WatchManager()
|
||||||
observer.schedule(self, path='./config', recursive=False)
|
wm.add_watch('./config/mitmf.conf', pyinotify.IN_MODIFY)
|
||||||
observer.start()
|
notifier = pyinotify.Notifier(wm, self)
|
||||||
|
|
||||||
|
t = threading.Thread(name='ConfigWatcher', target=notifier.loop)
|
||||||
|
t.setDaemon(True)
|
||||||
|
t.start()
|
||||||
|
|
||||||
def on_config_change(self):
|
def on_config_change(self):
|
||||||
""" We can subclass this function to do stuff after the config file has been modified"""
|
""" We can subclass this function to do stuff after the config file has been modified"""
|
||||||
|
|
5
mitmf.py
5
mitmf.py
|
@ -21,7 +21,6 @@
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #Gets rid of IPV6 Error when importing scapy
|
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("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 argparse
|
||||||
import sys
|
import sys
|
||||||
|
@ -29,6 +28,7 @@ import os
|
||||||
import threading
|
import threading
|
||||||
import core.responder.settings as settings
|
import core.responder.settings as settings
|
||||||
|
|
||||||
|
from argparse import RawTextHelpFormatter
|
||||||
from twisted.web import http
|
from twisted.web import http
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from core.logger import logger
|
from core.logger import logger
|
||||||
|
@ -46,7 +46,8 @@ if os.geteuid() != 0:
|
||||||
parser = argparse.ArgumentParser(description="MITMf v{} - '{}'".format(mitmf_version, mitmf_codename),
|
parser = argparse.ArgumentParser(description="MITMf v{} - '{}'".format(mitmf_version, mitmf_codename),
|
||||||
version="{} - '{}'".format(mitmf_version, mitmf_codename),
|
version="{} - '{}'".format(mitmf_version, mitmf_codename),
|
||||||
usage='mitmf.py -i interface [mitmf options] [plugin name] [plugin options]',
|
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
|
#add MITMf options
|
||||||
sgroup = parser.add_argument_group("MITMf", "Options for MITMf")
|
sgroup = parser.add_argument_group("MITMf", "Options for MITMf")
|
||||||
|
|
|
@ -18,12 +18,11 @@
|
||||||
# USA
|
# USA
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
|
import pyinotify
|
||||||
|
|
||||||
from plugins.plugin import Plugin
|
from plugins.plugin import Plugin
|
||||||
from plugins.inject import Inject
|
from plugins.inject import Inject
|
||||||
from core.beefapi import BeefAPI
|
from core.beefapi import BeefAPI
|
||||||
from watchdog.observers import Observer
|
|
||||||
from watchdog.events import FileSystemEventHandler
|
|
||||||
|
|
||||||
class BeefAutorun(Inject, Plugin):
|
class BeefAutorun(Inject, Plugin):
|
||||||
name = "BeEFAutoloader"
|
name = "BeEFAutoloader"
|
||||||
|
@ -52,14 +51,14 @@ class BeefAutorun(Inject, Plugin):
|
||||||
def options(self, options):
|
def options(self, options):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class RuleWatcher(FileSystemEventHandler):
|
class RuleWatcher(pyinotify.ProcessEvent):
|
||||||
|
|
||||||
def __init__(self, beef, logger):
|
def __init__(self, beef, logger):
|
||||||
FileSystemEventHandler.__init__(self)
|
pyinotify.ProcessEvent.__init__(self)
|
||||||
self.beef = beef
|
self.beef = beef
|
||||||
self.log = logger
|
self.log = logger
|
||||||
|
|
||||||
def on_modified(self, event):
|
def process_IN_MODIFY(self, event):
|
||||||
self.log.debug('Detected ARE rule change!')
|
self.log.debug('Detected ARE rule change!')
|
||||||
for rule in self.beef.are_rules.list():
|
for rule in self.beef.are_rules.list():
|
||||||
self.log.debug('Deleting rule id: {} name: {}'.format(rule.id, rule.name))
|
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)
|
self.beef.are_rules.add(rule_path)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
observer = Observer()
|
wm = pyinotify.WatchManager()
|
||||||
observer.schedule(self, path='./config/beef_arerules/enabled', recursive=False)
|
wm.add_watch('./config/beef_arerules/enabled', pyinotify.IN_MODIFY)
|
||||||
observer.start()
|
notifier = pyinotify.Notifier(wm, self)
|
||||||
|
|
||||||
|
t = threading.Thread(name='RuleWatcher', target=notifier.loop)
|
||||||
|
t.setDaemon(True)
|
||||||
|
t.start()
|
|
@ -1,5 +1,5 @@
|
||||||
git+git://github.com/kti/python-netfilterqueue
|
git+git://github.com/kti/python-netfilterqueue
|
||||||
git+git://github.com/gorakhargosh/watchdog
|
pyinotify
|
||||||
pycrypto>=2.6
|
pycrypto>=2.6
|
||||||
pyasn1>=0.1.7
|
pyasn1>=0.1.7
|
||||||
cryptography
|
cryptography
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue