Beispiel #1
0
 def test_initKEXHash(self):
     netPackets = pcapReader.openPCAPFile(pcapPath)
     ikePackets = pcapReader.getISAKMPPackets(netPackets)
     initSAPacket = ikeParser.getIniatorSAPacket(ikePackets)
     initKEX = ikeParser.getPayloadFromISAKMP(initSAPacket,ikeParser.ISAKMP_KEX_NAME)
     initKEXHash  = sha256(initKEX).hexdigest()
     self.assertEqual(initKEXHash, TestStringMethods.initKEXHash)
Beispiel #2
0
 def test_respKEXHash(self):
     netPackets = pcapReader.openPCAPFile(pcapPath)
     ikePackets = pcapReader.getISAKMPPackets(netPackets)
     respSAPacket = ikeParser.getResponderSAPacket(ikePackets)
     respKEX = ikeParser.getPayloadFromISAKMP(respSAPacket,ikeParser.ISAKMP_KEX_NAME)
     respKEXHash  = sha256(respKEX).hexdigest()
     self.assertEqual(respKEXHash, TestStringMethods.respKEXHash)
Beispiel #3
0
def computeHashRFromValues(values):
    # value-tuple: 0 = k, 1 = gY, 2 = gX, 3 = ckyR, 4 = ckyI, 5 = SAI, 6 = IDR):
    valueSum = values[1] + values[2] + values[3] + values[4]+ values[5] + values[6]
    return hmac.new(values[0], valueSum, digestmod = hashlib.sha1).digest()


if __name__ == '__main__':

    # 1. open pcap
    packets = pcapReader.getISAKMPPackets(pcapReader.openPCAPFile(pcapPath))

    # 2. get required values
    initSAPacket = packets[0]
    respSAPacket = packets[1]
    nI = ikeParser.getPayloadFromISAKMP(initSAPacket, "ISAKMP_payload_Nonce")
    nR = ikeParser.getPayloadFromISAKMP(respSAPacket, "ISAKMP_payload_Nonce")
    gY = ikeParser.getPayloadFromISAKMP(respSAPacket, "ISAKMP_payload_KE")
    gX = ikeParser.getPayloadFromISAKMP(initSAPacket, "ISAKMP_payload_KE")
    ckyR = ikeParser.getCookieFromISAKMP(respSAPacket, True)
    ckyI = ikeParser.getCookieFromISAKMP(respSAPacket, False)
    SAI = ikeParser.getSAPayloadFromInitPacket(initSAPacket)
    IDR = ikeParser.getResponderIDFromRespPacket(respSAPacket)
    knownCiphertext = ikeParser.getPayloadFromISAKMP(respSAPacket, "ISAKMP_payload_Hash")

    # 3. read dict line by line
    with open(dictPath, "r") as f:
        while True:
            curLine = f.readline()
            if(curLine == ''):
                break