scapy hexdump() [英] scapy hexdump()
问题描述
我不知道是哪一个 hexdump()
scapy使用,因为我想修改它,但我根本找不到任何东西。
我发现的是:
def hexdump(self,lfilter = None):
$如果lfilter不是None并且不是lfilter(p(self.res)),那么b $ b代表范围内的我(len(self.res)):
p = self._elt2pkt(self.res [i])
):
continue
print%s%s%s%(conf.color_theme.id(i,%04i),
p.sprintf(%。time%) ),
self._elt2sum(self.res [i]))
hexdump(p)
但这只是 pkt.hexdump()
的替代方案,它会执行 pkt.summary()
与以下 hexdump(pkt)
任何人都可以告诉我在哪里可以找到 hexdump(pkt)
sourcecode? p>
我想要的是十六进制数据包,几乎就像 str (pkt [0])
(我可以通过 str pkt [0])[0]
),但除了hexvalues之外,就像在 hexdump(pkt)
中显示的一样。
也许你们可以帮我解决这个问题:)
发现它,所以,回答我自己的问题,它位于utils.pydef hexdump(x):
pre>
x = str(x)
l = len(x)
i = 0
while I< l:
在范围(16)中打印%04x%i,
:
if i + j < l:
print%02X%ord(x [i + j]),
else:
print,
if j%16 == 7:
print,
print,
print sane_color(x [i:i + 16])
i + = 16
i wonder which
hexdump()
scapy uses, since i would like to modify it, but i simply cant find anything.what i DO find is:
def hexdump(self, lfilter=None): for i in range(len(self.res)): p = self._elt2pkt(self.res[i]) if lfilter is not None and not lfilter(p): continue print "%s %s %s" % (conf.color_theme.id(i,"%04i"), p.sprintf("%.time%"), self._elt2sum(self.res[i])) hexdump(p)
but that simply is an alternative for
pkt.hexdump()
, which does apkt.summary()
with a followinghexdump(pkt)
could anyone tell me where to find the
hexdump(pkt)
sourcecode?what i want to have is the hex'ed packet, almost like
str(pkt[0])
(where i can check byte by byte viastr(pkt[0])[0]
), but with nothing else than hexvalues, just like displayed inhexdump(pkt)
.maybe you guys could help me out with this one :)
解决方案found it, so, to answer my own question, it is located in utils.py
def hexdump(x): x=str(x) l = len(x) i = 0 while i < l: print "%04x " % i, for j in range(16): if i+j < l: print "%02X" % ord(x[i+j]), else: print " ", if j%16 == 7: print "", print " ", print sane_color(x[i:i+16]) i += 16
这篇关于scapy hexdump()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!