Well the end bytes we are looking for “ 0x0D 0x0A “ are right at the end of the string “User-Agent” and to get the first byte of the actual string I added two to the length of the search string to the two normal end bytes for the string “User-Agent”. So when I subtracted that full length from the end position of the actual User-Agent end bytes I ended up with “-2” so that tells me the User-Agent string is missing here. In order to overcome this and to find what was there if it returned “–2”, instead of returning “-2” for a length I would instead return 2 for the length of bytes to get and to be able to have the index where it is, thus only having 2 Characters.
The next one shows a User-Agent string but with the web address tacked onto it, so the end bytes I was looking for was missing where it should have been. I also had to truncate the last few characters “: */*” from those strings returned because it messed up the string builder that I used in the program and would not display anything after the first one.
So what else can we do with this information ? To be honest I’m not totally sure yet.
But, the next question is, once you find one of these how could you find the packet that this belongs to in Wireshark?
The answer, after pouring over the file format spec was to use the timestamp.
Each packet/frame has a timestamp in it.
What is the timestamp? It is a Epoch time stamp in GMT but the normal date time is displayed in the users local time. More on this in a bit.
Lets start from the beginning. First we find a interesting UA string we want to investigate so we use the UA tool to find the offset and jump to it in a hex editor.
For this example we will use the first unique U-A string found.
UA = Index Location: 0x1F48
Microsoft NCSI UA End
It is usually the first one seen when the computer tries to connect to the internet.
So we jump to that location and search “Up” for the 2 bytes “0x54 0x56 that will help us find the timestamp, “BF8C545617920A00”. When the year changes we will have to see what the bytes are.
Update: as December rolled around the bytes to search for changed to 0x60 0x54.
So if we just open the pcap of interest in Wireshark , pull a epoch timestamp and convert it to hex as done below then get the last 2 bytes of the first half (bytes 3,4 from left) of the time stamp that will give us the 2 bytes to search up for in the current pcap.