mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-06 04:52:22 -07:00
Revamped logging , plugins will be re-added later once refactored
This commit is contained in:
parent
fb0e8a3762
commit
ff0ada2a39
34 changed files with 351 additions and 2352 deletions
|
@ -1,25 +1,52 @@
|
|||
'''
|
||||
The base plugin class. This shows the various methods that
|
||||
can get called during the MITM attack.
|
||||
'''
|
||||
from core.configwatcher import ConfigWatcher
|
||||
import logging
|
||||
#!/usr/bin/env python2.7
|
||||
|
||||
mitmf_logger = logging.getLogger('mitmf')
|
||||
# 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 logging
|
||||
import argparse
|
||||
|
||||
from core.configwatcher import ConfigWatcher
|
||||
from core.logger import logger
|
||||
|
||||
class Plugin(ConfigWatcher, object):
|
||||
name = "Generic plugin"
|
||||
optname = "generic"
|
||||
tree_info = list()
|
||||
tree_info = []
|
||||
desc = ""
|
||||
version = "0.0"
|
||||
has_opts = False
|
||||
|
||||
def __init__(self, parser):
|
||||
'''Passed the options namespace'''
|
||||
if self.desc:
|
||||
sgroup = parser.add_argument_group(self.name, self.desc)
|
||||
else:
|
||||
sgroup = parser.add_argument_group(self.name,"Options for the '{}' plugin".format(self.name))
|
||||
|
||||
sgroup.add_argument("--{}".format(self.optname), action="store_true",help="Load plugin '{}'".format(self.name))
|
||||
|
||||
self.options(sgroup)
|
||||
|
||||
def initialize(self, options):
|
||||
'''Called if plugin is enabled, passed the options namespace'''
|
||||
self.options = options
|
||||
|
||||
def clientRequest(self, request):
|
||||
def request(self, request):
|
||||
'''
|
||||
Handles all outgoing requests, hooks connectionMade()
|
||||
request object has the following attributes:
|
||||
|
@ -32,32 +59,43 @@ class Plugin(ConfigWatcher, object):
|
|||
'''
|
||||
pass
|
||||
|
||||
def serverHeaders(self, response, request):
|
||||
def responseheaders(self, response, request):
|
||||
'''
|
||||
Handles all response headers, hooks handleEndHeaders()
|
||||
'''
|
||||
pass
|
||||
|
||||
def serverResponseStatus(self, request, version, code, message):
|
||||
def responsestatus(self, request, version, code, message):
|
||||
'''
|
||||
Handles server response HTTP version, code and message
|
||||
'''
|
||||
return {"request": request, "version": version, "code": code, "message": message}
|
||||
|
||||
def serverResponse(self, response, request, data):
|
||||
def response(self, response, request, data):
|
||||
'''
|
||||
Handles all non-image responses by default, hooks handleResponse() (See Upsidedownternet for how to get images)
|
||||
'''
|
||||
return {'response': response, 'request':request, 'data': data}
|
||||
|
||||
def pluginOptions(self, options):
|
||||
def on_config_change(self):
|
||||
"""Do something when MITMf detects the config file has been modified"""
|
||||
pass
|
||||
|
||||
def options(self, options):
|
||||
'''Add your options to the options parser'''
|
||||
pass
|
||||
|
||||
def pluginReactor(self, strippingFactory):
|
||||
'''This sets up another instance of the reactor on a diffrent port, passed the default factory'''
|
||||
def reactor(self, strippingFactory):
|
||||
'''This makes it possible to set up another instance of the reactor on a diffrent port, passed the default factory'''
|
||||
pass
|
||||
|
||||
def finish(self):
|
||||
def setup_logger(self):
|
||||
formatter = logging.Formatter("%(asctime)s [{}] %(message)s".format(self.name), datefmt="%Y-%m-%d %H:%M:%S")
|
||||
self.log = logger().setup_logger(self.name, formatter)
|
||||
|
||||
formatter = logging.Formatter("%(asctime)s %(clientip)s [type:%(browser)s-%(browserv)s os:%(clientos)s] [{}] %(message)s".format(self.name), datefmt="%Y-%m-%d %H:%M:%S")
|
||||
self.clientlog = logger().setup_logger("{}_{}".format(self.name, "clientlog"), formatter)
|
||||
|
||||
def on_shutdown(self):
|
||||
'''This will be called when shutting down'''
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue