Exemplo n.º 1
0
        public void PerformWPADTest_AuthPermutations()
        {
            HttpListener httpListener = WPADServiceFakeHelper.CreateWPADService(String.Format("http://{0}:{1}/", ServerAddress, ServerPort));

            try
            {
                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                SpoofDetectionResult result =
                    WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, null, null, null);
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "Guest", null, null);
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "Guest", "test", null);
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "Guest", "test",
                                                    "test");
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "Guest", null, "test");
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, null, "test", "test");
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);

                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                result = WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, null, null, "test");
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual("HTTP Code OK", result.Response);
            }
            finally
            {
                httpListener.Close();
            }
        }
Exemplo n.º 2
0
 public void PerformWPADTest_ResponseSinkhole()
 {
     using (Socket socket = WPADServiceFakeHelper.CreateHTTPSinkholeTcpSocket(ServerAddress, ServerPort))
     {
         SpoofDetectionResult result =
             WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "test", "test", "test");
         Assert.IsFalse(result.Detected);
         Assert.AreEqual(ConfidenceLevel.FalsePositive, result.Confidence);
         Assert.AreEqual(Protocol.WPAD, result.Protocol);
         Assert.IsNull(result.Response);
         Assert.AreEqual("Unknown HTTP error (The operation has timed out.)", result.ErrorMessage);
         Assert.AreEqual(ServerAddress, result.Endpoint.Address.ToString());
         Assert.AreEqual(ServerPort, result.Endpoint.Port);
     }
 }
Exemplo n.º 3
0
 public void PerformWPADTest_TotalJunk()
 {
     using (Socket socket = WPADServiceFakeHelper.CreateJunkTcpSocket(ServerAddress, ServerPort))
     {
         SpoofDetectionResult result =
             WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "test", "test", "test");
         Assert.IsFalse(result.Detected);
         Assert.AreEqual(ConfidenceLevel.FalsePositive, result.Confidence);
         Assert.AreEqual(Protocol.WPAD, result.Protocol);
         Assert.IsNull(result.Response);
         Assert.AreEqual(
             "Unknown HTTP error (The server committed a protocol violation. Section=ResponseStatusLine)",
             result.ErrorMessage);
         Assert.AreEqual(ServerAddress, result.Endpoint.Address.ToString());
         Assert.AreEqual(ServerPort, result.Endpoint.Port);
     }
 }
Exemplo n.º 4
0
        public void PerformWPADTest()
        {
            HttpListener httpListener = WPADServiceFakeHelper.CreateWPADService(String.Format("http://{0}:{1}/", ServerAddress, ServerPort));

            try
            {
                WPADServiceFakeHelper.PerformSingleWPADServiceListen(httpListener, HttpStatusCode.OK, "");
                SpoofDetectionResult result =
                    WPADTester.PerformWPADTest(IPAddress.Parse(ServerAddress), ServerPort, "test", "test", "test");
                Assert.IsTrue(result.Detected);
                Assert.AreEqual(ConfidenceLevel.Medium, result.Confidence);
                Assert.AreEqual(Protocol.WPAD, result.Protocol);
                Assert.IsNull(result.ErrorMessage);
                Assert.AreEqual("HTTP Code OK", result.Response);
                Assert.AreEqual(ServerAddress, result.Endpoint.Address.ToString());
                Assert.AreEqual(ServerPort, result.Endpoint.Port);
            }
            finally
            {
                httpListener.Close();
            }
        }