How to detect OS version of a web server

2019-08-14 01:16发布

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?

2条回答
做个烂人
2楼-- · 2019-08-14 01:19

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-08-14 01:20

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:

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

查看更多
登录 后发表回答