How to detect web server type

前端 未结 2 797
滥情空心
滥情空心 2021-01-07 02:27

I\'m trying to detect which Web Server type is running a domain, so what are the best options to deal with this.

I\'m doing a C# application.

相关标签:
2条回答
  • 2021-01-07 02:53

    Another simple way is to use a web browser (Chrome, FireFox, IE). Most of them allow to access its developer mode pressing the F12 key. Then, access the web server url and go to the "Network" tab and "Response Headers" option to find if the "Server" response header is present.

    The bad news is that the "Server" header may not be present in the response as it is optional and, in fact, it's use is not recommended if security is a concern (otherwise a hacker may know the server in use and its version, so she can concentrate in it's vulnerabilities in order to attack the server)

    0 讨论(0)
  • 2021-01-07 03:01

    You could make a request to the server and check the response header for the value of "Server"

    For example

    using System;
    using System.Net;
    
    public class TestApp {
        public static void Main( string[] args ) {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com/");
            WebResponse response = request.GetResponse();
            Console.Out.WriteLine( response.Headers.Get("Server") );
        }
    }
    
    // Output:
    // Microsoft-IIS/7.0
    
    0 讨论(0)
提交回复
热议问题