Search code examples
javatomcatservletstcpfingerprinting

I am running a Tomcat server, I would like to pull the details of the machine from which the requests originate. Is this possible and how?


This requirement is for a local server that collects information of all devices that connect to it in a closed organization. Need to pull details like OS Version, software versions, hardware properties.


Solution

  • Your best bet is the user agent string that is in the header of all HTTP requests. You can access it via the HttpServletRequest like this:

    String agent = request.getHeader("User-Agent");
    

    It contains info like browser (client) name, browser version, OS, OS version etc. Although there is no guarantee that these will be complete and valid, but from the server you can't force the client to send complete and valid info about itself.

    Example

    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
        Chrome/34.0.1847.131 Safari/537.36
    

    This means (source):

    Mozilla: MozillaProductSlice. Claims to be a Mozilla based user agent, which is only true for Gecko browsers like Firefox and Netscape. For all other user agents it means 'Mozilla-compatible'. In modern browsers, this is only used for historical reasons. It has no real meaning anymore

    5.0: Mozilla version

    Windows NT 6.1: Operating System: Windows 7

    WOW64: (Windows-On-Windows 64-bit) A 32-bit application is running on a 64-bit processor

    AppleWebKit: The Web Kit provides a set of core classes to display web content in windows

    537.36: Web Kit build

    KHTML: Open Source HTML layout engine developed by the KDE project

    like Gecko: like Gecko...

    Chrome: Name: Chrome

    34.0.1847.131: Chrome version

    Safari: Based on Safari

    537.36: Safari build

    User Agent string analysis

    About analyzing user agent strings: Looking for a Java User Agent String Parser

    Also useragentstring.com has an API.

    And there are more on the internet (Google it).