private static CustomTestsFile GetCustomTestFile() { CustomTestsFile testFile = new CustomTestsFile(); var customTests = testFile.GetCustomTests(); customTests.Clear(); customTests.Add("Path Traversal", new CustomTestDef("Path Traversal", "Path Traversal", "$original" + MockTestController.PATH_TRAVERSAL, "root\\:")); testFile.SetCustomTests(customTests); testFile.LoginBeforeTests = false; testFile.TestOnlyParameters = true; var targetList = testFile.GetAttackTargetList(); targetList.Add("all", new AttackTarget("all", "Enabled", ".*")); testFile.SetAttackTargetList(targetList); return(testFile); }
public void CustomTestProxy_TestJSValidation() { MockProxy mockSite = new MockProxy(); string testReq = "GET /r1?p1=test HTTP/1.1\r\n"; mockSite.MockSite.AddRequestResponse(testReq, "HTTP/1.1 200 OK\r\n\r\nFound user test"); mockSite.Start(); CustomTestsFile testFile = GetCustomTestFile(); var tests = testFile.GetCustomTests(); tests.Clear(); tests.Add("PathTraversal", new CustomTestDef("PathTraversal", "Path Traversal", "$original/" + MockTestController.PATH_TRAVERSAL, "$js_code=function Callback(response){var found = false; if(response.indexOf('root')>-1) found=true; return found;}")); testFile.SetCustomTests(tests); testFile.Save(); TrafficViewerFile testDataStore = new TrafficViewerFile(); MockTestController mockTestController = new MockTestController(mockSite.MockSite); var targetList = new Dictionary <string, AttackTarget>(); targetList.Add("r1", new AttackTarget("r1", "Enabled", "r1")); testFile.SetAttackTargetList(targetList); DriveByAttackProxy testProxy = new DriveByAttackProxy(mockTestController, testFile, testDataStore); testProxy.Start(); SendRequestThroughTestProxy(testReq, testProxy, mockSite); Thread.Sleep(100); testProxy.Stop(); Assert.IsTrue(mockTestController.IssuesFound.ContainsKey("p1")); }
private void LoadFile(string path) { bool loaded = true; _testFile = new CustomTestsFile(); CustomTestsFile file = new CustomTestsFile(); if (File.Exists(path)) { loaded = file.Load(path); } if (!loaded) { ErrorBox.ShowDialog("Could not load file"); return; } _testFile = file; _testFile.SetCustomTests(file.GetCustomTests()); _grid.SetValues((List <string>)_testFile.GetOption(CUSTOM_TESTS)); runAutomaticallyToolStripMenuItem.Checked = _testFile.AutoRunTests; _testRunner.SetTestFile(_testFile); }