Is there a way to detect the Operating System version of a web server using its IP address (with knowledge that the web server is running php).
I haven't attempted to code it yet, as i am a beginner. Is it easy? Is it possible or not possible at all?
There's no official way to detect OS on a remote server across all operating systems and configurations. It's often considered a security risk to expose such information, since it can be used to research directed attacks based on the version of the OS and any services it runs.
However, you can fingerprint systems to "guess" the OS, depending on the services it exposes. Many services will reveal the OS that is currently running, some will hint at it or provide broad information about the system.
I certainly wouldn't suggest anyone inexperienced in PHP attempt such a project, but here are some links to get you started:
- Finger Protocol: http://en.wikipedia.org/wiki/Finger_protocol
- nmap security scanner (includes OS fingerprinting): http://nmap.org/
- nmap's book on remote OS detection: http://nmap.org/book/osdetect.html
If you're just trying to find out the OS of the user viewing your website, you should look into the User-Agent
HTTP header: http://en.wikipedia.org/wiki/User_agent
your question is kind a unclear but I asume you want to display the OS of the system your website is running on? You can try:
<?php
echo (string)(PHP_OS);
?>
or
<?php
echo $_SERVER['SERVER_SOFTWARE'];
?>
But this will never return a precise version of your OS as it will only indicating the platform(windows, linux, macos, etc) and the latter script also displays 32/64 bit under windows.