MCPcopy Index your code
hub / github.com/secdev/scapy / hexdump

Function hexdump

scapy/utils.py:307–334  ·  view source on GitHub ↗

Build a tcpdump like hexadecimal view :param p: a Packet :param dump: define if the result must be printed or returned in a variable :return: a String only when dump=True

(p, dump=False)

Source from the content-addressed store, hash-verified

305
306@conf.commands.register
307def hexdump(p, dump=False):
308 # type: (Union[Packet, AnyStr], bool) -> Optional[str]
309 """Build a tcpdump like hexadecimal view
310
311 :param p: a Packet
312 :param dump: define if the result must be printed or returned in a variable
313 :return: a String only when dump=True
314 """
315 s = ""
316 x = bytes_encode(p)
317 x_len = len(x)
318 i = 0
319 while i < x_len:
320 s += "%04x " % i
321 for j in range(16):
322 if i + j < x_len:
323 s += "%02X " % orb(x[i + j])
324 else:
325 s += " "
326 s += " %s\n" % sane(x[i:i + 16], color=True)
327 i += 16
328 # remove trailing \n
329 s = s[:-1] if s.endswith("\n") else s
330 if dump:
331 return s
332 else:
333 print(s)
334 return None
335
336
337@conf.commands.register

Callers 8

rawhexdumpMethod · 0.90
hexrawMethod · 0.90
hexdumpMethod · 0.90
paddingMethod · 0.90
nzpaddingMethod · 0.90
extract_ivMethod · 0.90
check_arp_replyMethod · 0.90
arpleakFunction · 0.90

Calls 3

bytes_encodeFunction · 0.90
orbFunction · 0.90
saneFunction · 0.85

Tested by

no test coverage detected