Esempio n. 1
0
    def setup_crypto(self):
        if not self.RandomSessionKey:
            self.RandomSessionKey = os.urandom(16)

        self.SessionBaseKey = self.ntlm_credentials.SessionBaseKey

        rc4 = RC4(self.KeyExchangeKey)
        self.EncryptedRandomSessionKey = rc4.encrypt(self.RandomSessionKey)

        self.calc_sealkey('Client')
        self.calc_sealkey('Server')
        self.calc_signkey('Client')
        self.calc_signkey('Server')
Esempio n. 2
0
    def setup_crypto(self):
        if not self.RandomSessionKey:
            self.RandomSessionKey = os.urandom(16)

        if self.mode.upper() != 'MANUAL':
            #this check is here to provide the option to load the messages + the sessionbasekey manually
            #then you will be able to use the sign and seal functions provided by this class
            self.SessionBaseKey = self.ntlm_credentials.SessionBaseKey

            rc4 = RC4(self.KeyExchangeKey)
            self.EncryptedRandomSessionKey = rc4.encrypt(self.RandomSessionKey)

        self.calc_sealkey('Client')
        self.calc_sealkey('Server')
        self.calc_signkey('Client')
        self.calc_signkey('Server')
Esempio n. 3
0
def DecryptAttributeValue(sessionKey, attribute):

    encryptedPayload = ENCRYPTED_PAYLOAD(attribute)

    md5 = hashlib.new('md5')
    md5.update(sessionKey)
    md5.update(encryptedPayload['Salt'])
    finalMD5 = md5.digest()

    cipher = RC4(finalMD5)
    plainText = cipher.decrypt(attribute[16:])

    #chkSum = (binascii.crc32(plainText[4:])) & 0xffffffff
    #if unpack('<L',plainText[:4])[0] != chkSum:
    #	print "RECEIVED 0x%x" % unpack('<L',plainText[:4])[0]
    #	print "CALCULATED 0x%x" % chkSum

    return plainText[4:]