/// <summary> /// Constructor. /// </summary> /// <param name="ScanProvider">Instanciated implementation of an IScanProvider.</param> /// <param name="dorkToScan">A DorkDone, which represents the Dork to scan.</param> public Scanner(IScanProvider ScanProvider, DorkDone dorkToScan) { scanProvider = ScanProvider; _ScanStatus = (int)SCANTHREADSTATE.Waiting; _DorkToScan = dorkToScan; httpGet = null; }
/// <summary> /// Run a scan with a DorkDone. /// </summary> /// <param name="DorkToScan">DorkDone to scan.</param> /// <returns>True if no errors occured.</returns> public bool DoDork(DorkDone DorkToScan) { _ScanStatus = (int)SCANTHREADSTATE.Working; RequestBuilder req = new RequestBuilder(scanProvider); httpGet = new HttpSimpleGet(Properties.Settings.Default.ScanTimeOut); string currentRequest = req.getRequest(DorkToScan.Query, DorkToScan.Host, DorkToScan.NextPage); Trace.WriteLineIf(Debug.Trace.TraceGoolag.TraceInfo, currentRequest, "ScanURL:"); if (!httpGet.Do(currentRequest)) { DorkToScan.ErrorMessage = httpGet.GetErrorMessage(); DorkToScan.ScanResult = (int)RESULT_STATUS.Failure; _ScanStatus = (int)SCANTHREADSTATE.Finished; firstResultDork = DorkToScan; return(false); } ParseHtmlResults parser = new ParseHtmlResults(scanProvider, DorkToScan.NextPage); parsedResults = parser.Parse(httpGet.GetResults()); if (parsedResults.Count > 0) { DorkToScan.ScanResult = (int)RESULT_STATUS.ScanWithResult; DorkToScan.NextPage = parser.NextPage; DorkDone tmpDork = null; foreach (string parsedUrl in parsedResults) { DorkDone newDork = new DorkDone(); newDork = (DorkDone)DorkToScan.Clone(); newDork.ResultURL = parsedUrl; newDork.Next = tmpDork; tmpDork = newDork; } firstResultDork = tmpDork; } else { DorkToScan.Next = null; firstResultDork = DorkToScan; if (parser.Blocked) { DorkToScan.ScanResult = (int)RESULT_STATUS.Blocked; DorkToScan.ResultURL = httpGet.ResponseUri; } else { DorkToScan.ScanResult = (int)RESULT_STATUS.Nothing; } } _ScanStatus = (int)SCANTHREADSTATE.Finished; return(true); }
/// <summary> /// Constructor. /// </summary> /// <param name="ScanProvider">Instanciated implementation of an IScanProvider.</param> public Scanner(IScanProvider ScanProvider) { scanProvider = ScanProvider; _ScanStatus = (int)SCANTHREADSTATE.Waiting; httpGet = null; }