Note: If this program is run against a pcap file that is open in a hex editor in read/write mode then it will fail to open the file for reading .
This view highlights several of the errors I encountered while making this tool. Probably a good thing I chose “this” file as my test subject, others didn’t return some of the same problems or only returned a few unique User-Agents. This one has known malware in it’s traffic.
The way my program works is it looks for the string “User-Agent” in hex bytes, then it looks for the 2 bytes that the actual string normally ends on “ 0x0D 0x0A “ then it does the math and takes the bytes in between and outputs the U-A string. As you can see in this screen shot some of it was returned in hex, that was because it could not find the end byte and when returned as a string it would not display correctly. I also had to add a limit of 300 bytes to make sure I got the longest possible string returned without returning over 1,000 bytes in some.
If we convert the hex for the top one showing it as utf-8, here is what we see.