Packet pck = Ethernet() / IP() / UDP() / payload;
pck.Print();
return 0;
}
$ g++ udp.cpp -o udp -lcrafter
$ ./udp $(echo -n "hellohex" | od -A n -t x1 |sed 's/ //g')
< Ethernet (14 bytes) :: DestinationMAC = ff:ff:ff:ff:ff:ff , SourceMAC = 00:00:00:00:00:00 , Type = 0x800 , >
< IP (20 bytes) :: Version = 4 , HeaderLength = 5 , DiffServicesCP = 0 , ExpCongestionNot = 0 , TotalLength = 0 , Identification = 0x0 , Flags = 2 , FragmentOffset = 0 , TTL = 64 , Protocol = 0x6 , CheckSum = 0x0 , SourceIP = 0.0.0.0 , DestinationIP = 0.0.0.0 , >
< UDP (8 bytes) :: SrcPort = 0 , DstPort = 53 , Length = 0 , CheckSum = 0x0 , >
< RawLayer (8 bytes) :: Payload = hellohex>
$ ./udp 588560cf3c
< Ethernet (14 bytes) :: DestinationMAC = ff:ff:ff:ff:ff:ff , SourceMAC = 00:00:00:00:00:00 , Type = 0x800 , >
< IP (20 bytes) :: Version = 4 , HeaderLength = 5 , DiffServicesCP = 0 , ExpCongestionNot = 0 , TotalLength = 0 , Identification = 0x0 , Flags = 2 , FragmentOffset = 0 , TTL = 64 , Protocol = 0x6 , CheckSum = 0x0 , SourceIP = 0.0.0.0 , DestinationIP = 0.0.0.0 , >
< UDP (8 bytes) :: SrcPort = 0 , DstPort = 53 , Length = 0 , CheckSum = 0x0 , >
< RawLayer (5 bytes) :: Payload = \x58\x85\x60\xcf\x3c>
In the last execution (with 588560cf3c) libcrafter show the characters in hex because it can't be converted to ASCII.