How can I do a string search in a packet (including headers and payload) in C? I tried using strstr(), but because my dest MAC address begins with a 0x00, the strstr() function seemed to not go any further into the packet. Furthermore, there is likely to be more 0x00 bytes within the packet. Do I need to do a byte-by-byte search, or is there a faster way?
Also, can I print the packet data using %s
? I tried the following, but there was no output.
while ((rc = pcap_next_ex(pcap, &pkthdr, &data)) >= 0)
printf("%s\n", data);