本文整理匯總了Python中impacket.ntlm.NTOWFv2方法的典型用法代碼示例。如果您正苦於以下問題:Python ntlm.NTOWFv2方法的具體用法?Python ntlm.NTOWFv2怎麽用?Python ntlm.NTOWFv2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類impacket.ntlm
的用法示例。
在下文中一共展示了ntlm.NTOWFv2方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: mod_computeResponseNTLMv2
# 需要導入模塊: from impacket import ntlm [as 別名]
# 或者: from impacket.ntlm import NTOWFv2 [as 別名]
def mod_computeResponseNTLMv2(flags, serverChallenge, clientChallenge, serverName, domain, user, password, lmhash='',
nthash='', use_ntlmv2=USE_NTLMv2, check=False):
responseServerVersion = b'\x01'
hiResponseServerVersion = b'\x01'
responseKeyNT = NTOWFv2(user, password, domain, nthash)
av_pairs = AV_PAIRS(serverName)
av_pairs[NTLMSSP_AV_TARGET_NAME] = 'cifs/'.encode('utf-16le') + av_pairs[NTLMSSP_AV_HOSTNAME][1]
if av_pairs[NTLMSSP_AV_TIME] is not None:
aTime = av_pairs[NTLMSSP_AV_TIME][1]
else:
aTime = struct.pack('<q', (116444736000000000 + calendar.timegm(time.gmtime()) * 10000000))
av_pairs[NTLMSSP_AV_TIME] = aTime
av_pairs[NTLMSSP_AV_FLAGS] = b'\x02' + b'\x00' * 3
serverName = av_pairs.getData()
temp = responseServerVersion + hiResponseServerVersion + b'\x00' * 6 + aTime + clientChallenge + b'\x00' * 4 + \
serverName + b'\x00' * 4
ntProofStr = hmac_md5(responseKeyNT, serverChallenge + temp)
ntChallengeResponse = ntProofStr + temp
lmChallengeResponse = hmac_md5(responseKeyNT, serverChallenge + clientChallenge) + clientChallenge
sessionBaseKey = hmac_md5(responseKeyNT, ntProofStr)
return ntChallengeResponse, lmChallengeResponse, sessionBaseKey