コード例 #1
0
        public void TestDuckDuckGo()
        {
            Init();

            DuckDuckGo ddg = new DuckDuckGo(Driver);

            ddg.SetQuery(TestQuery);
            ddg.DoSearch();
            ddg.Driver.Close();

            var unique = ddg.Results.Distinct();

            Assert.IsTrue(unique.Count() > 10);
        }
コード例 #2
0
        /// <summary>
        /// Gets the ID of a TV show in the database.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>ID.</returns>
        public override IEnumerable <ShowID> GetID(string name, string language = "en")
        {
            var list = new DuckDuckGo().Search("{0} site:epguides.com".FormatWith(name)).ToList();

            foreach (var result in list)
            {
                if (!Regex.IsMatch(result.URL, @"^http://(?:www\.)?epguides\.com/(?!menu|current|grid|spring|dvds|faq|search)([a-z0-9_]+)/$", RegexOptions.IgnoreCase))
                {
                    continue;
                }

                yield return(new ShowID(this)
                {
                    ID = result.URL,
                    Title = Regex.Replace(result.Title, @"\s+\(a Titles (?:&|and) (?:Air Dates|Seasons) Guide\).*$", string.Empty, RegexOptions.IgnoreCase),
                    Language = "en",
                    URL = result.URL
                });
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles the Click event of the proxySearchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void ProxySearchButtonClick(object sender, RoutedEventArgs e)
        {
            if (proxiesListView.SelectedIndex == -1)
            {
                return;
            }

            Thread action = null;
            var    done   = false;

            var sel = (ProxiesListViewItem)proxiesListView.SelectedItem;
            var uri = new Uri(sel.Address.Replace("$domain.", string.Empty));

            if (uri.Host == "localhost" || uri.Host == "127.0.0.1" || uri.Host == "::1")
            {
                var app = "a local application";

                try
                {
                    var tcpRows = Utils.GetExtendedTCPTable();
                    foreach (var row in tcpRows)
                    {
                        if (((row.localPort1 << 8) + (row.localPort2) + (row.localPort3 << 24) + (row.localPort4 << 16)) == uri.Port)
                        {
                            app = "PID " + row.owningPid + " (" + Process.GetProcessById(row.owningPid).Modules[0].FileName + ")";
                            break;
                        }
                    }
                }
                catch { }

                TaskDialog.Show(new TaskDialogOptions
                {
                    MainIcon        = VistaTaskDialogIcon.Warning,
                    Title           = sel.Name,
                    MainInstruction = "Potentially dangerous",
                    Content         = "This proxy points to a local loopback address on port " + uri.Port + ".\r\nYour requests will go to " + app + ", which will most likely forward them to an external server.",
                    CustomButtons   = new[] { "OK" }
                });
                return;
            }

            var showmbp = false;
            var mthd    = new Thread(() => TaskDialog.Show(new TaskDialogOptions
            {
                Title                   = sel.Name,
                MainInstruction         = "Testing proxy",
                Content                 = "Testing whether " + uri.Host + " is a known proxy...",
                CustomButtons           = new[] { "Cancel" },
                ShowMarqueeProgressBar  = true,
                EnableCallbackTimer     = true,
                AllowDialogCancellation = true,
                Callback                = (dialog, args, data) =>
                {
                    if (!showmbp)
                    {
                        dialog.SetProgressBarMarquee(true, 0);
                        showmbp = true;
                    }

                    if (args.ButtonId != 0)
                    {
                        if (!done)
                        {
                            try { action.Abort(); } catch { }
                        }

                        return(false);
                    }

                    if (done)
                    {
                        dialog.ClickButton(500);
                        return(false);
                    }

                    return(true);
                }
            }));

            mthd.SetApartmentState(ApartmentState.STA);
            mthd.Start();

            action = new Thread(() =>
            {
                try
                {
                    var src = new DuckDuckGo();
                    var res = new List <SearchResult>();
                    res.AddRange(src.Search("\"" + uri.Host + "\" intitle:proxy"));

                    if (res.Count == 0)
                    {
                        res.AddRange(src.Search("\"" + uri.Host + "\" intitle:proxies"));
                    }

                    done = true;

                    if (res.Count == 0)
                    {
                        TaskDialog.Show(new TaskDialogOptions
                        {
                            MainIcon        = VistaTaskDialogIcon.Information,
                            Title           = sel.Name,
                            MainInstruction = "Not a known public proxy",
                            Content         = uri.Host + " does not seem to be a known public proxy." + Environment.NewLine + Environment.NewLine +
                                              "If your goal is to trick proxy detectors, you're probably safe for now. However, you shouldn't use public proxies if you don't want to potentially compromise your account.",
                            CustomButtons = new[] { "OK" }
                        });
                        return;
                    }
                    else
                    {
                        TaskDialog.Show(new TaskDialogOptions
                        {
                            MainIcon        = VistaTaskDialogIcon.Error,
                            Title           = sel.Name,
                            MainInstruction = "Known public proxy",
                            Content         = uri.Host + " is a known public proxy according to " + new Uri(res[0].URL).Host.Replace("www.", string.Empty) + Environment.NewLine + Environment.NewLine +
                                              "If the site you're trying to access through this proxy forbids proxy usage, they're most likely use a detection mechanism too, which will trigger an alert when it sees this IP address. Your requests will be denied and your account might also get banned. Even if the site's detector won't recognize it, using a public proxy is not such a good idea, because you could compromise your account as public proxy operators are known to be evil sometimes.",
                            CustomButtons = new[] { "OK" }
                        });
                        return;
                    }
                }
                catch (ThreadAbortException) { }
                catch (Exception ex)
                {
                    done = true;

                    TaskDialog.Show(new TaskDialogOptions
                    {
                        MainIcon        = VistaTaskDialogIcon.Error,
                        Title           = sel.Name,
                        MainInstruction = "Connection error",
                        Content         = "An error occurred while checking the proxy.",
                        ExpandedInfo    = ex.Message,
                        CustomButtons   = new[] { "OK" }
                    });
                }
            });
            action.Start();
        }
コード例 #4
0
        /// <summary>
        /// Handles the Click event of the proxySearchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void ProxySearchButtonClick(object sender, RoutedEventArgs e)
        {
            if (proxiesListView.SelectedIndex == -1) return;

            Thread action = null;
            var done = false;

            var sel = (ProxiesListViewItem)proxiesListView.SelectedItem;
            var uri = new Uri(sel.Address.Replace("$domain.", string.Empty));

            if (uri.Host == "localhost" || uri.Host == "127.0.0.1" || uri.Host == "::1")
            {
                var app = "a local application";

                try
                {
                    var tcpRows = Utils.GetExtendedTCPTable();
                    foreach (var row in tcpRows)
                    {
                        if (((row.localPort1 << 8) + (row.localPort2) + (row.localPort3 << 24) + (row.localPort4 << 16)) == uri.Port)
                        {
                            app = "PID " + row.owningPid + " (" + Process.GetProcessById(row.owningPid).Modules[0].FileName + ")";
                            break;
                        }
                    }
                }
                catch { }

                TaskDialog.Show(new TaskDialogOptions
                    {
                        MainIcon        = VistaTaskDialogIcon.Warning,
                        Title           = sel.Name,
                        MainInstruction = "Potentially dangerous",
                        Content         = "This proxy points to a local loopback address on port " + uri.Port + ".\r\nYour requests will go to " + app + ", which will most likely forward them to an external server.",
                        CustomButtons   = new[] { "OK" }
                    });
                return;
            }

            var showmbp = false;
            var mthd = new Thread(() => TaskDialog.Show(new TaskDialogOptions
                {
                    Title                   = sel.Name,
                    MainInstruction         = "Testing proxy",
                    Content                 = "Testing whether " + uri.Host + " is a known proxy...",
                    CustomButtons           = new[] { "Cancel" },
                    ShowMarqueeProgressBar  = true,
                    EnableCallbackTimer     = true,
                    AllowDialogCancellation = true,
                    Callback                = (dialog, args, data) =>
                        {
                            if (!showmbp)
                            {
                                dialog.SetProgressBarMarquee(true, 0);
                                showmbp = true;
                            }

                            if (args.ButtonId != 0)
                            {
                                if (!done)
                                {
                                    try { action.Abort(); } catch { }
                                }

                                return false;
                            }

                            if (done)
                            {
                                dialog.ClickButton(500);
                                return false;
                            }

                            return true;
                        }
                }));
            mthd.SetApartmentState(ApartmentState.STA);
            mthd.Start();

            action = new Thread(() =>
                {
                    try
                    {
                        var src = new DuckDuckGo();
                        var res = new List<SearchResult>();
                        res.AddRange(src.Search("\"" + uri.Host + "\" intitle:proxy"));

                        if (res.Count == 0)
                        {
                            res.AddRange(src.Search("\"" + uri.Host + "\" intitle:proxies"));
                        }

                        done = true;

                        if (res.Count == 0)
                        {
                            TaskDialog.Show(new TaskDialogOptions
                                {
                                    MainIcon        = VistaTaskDialogIcon.Information,
                                    Title           = sel.Name,
                                    MainInstruction = "Not a known public proxy",
                                    Content         = uri.Host + " does not seem to be a known public proxy." + Environment.NewLine + Environment.NewLine +
                                                      "If your goal is to trick proxy detectors, you're probably safe for now. However, you shouldn't use public proxies if you don't want to potentially compromise your account.",
                                    CustomButtons   = new[] { "OK" }
                                });
                            return;
                        }
                        else
                        {
                            TaskDialog.Show(new TaskDialogOptions
                                {
                                    MainIcon        = VistaTaskDialogIcon.Error,
                                    Title           = sel.Name,
                                    MainInstruction = "Known public proxy",
                                    Content         = uri.Host + " is a known public proxy according to " + new Uri(res[0].URL).Host.Replace("www.", string.Empty) + Environment.NewLine + Environment.NewLine +
                                                      "If the site you're trying to access through this proxy forbids proxy usage, they're most likely use a detection mechanism too, which will trigger an alert when it sees this IP address. Your requests will be denied and your account might also get banned. Even if the site's detector won't recognize it, using a public proxy is not such a good idea, because you could compromise your account as public proxy operators are known to be evil sometimes.",
                                    CustomButtons   = new[] { "OK" }
                                });
                            return;
                        }
                    }
                    catch (ThreadAbortException) { }
                    catch (Exception ex)
                    {
                        done = true;

                        TaskDialog.Show(new TaskDialogOptions
                            {
                                MainIcon        = VistaTaskDialogIcon.Error,
                                Title           = sel.Name,
                                MainInstruction = "Connection error",
                                Content         = "An error occurred while checking the proxy.",
                                ExpandedInfo    = ex.Message,
                                CustomButtons   = new[] { "OK" }
                            });
                    }
                });
            action.Start();
        }
コード例 #5
0
        /// <summary>
        /// Gets the ID of a TV show in the database.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="language">The preferred language of the data.</param>
        /// <returns>ID.</returns>
        public override IEnumerable<ShowID> GetID(string name, string language = "en")
        {
            var list = new DuckDuckGo().Search("{0} site:epguides.com".FormatWith(name)).ToList();

            foreach (var result in list)
            {
                if (!Regex.IsMatch(result.URL, @"^http://(?:www\.)?epguides\.com/(?!menu|current|grid|spring|dvds|faq|search)([a-z0-9_]+)/$", RegexOptions.IgnoreCase)) continue;

                yield return new ShowID(this)
                    {
                        ID       = result.URL,
                        Title    = Regex.Replace(result.Title, @"\s+\(a Titles (?:&|and) (?:Air Dates|Seasons) Guide\).*$", string.Empty, RegexOptions.IgnoreCase),
                        Language = "en",
                        URL      = result.URL
                    };
            }
        }