我已经定义了以下 -
class PadChecksum(Packet):
name = "PadChecksum"
fields_desc = [ StrField("data", None) ]
conf.raw_layer = PadChecksum
如何显示如下?
###[ PadChecksum ]###
data = '\x00\x00\x00\xa8L\xa8\xe5'
as
###[ PadChecksum ]###
data = '00 00 00 a8 4c a8 e5'
如何更准确地显示如下?
###[ PadChecksum ]###
pad = '00 00 00'
checksum = 'a8 4c a8 e5'
答案 0 :(得分:2)
得到它!!
class XStrField(StrField):
def i2repr(self, pkt, x):
return ' '.join(b.encode('hex') for b in x)
class PadChecksum(Packet):
name = "PadChecksum"
fields_desc = [ XStrField("data", None) ]
显示 -
###[ PadChecksum ]###
data = 00 00 00 eb 62 aa 9d