private void btAllLinksDuckduckGo_Click(object sender, EventArgs e) { domain.map.SearchingAllLinks = HttpMap.SearchStatus.Searching; var wsSearch = new DuckduckgoWebSearcher { SearchAll = true, Site = domain.Domain }; wsSearch.SearcherLinkFoundEvent += wsSearch_SearcherLinkFoundEvent; wsSearch.SearcherEndEvent += delegate { domain.map.SearchingAllLinks = HttpMap.SearchStatus.Finished; Invoke(new MethodInvoker(delegate { Program.LogThis(new Log(Log.ModuleType.Crawling, "Finishing the links extraction of " + domain.Domain, Log.LogType.debug)); Program.FormMainInstance.UpdateBottomPanel(domain); })); }; wsSearch.GetCustomLinks("site:" + domain.Domain); Program.LogThis(new Log(Log.ModuleType.Crawling, "Extracting links of " + domain.Domain, Log.LogType.debug)); AddLog("Duckduckgo crawling"); }
/// <summary> /// Perform web search based on the user's choice /// </summary> private void SearchWeb() { string message = $"Searching subdomains for {strDomain} in {PanelWebSearcherInformation.EngineToString(searchEngine)}"; Program.LogThis(new Log(Log.ModuleType.WebSearch, message, Log.LogType.debug)); Program.ChangeStatus(message); LinkSearcher searcher = null; switch (searchEngine) { case PanelWebSearcherInformation.Engine.GoogleWeb: searcher = new GoogleWebSearcher { cSafeSearch = GoogleWebSearcher.SafeSearch.off, FirstSeen = GoogleWebSearcher.FirstSeenGoogle.AnyTime, LocatedInRegion = GoogleWebSearcher.Region.AnyRegion, WriteInLanguage = GoogleWebSearcher.Language.AnyLanguage }; break; case PanelWebSearcherInformation.Engine.GoogleAPI: searcher = new GoogleAPISearcher(Program.cfgCurrent.GoogleApiKey, Program.cfgCurrent.GoogleApiCx); break; case PanelWebSearcherInformation.Engine.BingWeb: searcher = new BingWebSearcher { LocatedInRegion = BingWebSearcher.Region.AnyRegion, WriteInLanguage = BingWebSearcher.Language.AnyLanguage }; break; case PanelWebSearcherInformation.Engine.BingAPI: searcher = new BingAPISearcher(Program.cfgCurrent.BingApiKey); break; case PanelWebSearcherInformation.Engine.DuckDuckGoWeb: searcher = new DuckduckgoWebSearcher(); break; } try { searcher.ItemsFoundEvent += CaptureSearchResults; searcher.SearcherLogEvent += WebSearcherLogEvent; CancelIfSkipRequested(); searcher.SearchBySite(this.searchCancelToken, strDomain) .ContinueWith((e) => SearchEngineFinish(e, searcher.Name, Log.ModuleType.WebSearch)) .Wait(); } catch (OperationCanceledException) { } }
/// <summary> /// Perform the search through DuckDuckGo Web /// </summary> private void DuckDuckWebSearch() { DuckduckgoWebSearcher duckSearcher = null; try { duckSearcher = new DuckduckgoWebSearcher(); var currentResults = new List <string>(); duckSearcher.SearcherLinkFoundEvent += delegate(object sender, EventsThreads.ThreadListDataFoundEventArgs e) { var searcher = (DuckduckgoWebSearcher)sender; foreach (var item in e.Data) { if (CheckToSkip()) { searcher.Abort(); } try { var url = new Uri((string)item); var strHost = url.Host; if (currentResults.All(d => !string.Equals(d, strHost, StringComparison.CurrentCultureIgnoreCase))) { currentResults.Add(strHost); AddAndLogSubdomainDiscover(strHost); } var domain = Program.data.GetDomain(url.Host); domain.map.AddUrl(url.ToString()); } catch (Exception ex) { throw ex; } } }; duckSearcher.SearcherLogEvent += WebSearcherLogEvent; var endReason = EventsThreads.ThreadEndEventArgs.EndReasonEnum.ErrorFound; duckSearcher.SearcherEndEvent += delegate(object o, EventsThreads.ThreadEndEventArgs e) { endReason = e.EndReason; }; var strSearchString = $"site:{strDomain}"; int nroResultados; do { if (CheckToSkip()) { return; } nroResultados = currentResults.Count; duckSearcher.GetCustomLinks(strSearchString); duckSearcher.Join(); CheckEndReason(endReason, currentResults, strSearchString, 49); } while (endReason == EventsThreads.ThreadEndEventArgs.EndReasonEnum.LimitReached && nroResultados != currentResults.Count); } catch (Exception ex) { throw ex; } finally { duckSearcher?.Abort(); } }
/// <summary> /// Perform web search based on the user's choice /// </summary> private void SearchWeb() { string message = $"Searching subdomains for {strDomain} in {PanelWebSearcherInformation.EngineToString(searchEngine)}"; Program.LogThis(new Log(Log.ModuleType.WebSearch, message, Log.LogType.debug)); Program.ChangeStatus(message); WebSearcher searcher = null; switch (searchEngine) { case PanelWebSearcherInformation.Engine.GoogleWeb: searcher = new GoogleWebSearcher { SearchAll = true, cSafeSearch = GoogleWebSearcher.SafeSearch.off, FirstSeen = GoogleWebSearcher.FirstSeenGoogle.AnyTime, LocatedInRegion = GoogleWebSearcher.Region.AnyRegion, WriteInLanguage = GoogleWebSearcher.Language.AnyLanguage }; break; case PanelWebSearcherInformation.Engine.GoogleAPI: searcher = new GoogleAPISearcher(Program.cfgCurrent.GoogleApiKey, Program.cfgCurrent.GoogleApiCx) { SearchAll = true }; break; case PanelWebSearcherInformation.Engine.BingWeb: searcher = new BingWebSearcher { LocatedInRegion = BingWebSearcher.Region.AnyRegion, SearchAll = true, WriteInLanguage = BingWebSearcher.Language.AnyLanguage }; break; case PanelWebSearcherInformation.Engine.BingAPI: searcher = new BingAPISearcher(Program.cfgCurrent.BingApiKey); break; case PanelWebSearcherInformation.Engine.DuckDuckGoWeb: searcher = new DuckduckgoWebSearcher(); break; } try { searcher.SearcherLinkFoundEvent += CaptureSearchResults; searcher.SearcherLogEvent += WebSearcherLogEvent; string strSearchString = $"site:{strDomain}"; if (CheckToSkip()) { return; } searcher.GetCustomLinks(strSearchString); searcher.Join(); } catch (ThreadAbortException) { } finally { searcher?.Abort(); } }