daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def hexdump(x, dump=False):
  2.     """ Build a tcpdump like hexadecimal view
  3.  
  4.     :param x: a Packet
  5.     :param dump: define if the result must be printed or returned in a variable
  6.     :returns: a String only when dump=True
  7.     """
  8.     s = ""
  9.     x = raw(x)
  10.     l = len(x)
  11.     i = 0
  12.     while i < l:
  13.         s += "%04x  " % i
  14.         for j in range(16):
  15.             if i+j < l:
  16.                 s += "%02X" % orb(x[i+j])
  17.             else:
  18.                 s += "  "
  19.             if j%16 == 7:
  20.                 s += ""
  21.         s += " "
  22.         s += sane_color(x[i:i+16])
  23.         i += 16
  24.         s += "\n"
  25.     # remove trailing \n
  26.     if s.endswith("\n"):
  27.         s = s[:-1]
  28.     if dump:
  29.         return s
  30.     else:
  31.         print(s)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top