mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-03-12 04:35:49 -07:00
replaced watchdog with pyinotify
This commit is contained in:
parent
d535c8796c
commit
885ecc3a4e
@ -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
|
||||
|
@ -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"""
|
||||
|
5
mitmf.py
5
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")
|
||||
|
@ -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()
|
||||
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()
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user