There is nothing in the USB spec that forces a host to identify itself, and there is no standard way a device can request such information. Without a cooperating driver in the operating system, there is no way for a ordinary device to know details about the host, like what operating system it is running, what processor it is using, etc.
I have, however, noticed that different operating systems tend to have their own quirks about what they request in what order during enumeration. You might be able to do some testing and find a way to distinguish a few of the major operating systems. However, that would not be guaranteed, could easily change at minor revisions, and can certainly be deliberately spoofed.
If you want a device to know it is connected to a trusted host, you will have to previously load software on that host. The device could, for example, send out a randomly generated string of bits when asked the right way by your software on the host. The host must then respond with a reply that is hashed from the original bits in a particular way envolving a password. Only a host with the right algorithm and password could reply correctly.
Of course that is just simple scheme. It can get a lot more complicated depending on what level of attacker you want to protect youself from. For example, the simple scheme I described above would be no good against a man in the middle attack.
Hardware USB analyzers tend to be fairly expensive but for a device already working a software analyzer should suffice. The following would be some good terms to search for:
- USB protocol analyzer
- USB bus analyzer
- USB bus sniffer
There is a question at StackOverflow with some answers that offer suggestions on some packages that are available if you're running Windows:
What (software) usb sniffers are available for windows?
Best Answer
Yes.
I have been very pleased with the software from HHD. I used the serial port monitor to do some heavy reverse engineering a few years back and the HHD software was well tailored for the work.
I dabbled with their USB sniffer version but never bought the full version. Back in the day there was a free trial version that was somewhat useful. They may still have it.
At any rate, I got in over my head with USB because I couldn't figure out how to make the "driver" in Windows. If you're using Linux the project may be quite a bit easier, since all of that low level driver I/O logic is easily accessible in the kernel code. Also, Linux 2.6 offers some devices under /dev which can be used to directly send/receive to the USB device without the need for any special module/drivers. Great for development.