class Libnet attr_reader :injection_type # :call-seq: # Libnet.hexdump(bytes) # -> string # # Returns a string containing a hexdump of the given byte string. # # Example: # Libnet.hexump("foobar") # # produces the following string: # # 0x00000000: 666f6f62 6172 def self.hexdump(bytes) offset = 0 i = 0 dump = "0x00000000: " bytes.each_byte do |b| if i != 0 if i % 16 == 0 offset += 16 dump += sprintf("\n0x%08x: ", offset) elsif i % 4 == 0 dump += " " end end dump += sprintf("%02x", b) i += 1 end dump += "\n" end end