mirror of
https://github.com/byt3bl33d3r/MITMf.git
synced 2025-07-06 21:12:16 -07:00
Added debug logging to ProxyPlugins, it will now print a traceback if errors occur in hooked functions
This commit is contained in:
parent
5d07551a50
commit
dfa9c9d65e
4 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
|
import traceback
|
||||||
|
|
||||||
mitmf_logger = logging.getLogger("mitmf")
|
mitmf_logger = logging.getLogger("mitmf")
|
||||||
|
|
||||||
|
@ -59,9 +60,12 @@ class ProxyPlugins:
|
||||||
for p in plugins:
|
for p in plugins:
|
||||||
self.addPlugin(p)
|
self.addPlugin(p)
|
||||||
|
|
||||||
|
mitmf_logger.debug("[ProxyPlugins] Loaded {} plugin/s".format(len(self.plist)))
|
||||||
|
|
||||||
def addPlugin(self,p):
|
def addPlugin(self,p):
|
||||||
'''Load a plugin'''
|
'''Load a plugin'''
|
||||||
self.plist.append(p)
|
self.plist.append(p)
|
||||||
|
mitmf_logger.debug("[ProxyPlugins] Adding {} plugin".format(p.name))
|
||||||
for mthd in p.implements:
|
for mthd in p.implements:
|
||||||
try:
|
try:
|
||||||
self.pmthds[mthd].append(getattr(p,mthd))
|
self.pmthds[mthd].append(getattr(p,mthd))
|
||||||
|
@ -71,6 +75,7 @@ class ProxyPlugins:
|
||||||
def removePlugin(self,p):
|
def removePlugin(self,p):
|
||||||
'''Unload a plugin'''
|
'''Unload a plugin'''
|
||||||
self.plist.remove(p)
|
self.plist.remove(p)
|
||||||
|
mitmf_logger.debug("[ProxyPlugins] Removing {} plugin".format(p.name))
|
||||||
for mthd in p.implements:
|
for mthd in p.implements:
|
||||||
self.pmthds[mthd].remove(p)
|
self.pmthds[mthd].remove(p)
|
||||||
|
|
||||||
|
@ -95,8 +100,12 @@ class ProxyPlugins:
|
||||||
for f in self.pmthds[fname]:
|
for f in self.pmthds[fname]:
|
||||||
a = f(**args)
|
a = f(**args)
|
||||||
if a != None: args = a
|
if a != None: args = a
|
||||||
except KeyError:
|
except KeyError as e:
|
||||||
pass
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
#This is needed because errors in hooked functions won't raise an Exception + Tracback (which can be infuriating)
|
||||||
|
mitmf_logger.error("[ProxyPlugins] Exception occurred in hooked function")
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
#pass our changes to the locals back down
|
#pass our changes to the locals back down
|
||||||
return args
|
return args
|
||||||
|
|
|
@ -189,7 +189,7 @@ class ServerConnection(HTTPClient):
|
||||||
self.client.setHeader('Content-Length', len(data))
|
self.client.setHeader('Content-Length', len(data))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.client.write(data) #Gets rid of some generic errors
|
self.client.write(data)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ from core.utils import SystemConfig
|
||||||
from plugins.plugin import Plugin
|
from plugins.plugin import Plugin
|
||||||
from plugins.CacheKill import CacheKill
|
from plugins.CacheKill import CacheKill
|
||||||
|
|
||||||
|
mitmf_logger = logging.getLogger("mitmf")
|
||||||
|
|
||||||
class Inject(CacheKill, Plugin):
|
class Inject(CacheKill, Plugin):
|
||||||
name = "Inject"
|
name = "Inject"
|
||||||
optname = "inject"
|
optname = "inject"
|
||||||
|
|
|
@ -66,4 +66,5 @@ class Upsidedownternet(Plugin):
|
||||||
mitmf_logger.info("{} Flipped image".format(request.client.getClientIP()))
|
mitmf_logger.info("{} Flipped image".format(request.client.getClientIP()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
mitmf_logger.info("{} Error: {}".format(request.client.getClientIP(), e))
|
mitmf_logger.info("{} Error: {}".format(request.client.getClientIP(), e))
|
||||||
|
|
||||||
return {'request': request, 'data': data}
|
return {'request': request, 'data': data}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue