|
| 1 | +using System; |
| 2 | +using System.Linq; |
| 3 | +using System.Text; |
| 4 | +using System.Net; |
| 5 | +using System.IO; |
| 6 | +using System.Threading; |
| 7 | +using System.Windows.Forms; |
| 8 | +namespace ProxyGenerator |
| 9 | +{ |
| 10 | + class Program |
| 11 | + { |
| 12 | + [STAThread] |
| 13 | + static void Main(string[] args) |
| 14 | + { |
| 15 | + Console.Title = "Proxy Tools | Made by Kye | https://github.com/promasterboy"; |
| 16 | + int selection = 0; |
| 17 | + start: Console.ForegroundColor = ConsoleColor.Blue; |
| 18 | + Console.WriteLine("Proxy Tools"); |
| 19 | + Console.ForegroundColor = ConsoleColor.Green; |
| 20 | + Console.WriteLine(""); |
| 21 | + Console.WriteLine("==============="); |
| 22 | + Console.WriteLine(""); |
| 23 | + Console.WriteLine("Proxy Generator"); |
| 24 | + Console.WriteLine("1 = HTTP"); |
| 25 | + Console.WriteLine("2 = Socks4"); |
| 26 | + Console.WriteLine("3 = Socks5"); |
| 27 | + Console.WriteLine(""); |
| 28 | + Console.WriteLine("==============="); |
| 29 | + Console.WriteLine(""); |
| 30 | + Console.WriteLine("4 = Proxy Checker"); |
| 31 | + try |
| 32 | + { |
| 33 | + selection = int.Parse(Console.ReadLine()); |
| 34 | + } |
| 35 | + catch |
| 36 | + { |
| 37 | + Console.Clear(); |
| 38 | + goto start; |
| 39 | + } |
| 40 | + if (selection > 4) |
| 41 | + { |
| 42 | + Console.Clear(); |
| 43 | + goto start; |
| 44 | + } |
| 45 | + |
| 46 | + if (selection == 1) |
| 47 | + { |
| 48 | + Console.WriteLine("Getting HTTP Proxies!"); |
| 49 | + WriteProxy2("https://api.proxyscrape.com/?request=getproxies&proxytype=http&timeout=10000&country=all&ssl=all&anonymity=all", "https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt", "HTTP"); |
| 50 | + } |
| 51 | + if (selection == 2) |
| 52 | + { |
| 53 | + Console.WriteLine("Getting Socks4 Proxies!"); |
| 54 | + WriteProxy("https://api.proxyscrape.com/?request=getproxies&proxytype=socks4&timeout=10000&country=all", "Socks4"); |
| 55 | + } |
| 56 | + if (selection == 3) |
| 57 | + { |
| 58 | + Console.WriteLine("Getting Socks5 Proxies!"); |
| 59 | + WriteProxy("https://api.proxyscrape.com/?request=getproxies&proxytype=socks5&timeout=10000&country=all", "Socks5"); |
| 60 | + } |
| 61 | + |
| 62 | + if (selection == 4) |
| 63 | + { |
| 64 | + if (!File.Exists("good_proxies.txt")) |
| 65 | + { |
| 66 | + File.Create("good_proxies.txt").Close(); |
| 67 | + } |
| 68 | + if (!File.Exists("bad_proxies.txt")) |
| 69 | + { |
| 70 | + File.Create("bad_proxies.txt").Close(); |
| 71 | + } |
| 72 | + CheckProxies(); |
| 73 | + } |
| 74 | + } |
| 75 | + public static int good { get; set; } |
| 76 | + public static int bad { get; set; } |
| 77 | + public static void CheckProxies() |
| 78 | + { |
| 79 | + |
| 80 | + Console.WriteLine("Select a proxy .txt file"); |
| 81 | + Thread.Sleep(300); |
| 82 | + OpenFileDialog o = new OpenFileDialog(); |
| 83 | + o.Filter = "txt files (*.txt)|*.txt"; |
| 84 | + o.Title = "Select a Proxy"; |
| 85 | + o.ShowDialog(); |
| 86 | + Console.Clear(); |
| 87 | + string[] proxies = File.ReadAllLines(o.FileName); |
| 88 | + Console.Clear(); |
| 89 | + Console.ForegroundColor = ConsoleColor.Blue; |
| 90 | + Console.WriteLine("Checking Proxies"); |
| 91 | + Console.WriteLine(" "); |
| 92 | + Console.WriteLine("============"); |
| 93 | + Console.WriteLine(" "); |
| 94 | + Console.ForegroundColor = ConsoleColor.Green; |
| 95 | + Console.WriteLine("Good: " + good); |
| 96 | + Console.ForegroundColor = ConsoleColor.Red; |
| 97 | + Console.WriteLine("Bad: " + bad); |
| 98 | + foreach (string proxy in proxies) |
| 99 | + { |
| 100 | + Thread.Sleep(800); |
| 101 | + string[] data = proxy.Split(':'); |
| 102 | + if (ProxyCheck(data[0], int.Parse(data[1])) == true) |
| 103 | + { |
| 104 | + string already = File.ReadAllText("good_proxies.txt"); |
| 105 | + using (StreamWriter writer = new StreamWriter("good_proxies.txt")) |
| 106 | + { |
| 107 | + writer.WriteLine(already + data[0] + ":" + data[1]); |
| 108 | + } |
| 109 | + good++; |
| 110 | + } |
| 111 | + else |
| 112 | + { |
| 113 | + string already = File.ReadAllText("bad_proxies.txt"); |
| 114 | + using (StreamWriter writer = new StreamWriter("bad_proxies.txt")) |
| 115 | + { |
| 116 | + writer.WriteLine(already + data[0] + ":" + data[1]); |
| 117 | + } |
| 118 | + bad++; |
| 119 | + } |
| 120 | + Console.Clear(); |
| 121 | + Console.ForegroundColor = ConsoleColor.Blue; |
| 122 | + Console.WriteLine("Checking Proxies"); |
| 123 | + Console.WriteLine(" "); |
| 124 | + Console.WriteLine("============"); |
| 125 | + Console.WriteLine(" "); |
| 126 | + Console.ForegroundColor = ConsoleColor.Green; |
| 127 | + Console.WriteLine("Good: " + good); |
| 128 | + Console.ForegroundColor = ConsoleColor.Red; |
| 129 | + Console.WriteLine("Bad: " + bad); |
| 130 | + } |
| 131 | + Console.Clear(); |
| 132 | + Console.ForegroundColor = ConsoleColor.Blue; |
| 133 | + Console.WriteLine("Proxy Results"); |
| 134 | + Console.WriteLine(" "); |
| 135 | + Console.WriteLine("============"); |
| 136 | + Console.WriteLine(" "); |
| 137 | + Console.ForegroundColor = ConsoleColor.Green; |
| 138 | + Console.WriteLine(good + " good proxies saved to " + AppDomain.CurrentDomain.BaseDirectory + "good_proxies.txt"); |
| 139 | + Console.ForegroundColor = ConsoleColor.Red; |
| 140 | + Console.WriteLine(bad + " bad proxies saved to " + AppDomain.CurrentDomain.BaseDirectory + "bad_proxies.txt"); |
| 141 | + Console.ReadKey(); |
| 142 | + } |
| 143 | + |
| 144 | + public static void WriteProxy(string url, string type) |
| 145 | + { |
| 146 | + string filename = type + "_proxies.txt"; |
| 147 | + if (File.Exists(filename)) |
| 148 | + { |
| 149 | + File.Delete(filename); |
| 150 | + } |
| 151 | + WebClient webClient = new WebClient(); |
| 152 | + webClient.Timeout = 100000; |
| 153 | + string proxies = webClient.DownloadString(url); |
| 154 | + using (StreamWriter writer = new StreamWriter(filename)) |
| 155 | + { |
| 156 | + writer.Write(proxies); |
| 157 | + } |
| 158 | + Console.Clear(); |
| 159 | + Console.ForegroundColor = ConsoleColor.Blue; |
| 160 | + int lineCount = File.ReadLines(filename).Count(); |
| 161 | + Console.WriteLine("Exported " + lineCount + " proxies to: " + AppDomain.CurrentDomain.BaseDirectory + filename); |
| 162 | + Console.ReadKey(); |
| 163 | + } |
| 164 | + |
| 165 | + public static void WriteProxy2(string url, string url2 ,string type) |
| 166 | + { |
| 167 | + string filename = type + "_proxies.txt"; |
| 168 | + if (File.Exists(filename)) |
| 169 | + { |
| 170 | + File.Delete(filename); |
| 171 | + } |
| 172 | + WebClient webClient = new WebClient(); |
| 173 | + webClient.Timeout = 100000; |
| 174 | + string proxies = webClient.DownloadString(url); |
| 175 | + string proxies2 = webClient.DownloadString(url2); |
| 176 | + using (StreamWriter writer = new StreamWriter(filename)) |
| 177 | + { |
| 178 | + writer.Write(proxies); |
| 179 | + writer.WriteLine(proxies2); |
| 180 | + } |
| 181 | + Console.Clear(); |
| 182 | + Console.ForegroundColor = ConsoleColor.Blue; |
| 183 | + int lineCount = File.ReadLines(filename).Count(); |
| 184 | + Console.WriteLine("Exported " + lineCount + " proxies to: " + AppDomain.CurrentDomain.BaseDirectory + filename); |
| 185 | + Console.ReadKey(); |
| 186 | + } |
| 187 | + |
| 188 | + private static readonly string UserAgent = "Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 70.0.3538.77 Safari / 537.36"; |
| 189 | + public static bool ProxyCheck(string ipAddress, int port) |
| 190 | + { |
| 191 | + try |
| 192 | + { |
| 193 | + ICredentials credentials = CredentialCache.DefaultCredentials; |
| 194 | + IWebProxy proxy = new WebProxy(ipAddress, port); |
| 195 | + proxy.Credentials = credentials; |
| 196 | + using (var wc = new WebClient()) |
| 197 | + { |
| 198 | + wc.Timeout = 5000; |
| 199 | + wc.Proxy = proxy; |
| 200 | + wc.Encoding = Encoding.UTF8; |
| 201 | + wc.Headers.Add("User-Agent", UserAgent); |
| 202 | + string result = wc.DownloadString("http://google.com"); |
| 203 | + return true; |
| 204 | + } |
| 205 | + } |
| 206 | + catch |
| 207 | + { |
| 208 | + return false; |
| 209 | + } |
| 210 | + } |
| 211 | + private class WebClient : System.Net.WebClient |
| 212 | + { |
| 213 | + public int Timeout { get; set; } |
| 214 | + protected override WebRequest GetWebRequest(Uri uri) |
| 215 | + { |
| 216 | + WebRequest lWebRequest = base.GetWebRequest(uri); |
| 217 | + lWebRequest.Timeout = Timeout; |
| 218 | + ((HttpWebRequest)lWebRequest).ReadWriteTimeout = Timeout; |
| 219 | + return lWebRequest; |
| 220 | + } |
| 221 | + } |
| 222 | + } |
| 223 | +} |
0 commit comments