/usr/lib/python2.7/dist-packages/impacket/examples/logger.py is in python-impacket 0.9.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #!/usr/bin/python
# Copyright (c) 2003-2016 CORE Security Technologies
#
# 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)
def init():
# We add a StreamHandler and formatter to the root logger
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(ImpacketFormatter())
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(logging.INFO)
|