mirror of
https://github.com/lgandx/Responder.git
synced 2025-07-08 05:50:58 -07:00
Ported MultiRelay to python3 + enhancements.
This commit is contained in:
parent
24e7b7c667
commit
4bddf50b5c
82 changed files with 64692 additions and 4466 deletions
59
tools/MultiRelay/impacket-dev/impacket/examples/logger.py
Normal file
59
tools/MultiRelay/impacket-dev/impacket/examples/logger.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved.
|
||||
#
|
||||
# This software is provided under under a slightly modified version
|
||||
# of the Apache Software License. See the accompanying LICENSE file
|
||||
# for more information.
|
||||
#
|
||||
# Description: This logger is intended to be used by impacket instead
|
||||
# of printing directly. This will allow other libraries to use their
|
||||
# custom logging implementation.
|
||||
#
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
# This module can be used by scripts using the Impacket library
|
||||
# in order to configure the root logger to output events
|
||||
# generated by the library with a predefined format
|
||||
|
||||
# If the scripts want to generate log entries, they can write
|
||||
# directly to the root logger (logging.info, debug, etc).
|
||||
|
||||
class ImpacketFormatter(logging.Formatter):
|
||||
'''
|
||||
Prefixing logged messages through the custom attribute 'bullet'.
|
||||
'''
|
||||
def __init__(self):
|
||||
logging.Formatter.__init__(self,'%(bullet)s %(message)s', None)
|
||||
|
||||
def format(self, record):
|
||||
if record.levelno == logging.INFO:
|
||||
record.bullet = '[*]'
|
||||
elif record.levelno == logging.DEBUG:
|
||||
record.bullet = '[+]'
|
||||
elif record.levelno == logging.WARNING:
|
||||
record.bullet = '[!]'
|
||||
else:
|
||||
record.bullet = '[-]'
|
||||
|
||||
return logging.Formatter.format(self, record)
|
||||
|
||||
class ImpacketFormatterTimeStamp(ImpacketFormatter):
|
||||
'''
|
||||
Prefixing logged messages through the custom attribute 'bullet'.
|
||||
'''
|
||||
def __init__(self):
|
||||
logging.Formatter.__init__(self,'[%(asctime)-15s] %(bullet)s %(message)s', None)
|
||||
|
||||
def formatTime(self, record, datefmt=None):
|
||||
return ImpacketFormatter.formatTime(self, record, datefmt="%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def init(ts=False):
|
||||
# We add a StreamHandler and formatter to the root logger
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
if not ts:
|
||||
handler.setFormatter(ImpacketFormatter())
|
||||
else:
|
||||
handler.setFormatter(ImpacketFormatterTimeStamp())
|
||||
logging.getLogger().addHandler(handler)
|
||||
logging.getLogger().setLevel(logging.INFO)
|
Loading…
Add table
Add a link
Reference in a new issue