Ejemplo n.º 1
0
        private TargetResult Connect(HttpProtocol Protocol, string IPAddress, int Port)
        {
            TargetResult Result  = new TargetResult();
            string       Address = string.Empty;

            if (Protocol == HttpProtocol.HTTP)
            {
                Address = "http://" + IPAddress + ":" + Port.ToString();
            }
            else if (Protocol == HttpProtocol.HTTPs)
            {
                Address = "https://" + IPAddress + ":" + Port.ToString();
            }


            CreateWebrequest webRequest = new CreateWebrequest();

            Result.Html     = webRequest.StringGetWebPage(Address, string.Empty);
            Result.Url      = Address;
            Result.Protocol = Protocol;

            if (webRequest.Response != null)
            {
                Result.ResponseHeaders = webRequest.Response.Headers;
                Result.Banner          = webRequest.Response.Server;
                Result.WebServer       = GetWebServer(webRequest.Response.Server);
                IPHostEntry Hostname = Dns.GetHostEntry(IPAddress);
                Result.Hostname   = Hostname.HostName;
                Result.Success    = true;
                Result.StatusCode = webRequest.Response.StatusCode;
            }
            else
            {
                Result.Success = false;
            }

            return(Result);
        }
        private TargetResult Connect(HttpProtocol Protocol, string IPAddress, int Port)
        {
            TargetResult Result = new TargetResult();
            string Address = string.Empty;
            if (Protocol == HttpProtocol.HTTP)
                Address = "http://" + IPAddress + ":" + Port.ToString();
            else if (Protocol == HttpProtocol.HTTPs)
                Address = "https://" + IPAddress + ":" + Port.ToString();

            CreateWebrequest webRequest = new CreateWebrequest();
            Result.Html = webRequest.StringGetWebPage(Address, string.Empty);
            Result.Url = Address;
            Result.Protocol = Protocol;

            if (webRequest.Response != null)
            {
                Result.ResponseHeaders = webRequest.Response.Headers;
                Result.Banner = webRequest.Response.Server;
                Result.WebServer = GetWebServer(webRequest.Response.Server);
                IPHostEntry Hostname = Dns.GetHostEntry(IPAddress);
                Result.Hostname = Hostname.HostName;
                Result.Success = true;
                Result.StatusCode = webRequest.Response.StatusCode;
            }
            else
            {
                Result.Success = false;
            }

            return Result;
        }