scapy hexdump()

hex, hexdump, scapy

Solution

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

Problem

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 a `pkt.summary()` with a following `hexdump(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 via `str(pkt[0])[0]` ), but with nothing else than hexvalues, just like displayed in `hexdump(pkt)`. maybe you guys could help me out with this one :)

Original source