def translate_to_basic(self, environment, connection, error_code): "" connection.logger.log('*** Translating NTLM to Basic...\n') user, password = self.get_credentials_from_basic(connection, error_code) if user: connection.logger.log("*** Found Basic credentials in client's header.\n") environment['USER'] = user #environment['PASSWORD'] = password connection.logger.log("*** Basic User/Password: %s/%s.\n" % (user, password)) connection.logger.log("*** Calculating hashed passwords (LM and NT)...") environment['LM_HASHED_PW'] = ntlm_procs.create_LM_hashed_password(password) environment['NT_HASHED_PW'] = ntlm_procs.create_NT_hashed_password(password) connection.logger.log("Done.\n") return 1 else: connection.logger.log("*** There are no basic credentials in client's header.\n") connection.logger.log("*** Replacing NTLM value with Basic in rserver's header...") self.replace_ntlm_with_basic(connection, error_code) connection.logger.log("Done.\n") connection.logger.log("*** New server's header:\n=====\n" + connection.rserver_head_obj.__repr__()) return 0
def __init__(self, config): self.config = config self.MyHost = '' self.ListenPort = self.config['GENERAL']['LISTEN_PORT'] self.sigLock = thread.allocate_lock() # For locking in the sigHandler self.monLock = thread.allocate_lock( ) # For keeping the monitor thread sane self.watchUpstream = 0 self.monitor = None if not self.config['NTLM_AUTH']['NTLM_TO_BASIC']: if not self.config['NTLM_AUTH']['PASSWORD']: tries = 3 print '------------------------' while tries and (not self.config['NTLM_AUTH']['PASSWORD']): tries = tries - 1 self.config['NTLM_AUTH']['PASSWORD'] = getpass.getpass( 'Your NT password to be used:') if not self.config['NTLM_AUTH']['PASSWORD']: print 'Sorry. PASSWORD is required, bye.' sys.exit(1) else: # TODO: migrate this properly so placeholders aren't required self.config['NTLM_AUTH']['USER'] = '******' self.config['NTLM_AUTH']['PASSWORD'] = '******' # hashed passwords calculation self.config['NTLM_AUTH'][ 'LM_HASHED_PW'] = ntlm_procs.create_LM_hashed_password( self.config['NTLM_AUTH']['PASSWORD']) self.config['NTLM_AUTH'][ 'NT_HASHED_PW'] = ntlm_procs.create_NT_hashed_password( self.config['NTLM_AUTH']['PASSWORD'])
def __init__(self, config): self.config = config self.MyHost = '' self.ListenPort = self.config['GENERAL']['LISTEN_PORT'] self.sigLock = thread.allocate_lock() # For locking in the sigHandler self.monLock = thread.allocate_lock() # For keeping the monitor thread sane self.watchUpstream = 0 if not self.config['NTLM_AUTH']['NTLM_TO_BASIC']: if not self.config['NTLM_AUTH']['PASSWORD']: tries = 3 print '------------------------' while tries and (not self.config['NTLM_AUTH']['PASSWORD']): tries = tries - 1 self.config['NTLM_AUTH']['PASSWORD'] = getpass.getpass('Your NT password to be used:') if not self.config['NTLM_AUTH']['PASSWORD']: print 'Sorry. PASSWORD is required, bye.' sys.exit(1) else: # TODO: migrate this properly so placeholders aren't required self.config['NTLM_AUTH']['USER'] = '******' self.config['NTLM_AUTH']['PASSWORD'] = '******' # hashed passwords calculation if self.config['DEBUG']['DEBUG']: print ("user:%s") % self.config['NTLM_AUTH']['USER'] print ("passwd:%s") % self.config['NTLM_AUTH']['PASSWORD'] self.config['NTLM_AUTH']['LM_HASHED_PW'] = ntlm_procs.create_LM_hashed_password(self.config['NTLM_AUTH']['PASSWORD']) self.config['NTLM_AUTH']['NT_HASHED_PW'] = ntlm_procs.create_NT_hashed_password(self.config['NTLM_AUTH']['PASSWORD'])
def __init__(self, config): self.config = config self.MyHost = "" self.ListenPort = self.config["GENERAL"]["LISTEN_PORT"] self.sigLock = thread.allocate_lock() # For locking in the sigHandler self.monLock = thread.allocate_lock() # For keeping the monitor thread sane self.watchUpstream = 0 if not self.config["NTLM_AUTH"]["NTLM_TO_BASIC"]: if not self.config["NTLM_AUTH"]["PASSWORD"]: tries = 3 print("------------------------") while tries and (not self.config["NTLM_AUTH"]["PASSWORD"]): tries = tries - 1 self.config["NTLM_AUTH"]["PASSWORD"] = getpass.getpass( "Your NT password to be used:" ) if not self.config["NTLM_AUTH"]["PASSWORD"]: print("Sorry. PASSWORD is required, bye.") sys.exit(1) else: # TODO: migrate this properly so placeholders aren't required self.config["NTLM_AUTH"]["USER"] = "******" self.config["NTLM_AUTH"]["PASSWORD"] = "******" # hashed passwords calculation self.config["NTLM_AUTH"]["LM_HASHED_PW"] = ntlm_procs.create_LM_hashed_password( self.config["NTLM_AUTH"]["PASSWORD"] ) self.config["NTLM_AUTH"]["NT_HASHED_PW"] = ntlm_procs.create_NT_hashed_password( self.config["NTLM_AUTH"]["PASSWORD"] )
def __init__(self, config): self.config = config self.MyHost = "" self.ListenPort = self.config["GENERAL"]["LISTEN_PORT"] self.sigLock = thread.allocate_lock() # For locking in the sigHandler self.monLock = thread.allocate_lock() # For keeping the monitor thread sane self.watchUpstream = 0 # if found, convert hashed passwords from hex to string if self.config["NTLM_AUTH"]["LM_HASHED_PW"]: self.config["NTLM_AUTH"]["LM_HASHED_PW"] = utils.hex2str(self.config["NTLM_AUTH"]["LM_HASHED_PW"]) if self.config["NTLM_AUTH"]["NT_HASHED_PW"]: self.config["NTLM_AUTH"]["NT_HASHED_PW"] = utils.hex2str(self.config["NTLM_AUTH"]["NT_HASHED_PW"]) if not self.config["NTLM_AUTH"]["NTLM_TO_BASIC"]: if (self.config["NTLM_AUTH"]["LM_PART"] and not self.config["NTLM_AUTH"]["LM_HASHED_PW"]) or ( self.config["NTLM_AUTH"]["NT_PART"] and not self.config["NTLM_AUTH"]["NT_HASHED_PW"] ): if not self.config["NTLM_AUTH"]["PASSWORD"]: tries = 3 print "------------------------" while tries and (not self.config["NTLM_AUTH"]["PASSWORD"]): tries = tries - 1 self.config["NTLM_AUTH"]["PASSWORD"] = getpass.getpass("Your NT password to be used:") if not self.config["NTLM_AUTH"]["PASSWORD"]: print "Sorry. PASSWORD is required, bye." sys.exit(1) else: # TODO: migrate this properly so placeholders aren't required self.config["NTLM_AUTH"]["USER"] = "******" self.config["NTLM_AUTH"]["PASSWORD"] = "******" # compute hashed passwords if necessary if self.config["NTLM_AUTH"]["LM_PART"] and not self.config["NTLM_AUTH"]["LM_HASHED_PW"]: self.config["NTLM_AUTH"]["LM_HASHED_PW"] = ntlm_procs.create_LM_hashed_password( self.config["NTLM_AUTH"]["PASSWORD"] ) if self.config["NTLM_AUTH"]["NT_PART"] and not self.config["NTLM_AUTH"]["NT_HASHED_PW"]: self.config["NTLM_AUTH"]["NT_HASHED_PW"] = ntlm_procs.create_NT_hashed_password( self.config["NTLM_AUTH"]["PASSWORD"] ) # if requested. compute and print out password hashes and exit if self.config["NTLM_AUTH"]["PRINT_PW_HASH_AND_EXIT"]: if self.config["NTLM_AUTH"]["LM_PART"]: print "LM_HASHED_PW:%s" % utils.str2hex(self.config["NTLM_AUTH"]["LM_HASHED_PW"]) if self.config["NTLM_AUTH"]["NT_PART"]: print "NT_HASHED_PW:%s" % utils.str2hex(self.config["NTLM_AUTH"]["NT_HASHED_PW"]) sys.exit(0)
def __init__(self, config): self.config = config self.MyHost = '' self.ListenPort = self.config['GENERAL']['LISTEN_PORT'] self.sigLock = thread.allocate_lock() # For locking in the sigHandler self.monLock = thread.allocate_lock() # For keeping the monitor thread sane self.watchUpstream = 0 self.monitor = None password_prompt = getpass.getpass # If the hashes exist then use them. if self.config['NTLM_AUTH']['LM_HASHED_PW'] and self.config['NTLM_AUTH']['NT_HASHED_PW']: self.config['NTLM_AUTH']['LM_HASHED_PW'] = base64.decodestring(self.config['NTLM_AUTH']['LM_HASHED_PW']) self.config['NTLM_AUTH']['NT_HASHED_PW'] = base64.decodestring(self.config['NTLM_AUTH']['NT_HASHED_PW']) else: if self.config['NTLM_AUTH']['COMPLEX_PASSWORD_INPUT']: try: import win32console password_prompt = win32console.getpass except ImportError: sys.stderr.write('Unable to load win32console support; complex passwords can not be input.\n') except AttributeError: sys.stderr.write('win32console lacking getpass support; complex passwords can not be input.\n') if not self.config['NTLM_AUTH']['NTLM_TO_BASIC']: if not self.config['NTLM_AUTH']['PASSWORD']: tries = 3 print '------------------------' while tries and (not self.config['NTLM_AUTH']['PASSWORD']): tries = tries - 1 self.config['NTLM_AUTH']['PASSWORD'] = password_prompt('Your NT password to be used:') if not self.config['NTLM_AUTH']['PASSWORD']: print 'Sorry. PASSWORD is required, bye.' sys.exit(1) else: # TODO: migrate this properly so placeholders aren't required self.config['NTLM_AUTH']['USER'] = '******' self.config['NTLM_AUTH']['PASSWORD'] = '******' # hashed passwords calculation self.config['NTLM_AUTH']['LM_HASHED_PW'] = ntlm_procs.create_LM_hashed_password(self.config['NTLM_AUTH']['PASSWORD']) self.config['NTLM_AUTH']['NT_HASHED_PW'] = ntlm_procs.create_NT_hashed_password(self.config['NTLM_AUTH']['PASSWORD'])