Пример #1
0
def test_reconstrut(data = None):
	print('=== reconstruct===')
	if not data:
		auth_test_data = bytes.fromhex('4e544c4d5353500003000000180018007c000000180118019400000008000800580000000c000c0060000000100010006c00000010001000ac010000158288e20a00d73a0000000f0d98eb57e9c52820709c99b98ca321a15400450053005400760069006300740069006d00570049004e0031003000580036003400000000000000000000000000000000000000000000000000fade3940b9381c53c91ddcdd0d44000b0101000000000000aec600bfc5fdd4011bfa20699d7628730000000002000800540045005300540001001200570049004e003200300031003900410044000400120074006500730074002e0063006f007200700003002600570049004e003200300031003900410044002e0074006500730074002e0063006f007200700007000800aec600bfc5fdd40106000400020000000800300030000000000000000000000000200000527d27f234de743760966384d36f61ae2aa4fc2a380699f8caa600011b486d890a0010000000000000000000000000000000000009001e0063006900660073002f00310030002e00310030002e00310030002e003200000000000000000000000000fd67edfb41c09465a91fd733deb0b55b')
	else:
		auth_test_data = data
	challenge = NTLMAuthenticate.from_bytes(auth_test_data)
	print(repr(challenge))
	auth_test_data_verify = challenge.to_bytes()
	print('====== reconstructed ====')
	print(hexdump(auth_test_data_verify))
	print('====== original ====')
	print(hexdump(auth_test_data))
	assert auth_test_data == auth_test_data_verify
Пример #2
0
def test_reconstrut(data = None):
	print('=== reconstruct===')
	if not data:
		challenge_test_data = bytes.fromhex('4e544c4d53535000020000000800080038000000158289e2a7314a557bdb11bf000000000000000072007200400000000a0063450000000f540045005300540002000800540045005300540001001200570049004e003200300031003900410044000400120074006500730074002e0063006f007200700003002600570049004e003200300031003900410044002e0074006500730074002e0063006f007200700007000800aec600bfc5fdd40100000000')
	else:
		challenge_test_data = data
	challenge = NTLMChallenge.from_bytes(challenge_test_data)
	print(repr(challenge))
	challenge_test_data_verify = challenge.to_bytes()
	print('====== reconstructed ====')
	print(hexdump(challenge_test_data_verify))
	print('====== original ====')
	print(hexdump(challenge_test_data))
	assert challenge_test_data == challenge_test_data_verify
Пример #3
0
def test():
    test_data = bytes.fromhex(
        '0101000000000000aec600bfc5fdd4011bfa20699d7628730000000002000800540045005300540001001200570049004e003200300031003900410044000400120074006500730074002e0063006f007200700003002600570049004e003200300031003900410044002e0074006500730074002e0063006f007200700007000800aec600bfc5fdd40106000400020000000800300030000000000000000000000000200000527d27f234de743760966384d36f61ae2aa4fc2a380699f8caa600011b486d890a0010000000000000000000000000000000000009001e0063006900660073002f00310030002e00310030002e00310030002e0032000000000000000000'
    )

    cc = NTLMv2ClientChallenge.from_bytes(test_data)
    print(repr(cc))

    cc2 = NTLMv2ClientChallenge.from_bytes(cc.to_bytes())
    print(repr(cc2))
    print('=== Original ===')
    print(hexdump(test_data))
    print('=== CC ===')
    print(hexdump(cc.to_bytes()))

    ### assertions here fail because of the timestamp re-conversion loosing info (float-int conversion)
    #assert cc.to_bytes() == test_data
    #assert cc2.to_bytes() == test_data

    details = AVPairs({
        AVPAIRType.MsvAvNbDomainName: 'TEST',
        AVPAIRType.MsvAvNbComputerName: 'WIN2019AD',
        AVPAIRType.MsvAvDnsDomainName: 'test.corp',
        AVPAIRType.MsvAvDnsComputerName: 'WIN2019AD.test.corp',
        AVPAIRType.MsvAvTimestamp: b'\xae\xc6\x00\xbf\xc5\xfd\xd4\x01',
        AVPAIRType.MsvAvFlags: b'\x02\x00\x00\x00',
        AVPAIRType.MsvAvSingleHost:
        b"0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00R}'\xf24\xdet7`\x96c\x84\xd3oa\xae*\xa4\xfc*8\x06\x99\xf8\xca\xa6\x00\x01\x1bHm\x89",
        AVPAIRType.MsvChannelBindings:
        b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
        AVPAIRType.MsvAvTargetName: 'cifs/10.10.10.2'
    })
    timestamp = datetime.datetime(2019, 1, 1)
    client_challenge = os.urandom(8)

    cc3 = NTLMv2ClientChallenge.construct(timestamp, client_challenge, details)
    print(repr(cc3))
    cc4 = NTLMv2ClientChallenge.from_bytes(cc3.to_bytes())