Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions python/meterpreter/meterpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,9 @@
)
# ---------------------------------------------------------------

# Note: DEBUGGING is driven by the runtime config block, not a build-time
# constant, so logging is configured where DEBUGGING is enabled (below).
# Note: DEBUGGING is driven by either the runtime config block, or a build-time
# constant, so logging is configured lazily on first use in debug_print.
_logging_configured = False

if has_windll:
class SYSTEM_INFO(ctypes.Structure):
Expand Down Expand Up @@ -457,6 +458,14 @@ def crc16(data):
@export
def debug_print(msg):
if DEBUGGING:
global _logging_configured
if not _logging_configured:
logging.basicConfig(level=logging.DEBUG)
if DEBUGGING_LOG_FILE_PATH:
file_handler = logging.FileHandler(DEBUGGING_LOG_FILE_PATH)
file_handler.setLevel(logging.DEBUG)
logging.getLogger().addHandler(file_handler)
_logging_configured = True
logging.debug(msg)

def debug_hexdump(label, data):
Expand Down Expand Up @@ -2298,11 +2307,6 @@ def encrypt(self, pt):
if config.get('debug_log'):
DEBUGGING = True
DEBUGGING_LOG_FILE_PATH = config['debug_log']
logging.basicConfig(level=logging.DEBUG)
if DEBUGGING_LOG_FILE_PATH:
_dbg_fh = logging.FileHandler(DEBUGGING_LOG_FILE_PATH)
_dbg_fh.setLevel(logging.DEBUG)
logging.getLogger().addHandler(_dbg_fh)
transport = config['transports'][0]
# PATCH-SETUP-STAGELESS-TCP-SOCKET #
# For staged/stageless TCP payloads where the socket `s` is already
Expand Down
Loading