blob: 5ece8086f1bf39a703c498402a34389efe92e443 [file] [log] [blame]
% Regression tests for Scapy
# HomePlugAV
############
############
+ Basic tests
* Those test are here mainly to check nothing has been broken
= Building packets packet
~ basic HomePlugAV GetDeviceVersion StartMACRequest StartMACConfirmation ResetDeviceRequest ResetDeviceConfirmation NetworkInformationRequest ReadMACMemoryRequest ReadMACMemoryConfirmation ReadModuleDataRequest ReadModuleDataConfirmation WriteModuleDataRequest WriteModuleData2NVMRequest WriteModuleData2NVMConfirmation NetworkInfoConfirmationV10 NetworkInfoConfirmationV11 NetworkInfoV10 NetworkInfoV11 HostActionRequired LoopbackRequest LoopbackConfirmation SetEncryptionKeyRequest SetEncryptionKeyConfirmation ReadConfBlockRequest ReadConfBlockConfirmation QUAResetFactoryConfirm GetNVMParametersRequest GetNVMParametersConfirmation SnifferRequest SnifferConfirmation SnifferIndicate
HomePlugAV()
HomePlugAV()/GetDeviceVersion()
HomePlugAV()/StartMACRequest()
HomePlugAV()/StartMACConfirmation()
HomePlugAV()/ResetDeviceRequest()
HomePlugAV()/ResetDeviceConfirmation()
HomePlugAV()/NetworkInformationRequest()
HomePlugAV()/ReadMACMemoryRequest()
HomePlugAV()/ReadMACMemoryConfirmation()
HomePlugAV()/ReadModuleDataRequest()
HomePlugAV()/ReadModuleDataConfirmation()
HomePlugAV()/WriteModuleDataRequest()
HomePlugAV()/WriteModuleData2NVMRequest()
HomePlugAV()/WriteModuleData2NVMConfirmation()
HomePlugAV()/NetworkInfoConfirmationV10()
HomePlugAV()/NetworkInfoConfirmationV11()
HomePlugAV()/NetworkInfoConfirmationV10()/NetworkInfoV10()
HomePlugAV()/NetworkInfoConfirmationV11()/NetworkInfoV11()
HomePlugAV()/HostActionRequired()
HomePlugAV()/LoopbackRequest()
HomePlugAV()/LoopbackConfirmation()
HomePlugAV()/SetEncryptionKeyRequest()
HomePlugAV()/SetEncryptionKeyConfirmation()
HomePlugAV()/ReadConfBlockRequest()
HomePlugAV()/ReadConfBlockConfirmation()
HomePlugAV()/QUAResetFactoryConfirm()
HomePlugAV()/GetNVMParametersRequest()
HomePlugAV()/GetNVMParametersConfirmation()
HomePlugAV()/SnifferRequest()
HomePlugAV()/SnifferConfirmation()
HomePlugAV()/SnifferIndicate()
= Some important manipulations
~ field
pkt = HomePlugAV()/SetEncryptionKeyRequest()
pkt.NMK = "A" * 16
pkt.DAK = "B" * 16
raw(pkt)
_ == b"\x00P\xa0\x00\xb0R\x00AAAAAAAAAAAAAAAA\x00\xff\xff\xff\xff\xff\xffBBBBBBBBBBBBBBBB"
pkt = HomePlugAV()/ReadMACMemoryRequest()
pkt.Address = 0x31337
pkt.Length = 0x666
raw(pkt)
_ == b"\x00\x08\xa0\x00\xb0R7\x13\x03\x00f\x06\x00\x00"
pkt = HomePlugAV()/ReadModuleDataRequest()
pkt.Length = 0x666
pkt.Offset = 0x1337
raw(pkt)
assert(_ == b"\x00$\xa0\x00\xb0R\x02\x00f\x067\x13\x00\x00")
pkt = HomePlugAV()/SnifferRequest()
pkt.SnifferControl = 0x1
raw(pkt)
_ == b"\x004\xa0\x00\xb0R\x01"
= Some important fields parsing
~ field
_xstr = b"\x00%\xa0\x00\xb0R\x00\x00\x00\x00\x02\x00\x00\x04\x00\x00\x00\x00`\x8d\x05\xf9\x04\x01\x00\x00\x88)\x00\x00\x87`[\x14\x00$\xd4okm\x1f\xedHu\x85\x16>\x86\x1aKM\xd2\xe91\xfc6\x00\x00603506A112119017\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00z]\xa9\xe2]\xedR\x8b\x85\\\xdf\xe8~\xe9\xb2\x14637000A112139290\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00FREEPLUG_LC_6400_4-1_1.0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbb\xcb\x0e\x10 \xad\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00`\xe5\x16\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x03\x02\x80\x84\x1e\x00\x80\x84\x1e\x00\xe0\x93\x04\x00\xe0\x93\x04\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
pkt = HomePlugAV(_xstr)
ReadModuleDataConfirmation in pkt
_ == True
(pkt[ReadModuleDataConfirmation].ModuleID == 2, pkt[ReadModuleDataConfirmation].checksum == 4177890656, pkt[ReadModuleDataConfirmation].DataLen == 1024, pkt[ReadModuleDataConfirmation].Offset == 0)
_ == (True, True, True, True)
ModulePIB(pkt.ModuleData, pkt.Offset, pkt.DataLen)
(_.NMK == b"z]\xa9\xe2]\xedR\x8b\x85\\\xdf\xe8~\xe9\xb2\x14", _.DAK == b"\x1f\xedHu\x85\x16>\x86\x1aKM\xd2\xe91\xfc6")
_ == (True, True)
#= Discovery packet tests in local
#~ netaccess HomePlugAV NetworkInfoConfirmationV10 NetworkInfoConfirmationV11
#pkt = Ether()/HomePlugAV()
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#a
#pkt.version = a.version
#pkt /= NetworkInformationRequest()
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#NetworkInfoConfirmationV10 in a or NetworkInfoConfirmationV11 in a
#_ == True
#= Reading local 0x400st octets of Software Image in Module Data blocks
#~ netaccess HomePlugAV ReadModuleDataRequest
#pkt = Ether()/HomePlugAV()/ReadModuleDataRequest(ModuleID=0x1)
#old_debug_dissector = conf.debug_dissector
#conf.debug_dissector = False
#a = srp1(pkt, iface="eth0")
#conf.debug_dissector = old_debug_dissector
#a
#len(a.ModuleData) == pkt.Length
#_ == True
= Testing length and checksum on a generated Write Module Data Request
string = b"goodchoucroute\x00\x00"
pkt = WriteModuleDataRequest(ModuleData=string)
pkt = WriteModuleDataRequest(pkt.build())
pkt.show()
(pkt.checksum == chksum32(pkt.ModuleData), pkt.DataLen == len(pkt.ModuleData))
_ == (True, True)