Add custom logger file
parent
b16dca4054
commit
65c07f5311
|
@ -51,6 +51,7 @@ def gen_cli_args():
|
|||
std_parser.add_argument("-p", metavar="PASSWORD", dest='password', nargs='+', default=[], help="password(s) or file(s) containing passwords")
|
||||
std_parser.add_argument("-k", "--kerberos", action='store_true', help="Use Kerberos authentication")
|
||||
std_parser.add_argument("--use-kcache", action='store_true', help="Use Kerberos authentication from ccache file (KRB5CCNAME)")
|
||||
std_parser.add_argument("--log", metavar="LOG", nargs='+', help="Export result into a file a log file located into ~/.cme")
|
||||
std_parser.add_argument("--aesKey", metavar="AESKEY", nargs='+', help="AES key to use for Kerberos Authentication (128 or 256 bits)")
|
||||
std_parser.add_argument("--kdcHost", metavar="KDCHOST", help="FQDN of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter")
|
||||
|
||||
|
|
|
@ -50,10 +50,14 @@ class connection(object):
|
|||
self.kerberos = True if self.args.kerberos or self.args.use_kcache else False
|
||||
self.aesKey = None if not self.args.aesKey else self.args.aesKey
|
||||
self.kdcHost = None if not self.args.kdcHost else self.args.kdcHost
|
||||
self.log = None if not self.args.log else self.args.log
|
||||
self.use_kcache = None if not self.args.use_kcache else self.args.use_kcache
|
||||
self.failed_logins = 0
|
||||
self.local_ip = None
|
||||
|
||||
if self.log:
|
||||
CMEAdapter().setup_logfile(self.log[0])
|
||||
|
||||
try:
|
||||
self.host = gethost_addrinfo(self.hostname)
|
||||
if self.args.kerberos:
|
||||
|
|
|
@ -110,9 +110,9 @@ class CMEAdapter(logging.LoggerAdapter):
|
|||
CMEAdapter.message = ''
|
||||
return out
|
||||
|
||||
def setup_logfile(self):
|
||||
def setup_logfile(self, log_file=None):
|
||||
formatter = logging.Formatter("%(message)s")
|
||||
self.outputfile = init_log_file()
|
||||
self.outputfile = init_log_file() if log_file == None else log_file
|
||||
if not os.path.isfile(self.outputfile):
|
||||
open(self.outputfile, 'x')
|
||||
fileHandler = logging.FileHandler(filename=self.outputfile, mode="a")
|
||||
|
|
Loading…
Reference in New Issue