public static void Menu() { Console.Clear(); WriteConsole.AsciiText("ProxyStar", true, true, ConsoleColor.Cyan); WriteConsole.ColorText($"Welcome to ProxyStar V1.0.0!\n\nRead {ProxyQueue.Count.ToString()} Proxies from proxies.txt\n", ConsoleColor.Cyan); WriteConsole.ColorText("Menu:\n\n1) Check HTTP(s) proxies\n2) Check SOCKS4 proxies\n3) Check SOCKS5 proxies\n\nInput: ", ConsoleColor.Cyan); var UserInput = Console.ReadKey(); if (UserInput.Key == ConsoleKey.D1) { type = ProxyTypes.Http; } else if (UserInput.Key == ConsoleKey.D2) { type = ProxyTypes.Socks4; } else if (UserInput.Key == ConsoleKey.D3) { type = ProxyTypes.Socks5; } else { Menu(); } Console.Clear(); WriteConsole.ColorText($"Loaded: {ProxyQueue.Count.ToString()} Proxies from proxies.txt\n", ConsoleColor.Cyan); Console.WriteLine("Threads: "); threads = Convert.ToInt32(Console.ReadLine()); CheckProxy(); }
static void Main(string[] args) { if (!File.Exists("proxies.txt")) { WriteConsole.ColorText("Could not find proxies.txt! Make sure that proxies.txt is located in the root folder of this program!\n\n\n\n", ConsoleColor.Red); } else { Menu(); } }
static void CheckProxy() { int ProxyCount = ProxyQueue.Count; var uri = new Uri("https://api.ipify.org"); Parallel.ForEach(ProxyQueue, new ParallelOptions { MaxDegreeOfParallelism = threads }, FProxy => { try { string[] proxy = FProxy.Split(':'); string ip = proxy[0]; int port = Convert.ToInt32(proxy[1]); var HttpClientHandler = new HttpClientHandler(); HttpClientHandler.UseProxy = true; switch (type) { case ProxyTypes.Http: HttpClientHandler.Proxy = new WebProxy($"http://{proxy[0]}:{proxy[1]}"); break; case ProxyTypes.Socks4: var Socks4Proxy = new ProxyClient(ip, port, ProxyType.Socks4); HttpClientHandler.Proxy = Socks4Proxy; break; case ProxyTypes.Socks5: var Socks5Proxy = new ProxyClient(ip, port, ProxyType.Socks5); HttpClientHandler.Proxy = Socks5Proxy; break; } var client = new HttpClient(HttpClientHandler); HttpResponseMessage httpResponse = client.GetAsync(uri).Result; string response = httpResponse.Content.ReadAsStringAsync().Result; if (response.Contains(ip)) { Working++; WriteConsole.ColorText($"WORKING: {ip}:{port}", ConsoleColor.Green); SaveData.WriteLinesToTxt($"Working-Proxies-{DateTime.Now.ToString("MM-dd-yyyy")}.txt", $"{ip}:{port}"); } else { Dead++; WriteConsole.ColorText($"BAD: {ip}:{port}", ConsoleColor.Red); } } catch (HttpRequestException) { Dead++; WriteConsole.ColorText($"BAD: {FProxy}", ConsoleColor.Red); } catch (AggregateException) { Dead++; WriteConsole.ColorText($"BAD: {FProxy}", ConsoleColor.Red); } catch (NullReferenceException) { Dead++; WriteConsole.ColorText($"BAD: {FProxy}", ConsoleColor.Red); } catch (TaskCanceledException) {} Checked++; Console.Title = $"ProxyStar V1.0.0 | Progress: {Checked}/{ProxyCount} | Working: {Working} | Dead Proxies: {Dead}"; }); }