├── .gitattributes ├── .gitignore ├── Classes ├── CFIPList.cs ├── CheckIPWorking.cs ├── Config │ ├── AppConfig.cs │ ├── ConfigInterface.cs │ ├── ConfigManager.cs │ ├── RealConfig.cs │ └── ScanResults.cs ├── HTTPRequest │ └── DnsHandler.cs ├── IP │ ├── IPAddressExtensions.cs │ └── SubnetMask.cs ├── LogControl.cs ├── ScanEngine.cs └── ScanProgressInfo.cs ├── LICENSE.txt ├── Program.cs ├── Properties ├── Resources.Designer.cs └── Resources.resx ├── README.md ├── Resources └── github-mark24.png ├── WinCFScan.csproj ├── WinCFScan.sln ├── assets ├── Readme.txt ├── app-config.json ├── cf.local.iplist ├── v2ray-config │ ├── config.json.template │ └── config.real └── v2ray.exe ├── frmMain.Designer.cs ├── frmMain.cs └── frmMain.resx /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Classes/CFIPList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WinCFScan.Classes 8 | { 9 | // load cloudflare ip ranges from 'cf.local.iplist' file 10 | internal class CFIPList 11 | { 12 | protected string[] ipList { get; set; } 13 | 14 | public CFIPList(string fileName = "cf.local.iplist") 15 | { 16 | loadList(fileName); 17 | } 18 | 19 | private bool loadList(string fileName) 20 | { 21 | if (!File.Exists(fileName)) 22 | { 23 | return false; 24 | } 25 | 26 | string fileData = File.ReadAllText(fileName); 27 | 28 | ipList = fileData.Split(); 29 | 30 | return true; 31 | } 32 | 33 | public string[] getIPList() 34 | { 35 | return ipList; 36 | } 37 | 38 | public bool isIPListValid() 39 | { 40 | return ipList != null && ipList.Length > 0; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Classes/CheckIPWorking.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using WinCFScan.Classes.Config; 9 | using WinCFScan.Classes.HTTPRequest; 10 | 11 | namespace WinCFScan.Classes 12 | { 13 | internal class CheckIPWorking 14 | { 15 | private readonly string ip; 16 | private Process? process ; 17 | private string port; 18 | private string v2rayConfigPath; 19 | public long downloadDuration { get; private set; } 20 | 21 | public CheckIPWorking(string ip) 22 | { 23 | this.ip = ip; 24 | this.port = getPortByIP(); 25 | v2rayConfigPath = $"v2ray-config/generated/config.{ip}.json"; 26 | } 27 | 28 | public CheckIPWorking() 29 | { 30 | } 31 | 32 | public bool check() 33 | { 34 | // first of all quick test on fronting domain through cloudflare 35 | if(! checkFronting()) 36 | return false; 37 | 38 | // then test quality of connection by downloading small file through v2ray vpn 39 | return checkV2ray(); 40 | } 41 | 42 | public bool checkV2ray() { 43 | bool success = false; 44 | // create config 45 | if (createV2rayConfigFile()) 46 | { 47 | // start v2ray.exe process 48 | if (runV2rayProcess()) 49 | { 50 | // send download request 51 | if (checkDownloadSpeed()) 52 | { 53 | // speed was enough 54 | success = true; 55 | }; 56 | process.Kill(); 57 | } 58 | } 59 | return success; 60 | } 61 | 62 | private bool checkDownloadSpeed() 63 | { 64 | var proxy = new WebProxy(); 65 | proxy.Address = new Uri($"socks5://127.0.0.1:{port}"); 66 | var handler = new HttpClientHandler 67 | { 68 | Proxy = proxy 69 | }; 70 | 71 | var client = new HttpClient(handler); 72 | client.Timeout = TimeSpan.FromSeconds(2); // 2 seconds 73 | Stopwatch sw = new Stopwatch(); 74 | try 75 | { 76 | sw.Start(); 77 | string dlUrl = "https://" + ConfigManager.Instance.getAppConfig().scanDomain + "/data.100k"; 78 | var data = client.GetStringAsync(dlUrl).Result; 79 | 80 | return data.Length > 90_000; 81 | } 82 | catch (Exception ex) 83 | { 84 | return false; 85 | } 86 | finally 87 | { 88 | downloadDuration = sw.ElapsedMilliseconds; 89 | handler.Dispose(); 90 | client.Dispose(); 91 | } 92 | } 93 | 94 | private bool createV2rayConfigFile() 95 | { 96 | try 97 | { 98 | var configTemplate = ConfigManager.Instance.v2rayConfigTemplate; 99 | RealConfig realConfig = ConfigManager.Instance.getRealConfig(); 100 | 101 | configTemplate = configTemplate 102 | .Replace("IDID", realConfig.id) 103 | .Replace("PORTPORT", port) 104 | .Replace("HOSTHOST", realConfig.host) 105 | .Replace("CFPORTCFPORT", realConfig.port) 106 | .Replace("RANDOMHOST", realConfig.serverName) 107 | .Replace("IP.IP.IP.IP", this.ip) 108 | .Replace("ENDPOINTENDPOINT", realConfig.path); 109 | 110 | File.WriteAllText(v2rayConfigPath, configTemplate); 111 | 112 | return true; 113 | } 114 | catch (Exception) 115 | { 116 | return false; 117 | } 118 | 119 | } 120 | 121 | // sum of ip segments plus 3000 122 | private string getPortByIP() 123 | { 124 | int sum = Int32.Parse( 125 | this.ip.Split(".").Aggregate((current, next) => 126 | (Int32.Parse(current) + Int32.Parse(next)).ToString()) 127 | ); 128 | 129 | return (3000 + sum).ToString(); 130 | } 131 | 132 | private bool runV2rayProcess() 133 | { 134 | ProcessStartInfo startInfo = new ProcessStartInfo(); 135 | startInfo.FileName = "v2ray.exe"; 136 | startInfo.WindowStyle = ProcessWindowStyle.Hidden; 137 | startInfo.RedirectStandardOutput = true; 138 | startInfo.RedirectStandardError = true; 139 | startInfo.UseShellExecute = false; 140 | startInfo.CreateNoWindow = true; 141 | startInfo.Arguments = $"run -config=\"{v2rayConfigPath}\""; 142 | process = Process.Start(startInfo); 143 | Thread.Sleep(1500); 144 | return process.Responding && ! process.HasExited; 145 | } 146 | 147 | public bool checkFronting(bool withCstumDNSResolver = true, int timeout = 1) 148 | { 149 | DnsHandler dnsHandler; 150 | HttpClient client; 151 | if (withCstumDNSResolver) 152 | { 153 | dnsHandler = new DnsHandler(new CustomDnsResolver(ip)); 154 | client = new HttpClient(dnsHandler); 155 | } 156 | else 157 | { 158 | client = new HttpClient(); 159 | } 160 | 161 | //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 162 | client.Timeout = TimeSpan.FromSeconds(timeout); 163 | 164 | try 165 | { 166 | string frUrl = "https://" + ConfigManager.Instance.getAppConfig()?.frontDomain; 167 | var html = client.GetStringAsync(frUrl).Result; 168 | 169 | return true; 170 | } 171 | catch (Exception ex) 172 | { 173 | return false; 174 | } 175 | finally { 176 | client.Dispose(); 177 | } 178 | 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /Classes/Config/AppConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | 8 | namespace WinCFScan.Classes.Config 9 | { 10 | internal class AppConfig : ConfigInterface 11 | { 12 | protected string appConfigFileName = "app-config.json"; 13 | protected AppConfig? loadedInstance; 14 | 15 | public string frontDomain { get; set; } 16 | public string scanDomain { get; set; } 17 | public string configRealUrl { get; set; } 18 | 19 | // load app config 20 | public bool load() 21 | { 22 | try 23 | { 24 | if (!File.Exists(appConfigFileName)) 25 | { 26 | return false; 27 | } 28 | 29 | string jsonString = File.ReadAllText(appConfigFileName); 30 | loadedInstance = JsonSerializer.Deserialize(jsonString)!; 31 | 32 | } 33 | catch (Exception ex) 34 | { 35 | return false; 36 | } 37 | 38 | return isConfigValid(); 39 | } 40 | 41 | public bool isConfigValid() 42 | { 43 | return frontDomain != null && scanDomain != null && configRealUrl != null; 44 | } 45 | 46 | public AppConfig? getLoadedInstance() 47 | { 48 | return loadedInstance; 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Classes/Config/ConfigInterface.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WinCFScan.Classes.Config 8 | { 9 | internal interface ConfigInterface 10 | { 11 | bool isConfigValid(); 12 | bool load(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Classes/Config/ConfigManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | using WinCFScan.Classes.HTTPRequest; 8 | 9 | namespace WinCFScan.Classes.Config 10 | { 11 | internal class ConfigManager 12 | { 13 | protected string v2rayTemplateConfigFileName = "v2ray-config/config.json.template"; 14 | public string? v2rayConfigTemplate { get; private set; } 15 | protected string[] mandatoryDirectories = { "v2ray-config", "v2ray-config/generated", "results" }; //this dirs must be existed 16 | 17 | protected AppConfig? appConfig; 18 | protected RealConfig? realConfig; 19 | 20 | public string errorMessage { get; set; } = ""; 21 | protected bool loadedOK = true; 22 | 23 | public static ConfigManager? Instance { get; private set; } 24 | 25 | public ConfigManager() 26 | { 27 | if (this.load() && appConfig != null) 28 | { 29 | realConfig = new RealConfig(appConfig); 30 | } 31 | 32 | // set static instance for later access of this instance 33 | Instance = this; 34 | } 35 | 36 | protected bool load() 37 | { 38 | try 39 | { 40 | // create mandatory directories 41 | foreach (var dir in mandatoryDirectories) 42 | { 43 | if (!Directory.Exists(dir)); 44 | { 45 | Directory.CreateDirectory(dir); 46 | } 47 | } 48 | 49 | // app config 50 | appConfig = new AppConfig(); 51 | appConfig.load(); // this must be called 52 | appConfig = appConfig.getLoadedInstance(); 53 | 54 | // load v2ray config template 55 | if (!File.Exists(v2rayTemplateConfigFileName)) 56 | { 57 | errorMessage = "v2ray template config file is not exists at 'v2ray-config/config.json.template'"; 58 | loadedOK = false; 59 | return false; 60 | } 61 | 62 | v2rayConfigTemplate = File.ReadAllText(v2rayTemplateConfigFileName); 63 | 64 | // check existance of v2ray.exe 65 | if (!File.Exists("v2ray.exe")) 66 | { 67 | errorMessage = "v2ray.exe in not exists in app directory."; 68 | loadedOK = false; 69 | return false; 70 | } 71 | 72 | } 73 | catch(Exception ex) 74 | { 75 | errorMessage = ex.Message; 76 | return false; 77 | } 78 | 79 | return isConfigValid(); 80 | } 81 | 82 | public bool isConfigValid() 83 | { 84 | if(appConfig != null && appConfig.isConfigValid() && v2rayConfigTemplate != null && loadedOK) 85 | { 86 | return true; 87 | } 88 | 89 | return false; 90 | } 91 | 92 | 93 | public AppConfig? getAppConfig() 94 | { 95 | return this.appConfig; 96 | } 97 | 98 | public RealConfig? getRealConfig() 99 | { 100 | return this.realConfig; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Classes/Config/RealConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | 8 | namespace WinCFScan.Classes.Config 9 | { 10 | 11 | internal class RealConfig : ConfigInterface 12 | { 13 | public string id { get; private set; } 14 | public string host { get; private set; } 15 | public string port { get; private set; } 16 | public string path { get; private set; } 17 | public string serverName { get; private set; } 18 | 19 | protected string v2rayConfigRealFileName = "v2ray-config/config.real"; 20 | protected string v2rayGeneratedConfigDir = "v2ray-config/generated"; 21 | protected AppConfig appConfig; 22 | 23 | public RealConfig(AppConfig appConfig) 24 | { 25 | this.appConfig = appConfig; 26 | this.load(); 27 | } 28 | 29 | // load real config 30 | public bool load() 31 | { 32 | if (!File.Exists(v2rayConfigRealFileName)) 33 | { 34 | return false; 35 | } 36 | 37 | try 38 | { 39 | string[] lines = File.ReadAllLines(v2rayConfigRealFileName); 40 | foreach (string line in lines) 41 | { 42 | string[] parts = line.Split(": "); 43 | switch (parts[0].ToLower()) 44 | { 45 | case "id": 46 | this.id = parts[1]; 47 | break; 48 | case "host": 49 | this.host = parts[1]; 50 | break; 51 | case "port": 52 | this.port = parts[1]; 53 | break; 54 | case "path": 55 | this.path = parts[1]; 56 | break; 57 | case "servername": 58 | this.serverName = parts[1]; 59 | break; 60 | } 61 | } 62 | } 63 | catch (Exception ex) { 64 | return false; 65 | } 66 | 67 | return isConfigValid(); 68 | } 69 | 70 | public bool isConfigValid() 71 | { 72 | return this.id!= null && this.host != null && this.port != null && this.path != null && this.serverName != null; 73 | } 74 | 75 | // if 'config real' file is not exists or is too old then download it from remote 76 | public bool remoteUpdateConfigReal() 77 | { 78 | if (isConfigRealOld()) 79 | { 80 | deleteOldGeneratedConfigs(); 81 | 82 | // download fresh conf 83 | var client = new HttpClient(); 84 | try 85 | { 86 | client.Timeout = TimeSpan.FromSeconds(10); 87 | var html = client.GetStringAsync(this.appConfig.configRealUrl).Result; 88 | File.WriteAllText(v2rayConfigRealFileName, html); 89 | 90 | // reload 91 | this.load(); 92 | return true; 93 | 94 | } 95 | catch (Exception ex) 96 | { 97 | return false; 98 | } 99 | finally 100 | { 101 | client.Dispose(); 102 | } 103 | } 104 | 105 | return true; 106 | } 107 | 108 | private void deleteOldGeneratedConfigs() 109 | { 110 | try 111 | { 112 | var resultFiles = Directory.GetFiles(v2rayGeneratedConfigDir, "*.json"); 113 | foreach (var resultFile in resultFiles) 114 | { 115 | if (isFileOld(resultFile)) 116 | { 117 | File.Delete(resultFile); 118 | } 119 | } 120 | } 121 | catch (Exception) 122 | { 123 | 124 | } 125 | } 126 | 127 | private bool isFileOld(string file) 128 | { 129 | return (DateTime.Now - File.GetLastWriteTime(file)).TotalDays > 1; 130 | } 131 | 132 | public bool isConfigRealOld() 133 | { 134 | return !File.Exists(v2rayConfigRealFileName) || isFileOld(v2rayConfigRealFileName); 135 | } 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Classes/Config/ScanResults.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | 8 | namespace WinCFScan.Classes.Config 9 | { 10 | internal class ScanResults 11 | 12 | { 13 | public string? resultsFileName; 14 | private ScanResults loadedInstance; 15 | 16 | public DateTime startDate { get; set; } 17 | public DateTime endDate { get; set; } 18 | public int totalFoundWorkingIPs { get; set; } 19 | public ResultItem fastestIP; 20 | public List workingIPs { get; set; } 21 | 22 | private List unFetchedWorkingIPs { get; set; } 23 | private bool thereIsNewWorkingIPs = false; 24 | private int totalUnsavedWorkingIPs = 0; 25 | 26 | 27 | public ScanResults(string fileName) { 28 | workingIPs = new List(); 29 | unFetchedWorkingIPs = new List(); 30 | resultsFileName = fileName; 31 | } 32 | 33 | public ScanResults() : this("") {} 34 | 35 | // load app config 36 | public bool load() 37 | { 38 | try 39 | { 40 | if (!File.Exists(resultsFileName)) 41 | { 42 | return false; 43 | } 44 | 45 | string jsonString = File.ReadAllText(resultsFileName); 46 | loadedInstance = JsonSerializer.Deserialize(jsonString)!; 47 | 48 | } 49 | catch (Exception ex) 50 | { 51 | return false; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | public bool save(bool sortBeforeSave = true) 58 | { 59 | try 60 | { 61 | if (sortBeforeSave) 62 | { 63 | workingIPs = this.workingIPs.OrderBy(x => x.delay).ToList(); 64 | } 65 | endDate = DateTime.Now; 66 | JsonSerializerOptions options= new JsonSerializerOptions(); 67 | options.WriteIndented= true; 68 | string jsonString = JsonSerializer.Serialize(this, options); 69 | File.WriteAllText(resultsFileName, jsonString); 70 | totalUnsavedWorkingIPs = 0; 71 | } 72 | catch (Exception ex) 73 | { 74 | return false; 75 | } 76 | 77 | return true; 78 | } 79 | 80 | public ScanResults? getLoadedInstance() 81 | { 82 | return loadedInstance; 83 | } 84 | 85 | public void addIPResult(long delay, string ip ) 86 | { 87 | ResultItem resultItem = new ResultItem(delay, ip); 88 | workingIPs.Add(resultItem); 89 | unFetchedWorkingIPs.Add(new ResultItem(delay, ip)); 90 | thereIsNewWorkingIPs = true; 91 | totalFoundWorkingIPs++; 92 | totalUnsavedWorkingIPs++; 93 | if (fastestIP == null || resultItem.delay < fastestIP.delay) 94 | { 95 | fastestIP = resultItem; 96 | } 97 | } 98 | 99 | public void autoSave(int threshold = 10) 100 | { 101 | if(totalUnsavedWorkingIPs >= threshold) { 102 | save(true); 103 | } 104 | } 105 | 106 | public List? fetchWorkingIPs() 107 | { 108 | if (thereIsNewWorkingIPs) 109 | { 110 | List returnResult = unFetchedWorkingIPs; 111 | unFetchedWorkingIPs = new List(); 112 | thereIsNewWorkingIPs = false; 113 | return returnResult; 114 | } 115 | 116 | return null; 117 | } 118 | 119 | internal void remove() 120 | { 121 | try 122 | { 123 | File.Delete(this.resultsFileName); 124 | } 125 | catch(Exception ex) { } 126 | } 127 | } 128 | 129 | 130 | internal class ResultItem 131 | { 132 | public long delay { get; set; } 133 | public string ip { get; set; } 134 | 135 | public ResultItem(long delay = 0, string ip = "") 136 | { 137 | this.delay = delay; 138 | this.ip = ip; 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /Classes/HTTPRequest/DnsHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Security; 5 | using System.Reflection.Emit; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace WinCFScan.Classes.HTTPRequest 11 | { 12 | public class DnsHandler : HttpClientHandler 13 | { 14 | private readonly CustomDnsResolver _dnsResolver; 15 | 16 | public DnsHandler(CustomDnsResolver dnsResolver) 17 | { 18 | _dnsResolver = dnsResolver; 19 | } 20 | 21 | protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 22 | { 23 | // disable ssl cer check 24 | this.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; 25 | 26 | var host = request.RequestUri.Host; 27 | var ip = _dnsResolver.Resolve(host); 28 | 29 | // add host to header 30 | request.Headers.TryAddWithoutValidation("host", host); 31 | 32 | var builder = new UriBuilder(request.RequestUri); 33 | builder.Host = ip; 34 | 35 | request.RequestUri = builder.Uri; 36 | 37 | return base.SendAsync(request, cancellationToken); 38 | } 39 | } 40 | 41 | public class CustomDnsResolver 42 | { 43 | private readonly string resolveTo; 44 | public CustomDnsResolver(string resolveTo) 45 | { 46 | this.resolveTo = resolveTo; 47 | } 48 | 49 | public string Resolve(string host) 50 | { 51 | return resolveTo; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Classes/IP/IPAddressExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WinCFScan.Classes.IP 9 | { 10 | public static class IPAddressExtensions 11 | { 12 | public static List getIPRange(string ip, int network) 13 | { 14 | uint start, end, total; 15 | getIPRangeInfo(ip, network, out start, out end, out total); 16 | 17 | var ipRange = new List(); 18 | 19 | for (uint n = start; n < end; n++) 20 | { 21 | ipRange.Add(new IPAddress(BitConverter.GetBytes(n).Reverse().ToArray()).ToString()); 22 | } 23 | 24 | return ipRange; 25 | 26 | } 27 | 28 | public static uint getIPRangeTotalIPs (string ipAndNet) 29 | { 30 | string[] splitted = ipAndNet.Split('/'); 31 | getIPRangeInfo(splitted[0], Int32.Parse(splitted[1]), out uint start, out uint end, out uint total); 32 | return total; 33 | } 34 | 35 | 36 | public static void getIPRangeInfo(string ip, int network, out uint start, out uint end, out uint total) 37 | { 38 | IPAddress netAddr = SubnetMask.CreateByNetBitLength(network); 39 | byte[] mask = netAddr.GetAddressBytes(); 40 | byte[] iprev = IPAddress.Parse(ip).GetAddressBytes(); 41 | // Network id - network address 42 | byte[] netid = BitConverter.GetBytes(BitConverter.ToUInt32(iprev, 0) & BitConverter.ToUInt32(mask, 0)); 43 | // Binary inverted netmask 44 | byte[] inv_mask = mask.Select(r => (byte)~r).ToArray(); 45 | // Broadcast address 46 | byte[] brCast = BitConverter.GetBytes(BitConverter.ToUInt32(netid, 0) ^ BitConverter.ToUInt32(inv_mask, 0)); 47 | 48 | start = BitConverter.ToUInt32(netid.Reverse().ToArray(), 0) + 1; 49 | end = BitConverter.ToUInt32(brCast.Reverse().ToArray(), 0); 50 | total = end - start; 51 | } 52 | 53 | public static List getIPRange(string ipAndNet) 54 | { 55 | string[] splitted = ipAndNet.Split('/'); 56 | return getIPRange(splitted[0], Int32.Parse(splitted[1])); 57 | } 58 | 59 | 60 | public static IPAddress GetBroadcastAddress(this IPAddress address, IPAddress subnetMask) 61 | { 62 | byte[] ipAdressBytes = address.GetAddressBytes(); 63 | byte[] subnetMaskBytes = subnetMask.GetAddressBytes(); 64 | 65 | if (ipAdressBytes.Length != subnetMaskBytes.Length) 66 | throw new ArgumentException("Lengths of IP address and subnet mask do not match."); 67 | 68 | byte[] broadcastAddress = new byte[ipAdressBytes.Length]; 69 | for (int i = 0; i < broadcastAddress.Length; i++) 70 | { 71 | broadcastAddress[i] = (byte)(ipAdressBytes[i] | (subnetMaskBytes[i] ^ 255)); 72 | } 73 | return new IPAddress(broadcastAddress); 74 | } 75 | 76 | public static IPAddress GetNetworkAddress(this IPAddress address, IPAddress subnetMask) 77 | { 78 | byte[] ipAdressBytes = address.GetAddressBytes(); 79 | byte[] subnetMaskBytes = subnetMask.GetAddressBytes(); 80 | 81 | if (ipAdressBytes.Length != subnetMaskBytes.Length) 82 | throw new ArgumentException("Lengths of IP address and subnet mask do not match."); 83 | 84 | byte[] broadcastAddress = new byte[ipAdressBytes.Length]; 85 | for (int i = 0; i < broadcastAddress.Length; i++) 86 | { 87 | broadcastAddress[i] = (byte)(ipAdressBytes[i] & (subnetMaskBytes[i])); 88 | } 89 | return new IPAddress(broadcastAddress); 90 | } 91 | 92 | public static bool IsInSameSubnet(this IPAddress address2, IPAddress address, IPAddress subnetMask) 93 | { 94 | IPAddress network1 = address.GetNetworkAddress(subnetMask); 95 | IPAddress network2 = address2.GetNetworkAddress(subnetMask); 96 | 97 | return network1.Equals(network2); 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Classes/IP/SubnetMask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WinCFScan.Classes.IP 9 | { 10 | public static class SubnetMask 11 | { 12 | public static readonly IPAddress ClassA = IPAddress.Parse("255.0.0.0"); 13 | public static readonly IPAddress ClassB = IPAddress.Parse("255.255.0.0"); 14 | public static readonly IPAddress ClassC = IPAddress.Parse("255.255.255.0"); 15 | 16 | public static IPAddress CreateByHostBitLength(int hostpartLength) 17 | { 18 | int hostPartLength = hostpartLength; 19 | int netPartLength = 32 - hostPartLength; 20 | 21 | if (netPartLength < 2) 22 | throw new ArgumentException("Number of hosts is to large for IPv4"); 23 | 24 | Byte[] binaryMask = new byte[4]; 25 | 26 | for (int i = 0; i < 4; i++) 27 | { 28 | if (i * 8 + 8 <= netPartLength) 29 | binaryMask[i] = (byte)255; 30 | else if (i * 8 > netPartLength) 31 | binaryMask[i] = (byte)0; 32 | else 33 | { 34 | int oneLength = netPartLength - i * 8; 35 | string binaryDigit = 36 | String.Empty.PadLeft(oneLength, '1').PadRight(8, '0'); 37 | binaryMask[i] = Convert.ToByte(binaryDigit, 2); 38 | } 39 | } 40 | return new IPAddress(binaryMask); 41 | } 42 | 43 | public static IPAddress CreateByNetBitLength(int netpartLength) 44 | { 45 | int hostPartLength = 32 - netpartLength; 46 | return CreateByHostBitLength(hostPartLength); 47 | } 48 | 49 | public static IPAddress CreateByHostNumber(int numberOfHosts) 50 | { 51 | int maxNumber = numberOfHosts + 1; 52 | 53 | string b = Convert.ToString(maxNumber, 2); 54 | 55 | return CreateByHostBitLength(b.Length); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Classes/LogControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WinCFScan.Classes 8 | { 9 | public class LogControl 10 | { 11 | private static string _Path = string.Empty; 12 | private static bool DEBUG = true; 13 | 14 | public static void Write(string msg) 15 | { 16 | _Path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); 17 | try 18 | { 19 | using (StreamWriter w = File.AppendText(Path.Combine(_Path, "log.txt"))) 20 | { 21 | Log(msg, w); 22 | } 23 | if (DEBUG) 24 | Console.WriteLine(msg); 25 | } 26 | catch (Exception e) 27 | { 28 | //Handle 29 | } 30 | } 31 | 32 | static private void Log(string msg, TextWriter w) 33 | { 34 | try 35 | { 36 | //w.Write(Environment.NewLine); 37 | w.Write(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); 38 | w.WriteLine(" {0}", msg); 39 | } 40 | catch (Exception e) 41 | { 42 | //Handle 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Classes/ScanEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using WinCFScan.Classes.Config; 10 | using WinCFScan.Classes.HTTPRequest; 11 | using WinCFScan.Classes.IP; 12 | 13 | namespace WinCFScan.Classes 14 | { 15 | internal class ScanEngine 16 | { 17 | protected string errMessage = ""; 18 | protected bool hasError = false; 19 | 20 | public string[] cfIPList; 21 | public ScanProgressInfo progressInfo { get; protected set; } 22 | private CancellationTokenSource cts; 23 | public List? workingIPsFromPrevScan { get; set; } 24 | public int concurrentProcess = 4; 25 | 26 | public ScanEngine() 27 | { 28 | resetProgressInfo(); 29 | // load cf ip list 30 | loadCFIPList(); 31 | } 32 | 33 | public bool start(ScanType scanType = ScanType.SCAN_CLOUDFLARE_IPS) 34 | { 35 | if(progressInfo.isScanRunning) { 36 | return false; 37 | } 38 | 39 | resetProgressInfo(); 40 | 41 | progressInfo.isScanRunning = true; 42 | progressInfo.scanResults = new Config.ScanResults( "results/" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-results.json"); 43 | progressInfo.scanResults.startDate = DateTime.Now; 44 | 45 | if (scanType == ScanType.SCAN_CLOUDFLARE_IPS) 46 | scanInCfIPRanges(); 47 | else 48 | scanInPervResults(); 49 | 50 | 51 | progressInfo.isScanRunning = false; 52 | 53 | return true; 54 | } 55 | 56 | // scan in previous scan result 57 | private void scanInPervResults() 58 | { 59 | progressInfo.totalIPRanges = 1; 60 | 61 | if (workingIPsFromPrevScan == null) 62 | return; 63 | 64 | var listIP = workingIPsFromPrevScan.Select(x => x.ip).ToList(); 65 | progressInfo.currentIPRangeTotalIPs = listIP.Count; 66 | 67 | LogControl.Write($"Start scanning {listIP.Count:n0} ip in on previous scan results"); 68 | Stopwatch sw = Stopwatch.StartNew(); 69 | parallelScan(listIP); 70 | LogControl.Write($"End of scanning {listIP.Count:n0} ip in {sw.Elapsed.TotalSeconds:n0} sec\n"); 71 | progressInfo.currentIPRangesNumber = 1; 72 | } 73 | 74 | // scan in all cloudflare ip range 75 | private void scanInCfIPRanges() 76 | { 77 | 78 | if (hasError) 79 | return; 80 | 81 | progressInfo.totalIPRanges = cfIPList.Count(); 82 | 83 | foreach (var cfIP in cfIPList) 84 | { 85 | // stop scan? 86 | if (progressInfo.stopRequested == true) 87 | { 88 | break; 89 | } 90 | 91 | progressInfo.totalCheckedIPInCurIPRange = 0; 92 | 93 | if (isValidIPRange(cfIP)) 94 | { 95 | List ipRange = IPAddressExtensions.getIPRange(cfIP); 96 | progressInfo.currentIPRange = cfIP; 97 | progressInfo.currentIPRangeTotalIPs = ipRange.Count(); 98 | LogControl.Write(String.Format("Start scanning {0} ip in {1}", ipRange.Count, cfIP)); 99 | Stopwatch sw = Stopwatch.StartNew(); 100 | parallelScan(ipRange); 101 | LogControl.Write(String.Format("End of scanning {0} {1} ip in {2} sec\n\n", cfIP, ipRange.Count, sw.Elapsed.TotalSeconds)); 102 | 103 | progressInfo.currentIPRangesNumber++; 104 | 105 | // skip current range? 106 | if (progressInfo.skipCurrentIPRange == true) 107 | { 108 | LogControl.Write(String.Format("IP range skipped by user {0}", cfIP)); 109 | progressInfo.skipCurrentIPRange = false; 110 | } 111 | } 112 | } 113 | } 114 | 115 | public void setCFIPRangeList(string[] list) 116 | { 117 | this.cfIPList = list; 118 | } 119 | 120 | private bool isValidIPRange(string cfIP) 121 | { 122 | return cfIP != "" && cfIP.Contains('/') && cfIP.Contains('.'); 123 | } 124 | 125 | private void parallelScan(List ipRange) 126 | { 127 | //var bag = new ConcurrentBag(); 128 | cts = new CancellationTokenSource(); 129 | ParallelOptions po = new ParallelOptions(); 130 | po.CancellationToken = cts.Token; 131 | po.MaxDegreeOfParallelism = concurrentProcess; //System.Environment.ProcessorCount; 132 | 133 | try 134 | { 135 | Parallel.ForEach(ipRange, po, (ip) => 136 | { 137 | var checker = new CheckIPWorking(ip); 138 | bool isOK = checker.check(); 139 | 140 | progressInfo.lastCheckedIP = ip; 141 | progressInfo.totalCheckedIPInCurIPRange++; 142 | progressInfo.totalCheckedIP++; 143 | 144 | //Thread.Sleep(1); 145 | LogControl.Write($"{ip} is {isOK.ToString()} , dl in {checker.downloadDuration:n0} ms"); 146 | 147 | if (isOK) 148 | { 149 | progressInfo.scanResults.addIPResult(checker.downloadDuration, ip); 150 | //bag.Add(ip); 151 | } 152 | } 153 | ); 154 | } 155 | catch (OperationCanceledException ex) 156 | { 157 | 158 | } 159 | finally 160 | { 161 | cts.Dispose(); 162 | } 163 | } 164 | 165 | protected void resetProgressInfo() 166 | { 167 | progressInfo = new ScanProgressInfo(); 168 | } 169 | 170 | 171 | private void loadCFIPList() 172 | { 173 | CFIPList ipList = new CFIPList(); 174 | if(ipList.isIPListValid()) 175 | this.cfIPList = ipList.getIPList(); 176 | else 177 | { 178 | progressInfo.lastErrMessage = "Invalid couldflare IP list"; 179 | progressInfo.hasError = true; 180 | } 181 | } 182 | 183 | 184 | internal void stop() 185 | { 186 | if(progressInfo.isScanRunning) 187 | { 188 | progressInfo.stopRequested = true; 189 | cts.Cancel(); 190 | } 191 | } 192 | 193 | public void skipCurrentIPRange() { 194 | progressInfo.skipCurrentIPRange = true; 195 | cts.Cancel(); 196 | } 197 | } 198 | 199 | enum ScanType 200 | { 201 | SCAN_CLOUDFLARE_IPS, 202 | SCAN_IN_PERV_RESULTS 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /Classes/ScanProgressInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using WinCFScan.Classes.Config; 7 | 8 | namespace WinCFScan.Classes 9 | { 10 | internal class ScanProgressInfo 11 | { 12 | public bool isScanRunning = false; 13 | public string currentIPRange = ""; 14 | public string lastErrMessage = ""; 15 | public bool hasError = false; 16 | public bool stopRequested = false; // is requested to stop scan 17 | internal string lastCheckedIP; 18 | internal ScanResults scanResults; 19 | internal bool skipCurrentIPRange; 20 | internal int totalIPRanges; 21 | internal int currentIPRangesNumber = 0; 22 | internal int currentIPRangeTotalIPs = 0; 23 | internal int totalCheckedIPInCurIPRange = 0; 24 | internal int totalCheckedIP = 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | namespace WinCFScan 2 | { 3 | internal static class Program 4 | { 5 | /// 6 | /// The main entry point for the application. 7 | /// 8 | [STAThread] 9 | static void Main() 10 | { 11 | // To customize application configuration such as set high DPI settings or default font, 12 | // see https://aka.ms/applicationconfiguration. 13 | ApplicationConfiguration.Initialize(); 14 | Application.Run(new frmMain()); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WinCFScan.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinCFScan.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap github_mark24 { 67 | get { 68 | object obj = ResourceManager.GetObject("github-mark24", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\github-mark24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Continue here 2 | This repo is marked as archive and we continue this application in here: 3 | 4 | [Morteza CFScanner](https://github.com/MortezaBashsiz/CFScanner) 5 | 6 | See Windows section on that repo. 7 | 8 | # Cloudflare IP scan on Windows 9 | ![screen](https://user-images.githubusercontent.com/126115050/220948247-711c972c-0b86-4131-82c1-437e461daa6e.png) 10 | 11 | ## About 12 | This tool help you to scan all IP ranges of Cloudflare to find clean and working ones. 13 | 14 | Inspired by [Morteza CFScanner](https://github.com/MortezaBashsiz/CFScanner) 15 | 16 | ## Features 17 | * Scan all Cloudflare IP ranges and find fastest IP addresses. 18 | * Save scan results and ability to scan in previous results. 19 | * Scan a single IP address. 20 | * Fast and concurrent scan. 21 | * Selectable IP ranges and ability to skip current IP range. 22 | * User friendly and easy to use. 23 | 24 | ## Requirements 25 | To run this app you need to have `.NET Desktop Runtime 6` installed on your Windows which is normally installed on newer versions of Windows. 26 | However if you don't already have it installed on your pc then you can download it from here: 27 | 28 | Look for **.NET Desktop Runtime 6** in download page: 29 | ``` 30 | https://dotnet.microsoft.com/en-us/download/dotnet/6.0 31 | ``` 32 | 33 | Or use this direct links: 34 | 35 | For 64 bit Windows: 36 | ``` 37 | https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.14-windows-x64-installer 38 | ``` 39 | For 32 bit Windows: 40 | ``` 41 | https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-6.0.14-windows-x86-installer 42 | ``` 43 | 44 | ## How to use 45 | Just download latest release from `release` section and extract zip file to disk, then run `WinCFScan.exe`. 46 | 47 | ## Other notes 48 | * In `Scan Results` tab you can right click on an IP and **Copy** IP address and also you can click on `Test this IP address` menu to test just one IP address. 49 | 50 | ![right](https://user-images.githubusercontent.com/126115050/220962263-429eda22-2987-441c-81e2-9c448bbb026e.png) 51 | 52 | * Here also you can load saved previous results and scan only on those IPs by clicking on `Scan in results` button. 53 | * You can set number of concurrent scan process to speed up your scan but be careful about using large values. Set it base on your CPU threads and also your connection speed. High number of concurrent processes might lead to scan timeout and loose some of working IPs. 54 | 55 | ## Build and compile 56 | Only advanced users: 57 | 58 | If you want to build and compile it yourself then download source code to your pc and open `WinCFScan.sln` file in `Visual Studio 2022`. 59 | Then you can build it from Build menu. After that you **must** copy content of `assets` folder into executable folder which usually is something like `bin/Debug/net6.0-windows`. 60 | 61 | # Disclaimer 62 | This app is provided as is, and we make no warranties or guarantees about its performance or suitability for your specific needs. Use at your own risk. 63 | 64 | 65 | Have fun and give us feedback. 66 | -------------------------------------------------------------------------------- /Resources/github-mark24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goingfine/WinCFScan/f3ea428ff68d7ae03245df71bfd73d0b2647a4f4/Resources/github-mark24.png -------------------------------------------------------------------------------- /WinCFScan.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | enable 9 | 1.0.* 10 | false 11 | 12 | 13 | 14 | 15 | True 16 | True 17 | Resources.resx 18 | 19 | 20 | 21 | 22 | 23 | ResXFileCodeGenerator 24 | Resources.Designer.cs 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /WinCFScan.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33403.182 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinCFScan", "WinCFScan.csproj", "{4CADB7B9-1CF1-4136-A910-7BCCDD0BE09D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {4CADB7B9-1CF1-4136-A910-7BCCDD0BE09D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {4CADB7B9-1CF1-4136-A910-7BCCDD0BE09D}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {4CADB7B9-1CF1-4136-A910-7BCCDD0BE09D}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {4CADB7B9-1CF1-4136-A910-7BCCDD0BE09D}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {57AE3044-4D7F-4818-8F61-5D3B2F5F947F} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /assets/Readme.txt: -------------------------------------------------------------------------------- 1 | After compiling project, copy this files in the folder of app executable. 2 | it is usualy in bin\Debug\net6.0-windows\ or bin\Release\net6.0-windows -------------------------------------------------------------------------------- /assets/app-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "frontDomain": "fronting.sudoer.net", 3 | "scanDomain": "scan.sudoer.net", 4 | "configRealUrl": "http://bot.sudoer.net/config.real" 5 | } -------------------------------------------------------------------------------- /assets/cf.local.iplist: -------------------------------------------------------------------------------- 1 | 159.246.55.0/24 2 | 104.30.2.0/23 3 | 23.227.37.0/24 4 | 23.227.38.0/23 5 | 23.227.60.0/24 6 | 64.68.192.0/24 7 | 65.110.63.0/24 8 | 66.235.200.0/24 9 | 68.67.65.0/24 10 | 91.234.214.0/24 11 | 103.21.244.0/24 12 | 103.22.201.0/24 13 | 103.22.202.0/23 14 | 103.81.228.0/24 15 | 104.16.0.0/13 16 | 104.24.0.0/14 17 | 104.28.0.0/15 18 | 104.30.1.0/24 19 | 104.30.4.0/22 20 | 104.30.8.0/21 21 | 104.30.16.0/20 22 | 104.30.32.0/19 23 | 104.30.64.0/18 24 | 104.30.128.0/17 25 | 104.31.0.0/16 26 | 108.162.192.0/20 27 | 108.162.210.0/23 28 | 108.162.212.0/23 29 | 108.162.216.0/23 30 | 108.162.218.0/24 31 | 108.162.235.0/24 32 | 108.162.236.0/22 33 | 108.162.240.0/21 34 | 108.162.248.0/23 35 | 108.162.250.0/24 36 | 108.162.255.0/24 37 | 141.101.65.0/24 38 | 141.101.66.0/23 39 | 141.101.68.0/22 40 | 141.101.72.0/22 41 | 141.101.76.0/23 42 | 141.101.82.0/23 43 | 141.101.84.0/22 44 | 141.101.90.0/24 45 | 141.101.92.0/22 46 | 141.101.96.0/21 47 | 141.101.106.0/23 48 | 141.101.108.0/23 49 | 141.101.110.0/24 50 | 141.101.112.0/20 51 | 162.158.0.0/22 52 | 162.158.4.0/23 53 | 162.158.8.0/21 54 | 162.158.16.0/20 55 | 162.158.32.0/22 56 | 162.158.36.0/23 57 | 162.158.38.0/24 58 | 162.158.40.0/21 59 | 162.158.48.0/24 60 | 162.158.51.0/24 61 | 162.158.52.0/22 62 | 162.158.56.0/22 63 | 162.158.60.0/24 64 | 162.158.62.0/23 65 | 162.158.72.0/21 66 | 162.158.80.0/23 67 | 162.158.82.0/24 68 | 162.158.84.0/22 69 | 162.158.88.0/21 70 | 162.158.96.0/21 71 | 162.158.108.0/22 72 | 162.158.112.0/23 73 | 162.158.114.0/24 74 | 162.158.117.0/24 75 | 162.158.118.0/23 76 | 162.158.124.0/22 77 | 162.158.128.0/19 78 | 162.158.160.0/20 79 | 162.158.176.0/24 80 | 162.158.178.0/23 81 | 162.158.180.0/22 82 | 162.158.184.0/22 83 | 162.158.191.0/24 84 | 162.158.192.0/22 85 | 162.158.196.0/24 86 | 162.158.198.0/23 87 | 162.158.200.0/21 88 | 162.158.208.0/22 89 | 162.158.212.0/24 90 | 162.158.214.0/23 91 | 162.158.216.0/21 92 | 162.158.224.0/20 93 | 162.158.240.0/21 94 | 162.158.248.0/22 95 | 162.158.253.0/24 96 | 162.158.255.0/24 97 | 162.159.0.0/18 98 | 162.159.64.0/21 99 | 162.159.72.0/22 100 | 162.159.76.0/23 101 | 162.159.78.0/24 102 | 162.159.128.0/17 103 | 162.251.82.0/24 104 | 172.64.0.0/15 105 | 172.66.0.0/22 106 | 172.66.40.0/21 107 | 172.67.0.0/16 108 | 172.68.0.0/19 109 | 172.68.32.0/21 110 | 172.68.40.0/22 111 | 172.68.45.0/24 112 | 172.68.46.0/23 113 | 172.68.48.0/20 114 | 172.68.64.0/20 115 | 172.68.80.0/23 116 | 172.68.83.0/24 117 | 172.68.84.0/22 118 | 172.68.88.0/21 119 | 172.68.96.0/20 120 | 172.68.112.0/21 121 | 172.68.120.0/23 122 | 172.68.123.0/24 123 | 172.68.124.0/22 124 | 172.68.128.0/21 125 | 172.68.136.0/22 126 | 172.68.140.0/23 127 | 172.68.142.0/24 128 | 172.68.144.0/21 129 | 172.68.152.0/22 130 | 172.68.161.0/24 131 | 172.68.162.0/23 132 | 172.68.164.0/22 133 | 172.68.168.0/21 134 | 172.68.176.0/23 135 | 172.68.179.0/24 136 | 172.68.180.0/22 137 | 172.68.184.0/21 138 | 172.68.196.0/22 139 | 172.68.200.0/21 140 | 172.68.208.0/21 141 | 172.68.217.0/24 142 | 172.68.218.0/23 143 | 172.68.220.0/22 144 | 172.68.224.0/20 145 | 172.68.240.0/21 146 | 172.68.248.0/22 147 | 172.68.252.0/23 148 | 172.68.255.0/24 149 | 172.69.0.0/20 150 | 172.69.16.0/24 151 | 172.69.18.0/23 152 | 172.69.20.0/22 153 | 172.69.32.0/20 154 | 172.69.48.0/24 155 | 172.69.52.0/22 156 | 172.69.56.0/21 157 | 172.69.64.0/22 158 | 172.69.72.0/21 159 | 172.69.80.0/20 160 | 172.69.96.0/21 161 | 172.69.105.0/24 162 | 172.69.106.0/23 163 | 172.69.108.0/22 164 | 172.69.112.0/21 165 | 172.69.124.0/22 166 | 172.69.128.0/20 167 | 172.69.144.0/21 168 | 172.69.156.0/22 169 | 172.69.160.0/19 170 | 172.69.192.0/20 171 | 172.69.208.0/24 172 | 172.69.210.0/23 173 | 172.69.212.0/22 174 | 172.69.216.0/21 175 | 172.69.224.0/23 176 | 172.69.227.0/24 177 | 172.69.228.0/22 178 | 172.69.232.0/21 179 | 172.69.240.0/21 180 | 172.69.248.0/24 181 | 172.69.250.0/23 182 | 172.69.252.0/22 183 | 172.70.32.0/20 184 | 172.70.48.0/23 185 | 172.70.51.0/24 186 | 172.70.52.0/22 187 | 172.70.56.0/21 188 | 172.70.80.0/20 189 | 172.70.96.0/20 190 | 172.70.112.0/22 191 | 172.70.116.0/23 192 | 172.70.120.0/21 193 | 172.70.128.0/21 194 | 172.70.136.0/23 195 | 172.70.139.0/24 196 | 172.70.140.0/22 197 | 172.70.144.0/22 198 | 172.70.148.0/23 199 | 172.70.150.0/24 200 | 172.70.152.0/22 201 | 172.70.156.0/23 202 | 172.70.158.0/24 203 | 172.70.160.0/22 204 | 172.70.172.0/22 205 | 172.70.176.0/21 206 | 172.70.185.0/24 207 | 172.70.186.0/23 208 | 172.70.188.0/22 209 | 172.70.192.0/18 210 | 172.71.0.0/24 211 | 172.71.2.0/23 212 | 172.71.4.0/22 213 | 172.71.8.0/21 214 | 172.71.16.0/23 215 | 172.71.20.0/22 216 | 172.71.24.0/21 217 | 172.71.80.0/21 218 | 172.71.88.0/23 219 | 172.71.90.0/24 220 | 172.71.92.0/22 221 | 172.71.96.0/21 222 | 172.71.108.0/22 223 | 172.71.112.0/20 224 | 172.71.128.0/21 225 | 172.71.137.0/24 226 | 172.71.138.0/23 227 | 172.71.140.0/22 228 | 172.71.144.0/20 229 | 172.71.160.0/19 230 | 172.71.192.0/18 231 | 173.245.49.0/24 232 | 173.245.54.0/24 233 | 173.245.58.0/23 234 | 173.245.63.0/24 235 | 185.146.172.0/23 236 | 188.114.96.0/22 237 | 188.114.100.0/24 238 | 188.114.102.0/23 239 | 188.114.106.0/23 240 | 188.114.108.0/24 241 | 188.114.111.0/24 242 | 190.93.240.0/20 243 | 195.242.122.0/23 244 | 197.234.240.0/22 245 | 198.41.129.0/24 246 | 198.41.192.0/20 247 | 198.41.208.0/23 248 | 198.41.211.0/24 249 | 198.41.212.0/24 250 | 198.41.214.0/23 251 | 198.41.216.0/21 252 | 198.41.224.0/21 253 | 198.41.232.0/23 254 | 198.41.236.0/22 255 | 198.41.240.0/23 256 | 198.41.242.0/24 257 | 198.217.251.0/24 258 | 199.27.128.0/22 259 | 199.27.132.0/24 260 | 5.226.179.0/24 261 | 5.226.181.0/24 262 | 12.221.133.0/24 263 | 23.141.168.0/24 264 | 23.178.112.0/24 265 | 23.247.163.0/24 266 | 31.43.179.0/24 267 | 38.67.242.0/24 268 | 45.8.104.0/22 269 | 45.8.211.0/24 270 | 45.12.30.0/23 271 | 45.14.174.0/24 272 | 45.80.111.0/24 273 | 45.84.59.0/24 274 | 45.85.118.0/23 275 | 45.87.175.0/24 276 | 45.94.169.0/24 277 | 45.95.241.0/24 278 | 45.131.4.0/22 279 | 45.131.208.0/22 280 | 45.133.247.0/24 281 | 45.137.99.0/24 282 | 45.142.120.0/24 283 | 45.145.28.0/23 284 | 45.158.56.0/24 285 | 45.159.216.0/22 286 | 64.21.2.0/24 287 | 65.205.150.0/24 288 | 66.81.247.0/24 289 | 66.81.255.0/24 290 | 72.52.113.0/24 291 | 80.94.83.0/24 292 | 89.47.56.0/23 293 | 89.116.250.0/24 294 | 89.207.18.0/24 295 | 91.192.107.0/24 296 | 91.193.58.0/23 297 | 91.195.110.0/24 298 | 91.199.81.0/24 299 | 93.114.64.0/23 300 | 95.214.178.0/23 301 | 103.11.212.0/24 302 | 103.11.214.0/24 303 | 103.79.228.0/23 304 | 103.112.176.0/24 305 | 103.121.59.0/24 306 | 103.156.22.0/23 307 | 103.160.204.0/24 308 | 103.168.172.0/24 309 | 103.169.142.0/24 310 | 103.172.111.0/24 311 | 154.84.175.0/24 312 | 103.204.13.0/24 313 | 103.244.116.0/22 314 | 154.85.9.0/24 315 | 104.234.158.0/24 316 | 104.254.140.0/24 317 | 108.165.216.0/24 318 | 154.85.99.0/24 319 | 123.253.174.0/24 320 | 141.11.194.0/23 321 | 141.193.213.0/24 322 | 146.19.22.0/24 323 | 147.78.121.0/24 324 | 147.78.140.0/24 325 | 147.185.161.0/24 326 | 154.51.129.0/24 327 | 154.51.160.0/24 328 | 154.83.2.0/24 329 | 154.83.22.0/24 330 | 154.83.30.0/24 331 | 154.84.14.0/23 332 | 154.84.16.0/24 333 | 154.84.20.0/23 334 | 154.84.24.0/24 335 | 154.84.26.0/23 336 | 154.219.3.0/24 337 | 156.237.4.0/23 338 | 156.238.14.0/24 339 | 156.238.18.0/23 340 | 156.239.152.0/23 341 | 156.239.154.0/24 342 | 159.112.235.0/24 343 | 159.246.55.0/24 344 | 160.153.0.0/24 345 | 162.44.104.0/22 346 | 168.100.6.0/24 347 | 170.114.45.0/24 348 | 170.114.46.0/24 349 | 170.114.52.0/24 350 | 172.83.72.0/23 351 | 172.83.76.0/24 352 | 185.207.92.0/24 353 | 174.136.134.0/24 354 | 176.126.206.0/23 355 | 185.7.190.0/23 356 | 185.18.250.0/24 357 | 185.38.135.0/24 358 | 185.59.218.0/24 359 | 185.67.124.0/24 360 | 185.72.49.0/24 361 | 185.109.21.0/24 362 | 185.135.9.0/24 363 | 185.148.104.0/22 364 | 185.162.228.0/22 365 | 185.170.166.0/24 366 | 185.174.138.0/24 367 | 185.176.24.0/24 368 | 185.176.26.0/24 369 | 185.193.28.0/22 370 | 185.201.139.0/24 371 | 185.213.240.0/24 372 | 185.213.243.0/24 373 | 185.221.160.0/24 374 | 185.234.22.0/24 375 | 185.238.228.0/24 376 | 185.244.106.0/24 377 | 188.42.88.0/23 378 | 188.244.122.0/24 379 | 191.101.251.0/24 380 | 192.65.217.0/24 381 | 192.133.11.0/24 382 | 193.9.49.0/24 383 | 193.16.63.0/24 384 | 193.17.206.0/24 385 | 193.67.144.0/24 386 | 193.188.14.0/24 387 | 193.227.99.0/24 388 | 194.1.194.0/24 389 | 194.36.49.0/24 390 | 194.36.55.0/24 391 | 194.36.216.0/22 392 | 194.40.240.0/23 393 | 194.53.53.0/24 394 | 194.152.44.0/24 395 | 194.169.194.0/24 396 | 195.85.23.0/24 397 | 195.85.59.0/24 398 | 195.137.167.0/24 399 | 195.245.221.0/24 400 | 196.13.241.0/24 401 | 196.207.45.0/24 402 | 199.60.103.0/24 403 | 199.181.197.0/24 404 | 199.212.90.0/24 405 | 202.82.250.0/24 406 | 203.13.32.0/24 407 | 203.17.126.0/24 408 | 203.19.222.0/24 409 | 203.22.223.0/24 410 | 203.23.103.0/24 411 | 203.23.104.0/24 412 | 203.23.106.0/24 413 | 203.24.102.0/23 414 | 203.24.108.0/23 415 | 203.28.8.0/23 416 | 203.29.52.0/22 417 | 203.30.188.0/22 418 | 203.32.120.0/23 419 | 203.34.28.0/24 420 | 203.34.80.0/24 421 | 203.55.107.0/24 422 | 203.89.5.0/24 423 | 203.107.173.0/24 424 | 203.193.21.0/24 425 | 204.62.141.0/24 426 | 204.68.111.0/24 427 | 204.209.72.0/23 428 | 205.233.181.0/24 429 | 206.196.23.0/24 430 | 207.189.149.0/24 431 | 208.100.60.0/24 432 | 212.24.127.0/24 433 | 212.110.134.0/23 434 | 212.239.86.0/24 435 | 216.120.180.0/23 436 | -------------------------------------------------------------------------------- /assets/v2ray-config/config.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "inbounds": [{ 3 | "port": PORTPORT, 4 | "listen": "127.0.0.1", 5 | "tag": "socks-inbound", 6 | "protocol": "socks", 7 | "settings": { 8 | "auth": "noauth", 9 | "udp": false, 10 | "ip": "127.0.0.1" 11 | }, 12 | "sniffing": { 13 | "enabled": true, 14 | "destOverride": ["http", "tls"] 15 | } 16 | }], 17 | "outbounds": [ 18 | { 19 | "protocol": "vmess", 20 | "settings": { 21 | "vnext": [{ 22 | "address": "IP.IP.IP.IP", 23 | "port": 443, 24 | "users": [{"id": "IDID" }] 25 | }] 26 | }, 27 | "streamSettings": { 28 | "network": "ws", 29 | "security": "tls", 30 | "wsSettings": { 31 | "headers": { 32 | "Host": "HOSTHOST" 33 | }, 34 | "path": "ENDPOINTENDPOINT" 35 | }, 36 | "tlsSettings": { 37 | "serverName": "RANDOMHOST", 38 | "allowInsecure": false 39 | } 40 | } 41 | }], 42 | "other": {} 43 | } 44 | -------------------------------------------------------------------------------- /assets/v2ray-config/config.real: -------------------------------------------------------------------------------- 1 | id: 248ecb72-89cf-5be7-923f-b790fca681c5 2 | Host: scherehtzhel01.sudoer.net 3 | Port: 443 4 | path: api01 5 | serverName: 248ecb72-89cf-5be7-923f-b790fca681c5.sudoer.net 6 | -------------------------------------------------------------------------------- /assets/v2ray.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goingfine/WinCFScan/f3ea428ff68d7ae03245df71bfd73d0b2647a4f4/assets/v2ray.exe -------------------------------------------------------------------------------- /frmMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WinCFScan 2 | { 3 | partial class frmMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.btnStart = new System.Windows.Forms.Button(); 33 | this.txtLog = new System.Windows.Forms.TextBox(); 34 | this.timerBase = new System.Windows.Forms.Timer(this.components); 35 | this.prgOveral = new System.Windows.Forms.ProgressBar(); 36 | this.prgCurRange = new System.Windows.Forms.ProgressBar(); 37 | this.btnSkipCurRange = new System.Windows.Forms.Button(); 38 | this.labelLastIPChecked = new System.Windows.Forms.Label(); 39 | this.lblLastIPRange = new System.Windows.Forms.Label(); 40 | this.timerProgress = new System.Windows.Forms.Timer(this.components); 41 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 42 | this.linkGithub = new System.Windows.Forms.LinkLabel(); 43 | this.btnCopyFastestIP = new System.Windows.Forms.Button(); 44 | this.txtFastestIP = new System.Windows.Forms.TextBox(); 45 | this.lblFastestIP = new System.Windows.Forms.Label(); 46 | this.comboConcurrent = new System.Windows.Forms.ComboBox(); 47 | this.lblConcurrent = new System.Windows.Forms.Label(); 48 | this.lblTotalWorkingIPs = new System.Windows.Forms.Label(); 49 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 50 | this.comboResults = new System.Windows.Forms.ComboBox(); 51 | this.btnScanInPrevResults = new System.Windows.Forms.Button(); 52 | this.listResults = new System.Windows.Forms.ListView(); 53 | this.hdrDelay = new System.Windows.Forms.ColumnHeader(); 54 | this.hdrIP = new System.Windows.Forms.ColumnHeader(); 55 | this.mnuListView = new System.Windows.Forms.ContextMenuStrip(this.components); 56 | this.mnuListViewCopyIP = new System.Windows.Forms.ToolStripMenuItem(); 57 | this.mnuListViewTestThisIPAddress = new System.Windows.Forms.ToolStripMenuItem(); 58 | this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 59 | this.tabControl1 = new System.Windows.Forms.TabControl(); 60 | this.tabPageCFRanges = new System.Windows.Forms.TabPage(); 61 | this.lblCFIPListStatus = new System.Windows.Forms.Label(); 62 | this.btnSelectNoneIPRanges = new System.Windows.Forms.Button(); 63 | this.btnSelectAllIPRanges = new System.Windows.Forms.Button(); 64 | this.listCFIPList = new System.Windows.Forms.ListView(); 65 | this.headIPRange = new System.Windows.Forms.ColumnHeader(); 66 | this.headTotalIPs = new System.Windows.Forms.ColumnHeader(); 67 | this.tabPageResults = new System.Windows.Forms.TabPage(); 68 | this.lblPrevListTotalIPs = new System.Windows.Forms.Label(); 69 | this.lblPrevResults = new System.Windows.Forms.Label(); 70 | this.btnDeleteResult = new System.Windows.Forms.Button(); 71 | this.groupBox1.SuspendLayout(); 72 | this.mnuListView.SuspendLayout(); 73 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 74 | this.splitContainer1.Panel1.SuspendLayout(); 75 | this.splitContainer1.Panel2.SuspendLayout(); 76 | this.splitContainer1.SuspendLayout(); 77 | this.tabControl1.SuspendLayout(); 78 | this.tabPageCFRanges.SuspendLayout(); 79 | this.tabPageResults.SuspendLayout(); 80 | this.SuspendLayout(); 81 | // 82 | // btnStart 83 | // 84 | this.btnStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 85 | this.btnStart.Location = new System.Drawing.Point(685, 19); 86 | this.btnStart.Name = "btnStart"; 87 | this.btnStart.Size = new System.Drawing.Size(89, 52); 88 | this.btnStart.TabIndex = 0; 89 | this.btnStart.Text = "Start Scan"; 90 | this.toolTip1.SetToolTip(this.btnStart, "Scan in selected IP ranges of Cloudflare"); 91 | this.btnStart.UseVisualStyleBackColor = true; 92 | this.btnStart.Click += new System.EventHandler(this.btnStart_Click); 93 | // 94 | // txtLog 95 | // 96 | this.txtLog.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(21)))), ((int)(((byte)(23)))), ((int)(((byte)(24))))); 97 | this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill; 98 | this.txtLog.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); 99 | this.txtLog.ForeColor = System.Drawing.Color.PaleTurquoise; 100 | this.txtLog.Location = new System.Drawing.Point(0, 0); 101 | this.txtLog.Multiline = true; 102 | this.txtLog.Name = "txtLog"; 103 | this.txtLog.ReadOnly = true; 104 | this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 105 | this.txtLog.Size = new System.Drawing.Size(780, 176); 106 | this.txtLog.TabIndex = 1; 107 | this.txtLog.Text = "Welcome to Cloudflare IP Scanner.\r\n"; 108 | // 109 | // timerBase 110 | // 111 | this.timerBase.Enabled = true; 112 | this.timerBase.Interval = 1500; 113 | this.timerBase.Tick += new System.EventHandler(this.timerBase_Tick); 114 | // 115 | // prgOveral 116 | // 117 | this.prgOveral.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 118 | | System.Windows.Forms.AnchorStyles.Right))); 119 | this.prgOveral.Location = new System.Drawing.Point(274, 47); 120 | this.prgOveral.Name = "prgOveral"; 121 | this.prgOveral.Size = new System.Drawing.Size(260, 20); 122 | this.prgOveral.TabIndex = 5; 123 | this.toolTip1.SetToolTip(this.prgOveral, "Overal progress"); 124 | // 125 | // prgCurRange 126 | // 127 | this.prgCurRange.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 128 | | System.Windows.Forms.AnchorStyles.Right))); 129 | this.prgCurRange.Location = new System.Drawing.Point(274, 20); 130 | this.prgCurRange.Name = "prgCurRange"; 131 | this.prgCurRange.Size = new System.Drawing.Size(260, 20); 132 | this.prgCurRange.Style = System.Windows.Forms.ProgressBarStyle.Continuous; 133 | this.prgCurRange.TabIndex = 4; 134 | this.toolTip1.SetToolTip(this.prgCurRange, "Current IP range progress"); 135 | // 136 | // btnSkipCurRange 137 | // 138 | this.btnSkipCurRange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 139 | this.btnSkipCurRange.Enabled = false; 140 | this.btnSkipCurRange.Location = new System.Drawing.Point(545, 19); 141 | this.btnSkipCurRange.Name = "btnSkipCurRange"; 142 | this.btnSkipCurRange.Size = new System.Drawing.Size(131, 23); 143 | this.btnSkipCurRange.TabIndex = 3; 144 | this.btnSkipCurRange.Text = "Skip Curent IP Range"; 145 | this.btnSkipCurRange.UseVisualStyleBackColor = true; 146 | this.btnSkipCurRange.Click += new System.EventHandler(this.btnSkipCurRange_Click); 147 | // 148 | // labelLastIPChecked 149 | // 150 | this.labelLastIPChecked.AutoSize = true; 151 | this.labelLastIPChecked.Location = new System.Drawing.Point(11, 22); 152 | this.labelLastIPChecked.Name = "labelLastIPChecked"; 153 | this.labelLastIPChecked.Size = new System.Drawing.Size(91, 15); 154 | this.labelLastIPChecked.TabIndex = 1; 155 | this.labelLastIPChecked.Text = "Last checked IP:"; 156 | // 157 | // lblLastIPRange 158 | // 159 | this.lblLastIPRange.AutoSize = true; 160 | this.lblLastIPRange.Location = new System.Drawing.Point(11, 43); 161 | this.lblLastIPRange.Name = "lblLastIPRange"; 162 | this.lblLastIPRange.Size = new System.Drawing.Size(99, 15); 163 | this.lblLastIPRange.TabIndex = 0; 164 | this.lblLastIPRange.Text = "Current IP Range:"; 165 | // 166 | // timerProgress 167 | // 168 | this.timerProgress.Interval = 300; 169 | this.timerProgress.Tick += new System.EventHandler(this.timerProgress_Tick); 170 | // 171 | // groupBox1 172 | // 173 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 174 | | System.Windows.Forms.AnchorStyles.Right))); 175 | this.groupBox1.Controls.Add(this.linkGithub); 176 | this.groupBox1.Controls.Add(this.btnCopyFastestIP); 177 | this.groupBox1.Controls.Add(this.txtFastestIP); 178 | this.groupBox1.Controls.Add(this.lblFastestIP); 179 | this.groupBox1.Controls.Add(this.comboConcurrent); 180 | this.groupBox1.Controls.Add(this.lblConcurrent); 181 | this.groupBox1.Controls.Add(this.lblTotalWorkingIPs); 182 | this.groupBox1.Controls.Add(this.labelLastIPChecked); 183 | this.groupBox1.Controls.Add(this.prgOveral); 184 | this.groupBox1.Controls.Add(this.lblLastIPRange); 185 | this.groupBox1.Controls.Add(this.btnStart); 186 | this.groupBox1.Controls.Add(this.prgCurRange); 187 | this.groupBox1.Controls.Add(this.btnSkipCurRange); 188 | this.groupBox1.Location = new System.Drawing.Point(12, 4); 189 | this.groupBox1.Name = "groupBox1"; 190 | this.groupBox1.Size = new System.Drawing.Size(780, 120); 191 | this.groupBox1.TabIndex = 3; 192 | this.groupBox1.TabStop = false; 193 | // 194 | // linkGithub 195 | // 196 | this.linkGithub.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 197 | this.linkGithub.Image = global::WinCFScan.Properties.Resources.github_mark24; 198 | this.linkGithub.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 199 | this.linkGithub.Location = new System.Drawing.Point(694, 85); 200 | this.linkGithub.Name = "linkGithub"; 201 | this.linkGithub.Size = new System.Drawing.Size(71, 23); 202 | this.linkGithub.TabIndex = 12; 203 | this.linkGithub.TabStop = true; 204 | this.linkGithub.Text = "GitHub"; 205 | this.linkGithub.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 206 | this.toolTip1.SetToolTip(this.linkGithub, "Visit us on GitHub.com"); 207 | this.linkGithub.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkGithub_LinkClicked); 208 | // 209 | // btnCopyFastestIP 210 | // 211 | this.btnCopyFastestIP.Location = new System.Drawing.Point(545, 87); 212 | this.btnCopyFastestIP.Name = "btnCopyFastestIP"; 213 | this.btnCopyFastestIP.Size = new System.Drawing.Size(131, 23); 214 | this.btnCopyFastestIP.TabIndex = 11; 215 | this.btnCopyFastestIP.Text = "Copy fastest IP"; 216 | this.btnCopyFastestIP.UseVisualStyleBackColor = true; 217 | this.btnCopyFastestIP.Click += new System.EventHandler(this.btnCopyFastestIP_Click); 218 | // 219 | // txtFastestIP 220 | // 221 | this.txtFastestIP.BackColor = System.Drawing.Color.White; 222 | this.txtFastestIP.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); 223 | this.txtFastestIP.ForeColor = System.Drawing.Color.Green; 224 | this.txtFastestIP.Location = new System.Drawing.Point(274, 85); 225 | this.txtFastestIP.Name = "txtFastestIP"; 226 | this.txtFastestIP.ReadOnly = true; 227 | this.txtFastestIP.Size = new System.Drawing.Size(260, 23); 228 | this.txtFastestIP.TabIndex = 10; 229 | // 230 | // lblFastestIP 231 | // 232 | this.lblFastestIP.AutoSize = true; 233 | this.lblFastestIP.Location = new System.Drawing.Point(11, 88); 234 | this.lblFastestIP.Name = "lblFastestIP"; 235 | this.lblFastestIP.Size = new System.Drawing.Size(94, 15); 236 | this.lblFastestIP.TabIndex = 9; 237 | this.lblFastestIP.Text = "Fastest IP found:"; 238 | // 239 | // comboConcurrent 240 | // 241 | this.comboConcurrent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 242 | this.comboConcurrent.FormattingEnabled = true; 243 | this.comboConcurrent.Items.AddRange(new object[] { 244 | "1", 245 | "2", 246 | "4", 247 | "8", 248 | "16"}); 249 | this.comboConcurrent.Location = new System.Drawing.Point(621, 48); 250 | this.comboConcurrent.Name = "comboConcurrent"; 251 | this.comboConcurrent.Size = new System.Drawing.Size(55, 23); 252 | this.comboConcurrent.TabIndex = 8; 253 | this.comboConcurrent.Text = "4"; 254 | this.toolTip1.SetToolTip(this.comboConcurrent, "Number of parallel scan processes"); 255 | this.comboConcurrent.TextChanged += new System.EventHandler(this.comboConcurrent_TextChanged); 256 | // 257 | // lblConcurrent 258 | // 259 | this.lblConcurrent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 260 | this.lblConcurrent.AutoSize = true; 261 | this.lblConcurrent.Location = new System.Drawing.Point(545, 52); 262 | this.lblConcurrent.Name = "lblConcurrent"; 263 | this.lblConcurrent.Size = new System.Drawing.Size(70, 15); 264 | this.lblConcurrent.TabIndex = 7; 265 | this.lblConcurrent.Text = "Concurrent:"; 266 | // 267 | // lblTotalWorkingIPs 268 | // 269 | this.lblTotalWorkingIPs.AutoSize = true; 270 | this.lblTotalWorkingIPs.Location = new System.Drawing.Point(11, 64); 271 | this.lblTotalWorkingIPs.Name = "lblTotalWorkingIPs"; 272 | this.lblTotalWorkingIPs.Size = new System.Drawing.Size(108, 15); 273 | this.lblTotalWorkingIPs.TabIndex = 6; 274 | this.lblTotalWorkingIPs.Text = "Total working IPs: 0"; 275 | // 276 | // comboResults 277 | // 278 | this.comboResults.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 279 | this.comboResults.FormattingEnabled = true; 280 | this.comboResults.Location = new System.Drawing.Point(128, 10); 281 | this.comboResults.Name = "comboResults"; 282 | this.comboResults.Size = new System.Drawing.Size(215, 23); 283 | this.comboResults.TabIndex = 5; 284 | this.toolTip1.SetToolTip(this.comboResults, "List of last scan results"); 285 | this.comboResults.SelectedIndexChanged += new System.EventHandler(this.comboResults_SelectedIndexChanged); 286 | // 287 | // btnScanInPrevResults 288 | // 289 | this.btnScanInPrevResults.Location = new System.Drawing.Point(396, 10); 290 | this.btnScanInPrevResults.Name = "btnScanInPrevResults"; 291 | this.btnScanInPrevResults.Size = new System.Drawing.Size(131, 24); 292 | this.btnScanInPrevResults.TabIndex = 6; 293 | this.btnScanInPrevResults.Text = "Scan in results"; 294 | this.toolTip1.SetToolTip(this.btnScanInPrevResults, "Scan again in this ip results"); 295 | this.btnScanInPrevResults.UseVisualStyleBackColor = true; 296 | this.btnScanInPrevResults.Click += new System.EventHandler(this.btnScanInPrevResults_Click); 297 | // 298 | // listResults 299 | // 300 | this.listResults.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 301 | | System.Windows.Forms.AnchorStyles.Left) 302 | | System.Windows.Forms.AnchorStyles.Right))); 303 | this.listResults.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 304 | this.hdrDelay, 305 | this.hdrIP}); 306 | this.listResults.FullRowSelect = true; 307 | this.listResults.GridLines = true; 308 | this.listResults.Location = new System.Drawing.Point(0, 40); 309 | this.listResults.Name = "listResults"; 310 | this.listResults.Size = new System.Drawing.Size(772, 181); 311 | this.listResults.TabIndex = 4; 312 | this.listResults.UseCompatibleStateImageBehavior = false; 313 | this.listResults.View = System.Windows.Forms.View.Details; 314 | this.listResults.MouseClick += new System.Windows.Forms.MouseEventHandler(this.listResults_MouseClick); 315 | this.listResults.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listResults_MouseDoubleClick); 316 | // 317 | // hdrDelay 318 | // 319 | this.hdrDelay.Text = "Delay"; 320 | this.hdrDelay.Width = 90; 321 | // 322 | // hdrIP 323 | // 324 | this.hdrIP.Text = "IP Address"; 325 | this.hdrIP.Width = 160; 326 | // 327 | // mnuListView 328 | // 329 | this.mnuListView.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 330 | this.mnuListViewCopyIP, 331 | this.mnuListViewTestThisIPAddress}); 332 | this.mnuListView.Name = "mnuListView"; 333 | this.mnuListView.Size = new System.Drawing.Size(175, 48); 334 | // 335 | // mnuListViewCopyIP 336 | // 337 | this.mnuListViewCopyIP.Name = "mnuListViewCopyIP"; 338 | this.mnuListViewCopyIP.Size = new System.Drawing.Size(174, 22); 339 | this.mnuListViewCopyIP.Text = "Copy IP Address"; 340 | // 341 | // mnuListViewTestThisIPAddress 342 | // 343 | this.mnuListViewTestThisIPAddress.Name = "mnuListViewTestThisIPAddress"; 344 | this.mnuListViewTestThisIPAddress.Size = new System.Drawing.Size(174, 22); 345 | this.mnuListViewTestThisIPAddress.Text = "Test this IP Address"; 346 | this.mnuListViewTestThisIPAddress.Click += new System.EventHandler(this.mnuListViewTestThisIPAddress_Click); 347 | // 348 | // splitContainer1 349 | // 350 | this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 351 | | System.Windows.Forms.AnchorStyles.Left) 352 | | System.Windows.Forms.AnchorStyles.Right))); 353 | this.splitContainer1.Location = new System.Drawing.Point(12, 132); 354 | this.splitContainer1.Name = "splitContainer1"; 355 | this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; 356 | // 357 | // splitContainer1.Panel1 358 | // 359 | this.splitContainer1.Panel1.Controls.Add(this.tabControl1); 360 | // 361 | // splitContainer1.Panel2 362 | // 363 | this.splitContainer1.Panel2.Controls.Add(this.txtLog); 364 | this.splitContainer1.Size = new System.Drawing.Size(780, 426); 365 | this.splitContainer1.SplitterDistance = 246; 366 | this.splitContainer1.TabIndex = 7; 367 | // 368 | // tabControl1 369 | // 370 | this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 371 | | System.Windows.Forms.AnchorStyles.Left) 372 | | System.Windows.Forms.AnchorStyles.Right))); 373 | this.tabControl1.Controls.Add(this.tabPageCFRanges); 374 | this.tabControl1.Controls.Add(this.tabPageResults); 375 | this.tabControl1.Location = new System.Drawing.Point(3, 1); 376 | this.tabControl1.Name = "tabControl1"; 377 | this.tabControl1.SelectedIndex = 0; 378 | this.tabControl1.Size = new System.Drawing.Size(780, 249); 379 | this.tabControl1.TabIndex = 9; 380 | // 381 | // tabPageCFRanges 382 | // 383 | this.tabPageCFRanges.Controls.Add(this.lblCFIPListStatus); 384 | this.tabPageCFRanges.Controls.Add(this.btnSelectNoneIPRanges); 385 | this.tabPageCFRanges.Controls.Add(this.btnSelectAllIPRanges); 386 | this.tabPageCFRanges.Controls.Add(this.listCFIPList); 387 | this.tabPageCFRanges.Location = new System.Drawing.Point(4, 24); 388 | this.tabPageCFRanges.Name = "tabPageCFRanges"; 389 | this.tabPageCFRanges.Padding = new System.Windows.Forms.Padding(3); 390 | this.tabPageCFRanges.Size = new System.Drawing.Size(772, 221); 391 | this.tabPageCFRanges.TabIndex = 1; 392 | this.tabPageCFRanges.Text = "Cloudflare IP ranges"; 393 | this.tabPageCFRanges.UseVisualStyleBackColor = true; 394 | // 395 | // lblCFIPListStatus 396 | // 397 | this.lblCFIPListStatus.AutoSize = true; 398 | this.lblCFIPListStatus.Location = new System.Drawing.Point(6, 12); 399 | this.lblCFIPListStatus.Name = "lblCFIPListStatus"; 400 | this.lblCFIPListStatus.Size = new System.Drawing.Size(110, 15); 401 | this.lblCFIPListStatus.TabIndex = 3; 402 | this.lblCFIPListStatus.Text = "Loading IP ranges..."; 403 | // 404 | // btnSelectNoneIPRanges 405 | // 406 | this.btnSelectNoneIPRanges.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 407 | this.btnSelectNoneIPRanges.Location = new System.Drawing.Point(581, 9); 408 | this.btnSelectNoneIPRanges.Name = "btnSelectNoneIPRanges"; 409 | this.btnSelectNoneIPRanges.Size = new System.Drawing.Size(88, 23); 410 | this.btnSelectNoneIPRanges.TabIndex = 2; 411 | this.btnSelectNoneIPRanges.Text = "Select None"; 412 | this.btnSelectNoneIPRanges.UseVisualStyleBackColor = true; 413 | this.btnSelectNoneIPRanges.Click += new System.EventHandler(this.btnSelectNoneIPRanges_Click); 414 | // 415 | // btnSelectAllIPRanges 416 | // 417 | this.btnSelectAllIPRanges.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 418 | this.btnSelectAllIPRanges.Location = new System.Drawing.Point(678, 9); 419 | this.btnSelectAllIPRanges.Name = "btnSelectAllIPRanges"; 420 | this.btnSelectAllIPRanges.Size = new System.Drawing.Size(88, 23); 421 | this.btnSelectAllIPRanges.TabIndex = 1; 422 | this.btnSelectAllIPRanges.Text = "Select All"; 423 | this.btnSelectAllIPRanges.UseVisualStyleBackColor = true; 424 | this.btnSelectAllIPRanges.Click += new System.EventHandler(this.btnSelectAllIPRanges_Click); 425 | // 426 | // listCFIPList 427 | // 428 | this.listCFIPList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 429 | | System.Windows.Forms.AnchorStyles.Left) 430 | | System.Windows.Forms.AnchorStyles.Right))); 431 | this.listCFIPList.CheckBoxes = true; 432 | this.listCFIPList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 433 | this.headIPRange, 434 | this.headTotalIPs}); 435 | this.listCFIPList.Location = new System.Drawing.Point(0, 38); 436 | this.listCFIPList.Name = "listCFIPList"; 437 | this.listCFIPList.Size = new System.Drawing.Size(772, 183); 438 | this.listCFIPList.TabIndex = 0; 439 | this.listCFIPList.UseCompatibleStateImageBehavior = false; 440 | this.listCFIPList.View = System.Windows.Forms.View.Details; 441 | this.listCFIPList.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.listCFIPList_ItemChecked); 442 | // 443 | // headIPRange 444 | // 445 | this.headIPRange.Text = "IP Range"; 446 | this.headIPRange.Width = 120; 447 | // 448 | // headTotalIPs 449 | // 450 | this.headTotalIPs.Text = "Total IPs"; 451 | this.headTotalIPs.Width = 90; 452 | // 453 | // tabPageResults 454 | // 455 | this.tabPageResults.Controls.Add(this.lblPrevListTotalIPs); 456 | this.tabPageResults.Controls.Add(this.lblPrevResults); 457 | this.tabPageResults.Controls.Add(this.btnDeleteResult); 458 | this.tabPageResults.Controls.Add(this.comboResults); 459 | this.tabPageResults.Controls.Add(this.btnScanInPrevResults); 460 | this.tabPageResults.Controls.Add(this.listResults); 461 | this.tabPageResults.Location = new System.Drawing.Point(4, 24); 462 | this.tabPageResults.Name = "tabPageResults"; 463 | this.tabPageResults.Padding = new System.Windows.Forms.Padding(3); 464 | this.tabPageResults.Size = new System.Drawing.Size(772, 221); 465 | this.tabPageResults.TabIndex = 0; 466 | this.tabPageResults.Text = "Scan Results"; 467 | this.tabPageResults.UseVisualStyleBackColor = true; 468 | // 469 | // lblPrevListTotalIPs 470 | // 471 | this.lblPrevListTotalIPs.Location = new System.Drawing.Point(343, 14); 472 | this.lblPrevListTotalIPs.Name = "lblPrevListTotalIPs"; 473 | this.lblPrevListTotalIPs.Size = new System.Drawing.Size(53, 19); 474 | this.lblPrevListTotalIPs.TabIndex = 9; 475 | this.lblPrevListTotalIPs.Text = "0 IPs"; 476 | this.lblPrevListTotalIPs.TextAlign = System.Drawing.ContentAlignment.TopCenter; 477 | // 478 | // lblPrevResults 479 | // 480 | this.lblPrevResults.AutoSize = true; 481 | this.lblPrevResults.Location = new System.Drawing.Point(6, 13); 482 | this.lblPrevResults.Name = "lblPrevResults"; 483 | this.lblPrevResults.Size = new System.Drawing.Size(119, 15); 484 | this.lblPrevResults.TabIndex = 7; 485 | this.lblPrevResults.Text = "Previous scan results:"; 486 | // 487 | // btnDeleteResult 488 | // 489 | this.btnDeleteResult.Location = new System.Drawing.Point(538, 11); 490 | this.btnDeleteResult.Name = "btnDeleteResult"; 491 | this.btnDeleteResult.Size = new System.Drawing.Size(131, 23); 492 | this.btnDeleteResult.TabIndex = 8; 493 | this.btnDeleteResult.Text = "Delete current result"; 494 | this.btnDeleteResult.UseVisualStyleBackColor = true; 495 | this.btnDeleteResult.Click += new System.EventHandler(this.btnDeleteResult_Click); 496 | // 497 | // frmMain 498 | // 499 | this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 500 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 501 | this.ClientSize = new System.Drawing.Size(804, 570); 502 | this.Controls.Add(this.splitContainer1); 503 | this.Controls.Add(this.groupBox1); 504 | this.MinimumSize = new System.Drawing.Size(820, 480); 505 | this.Name = "frmMain"; 506 | this.Text = "Cloudflare Scan"; 507 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing); 508 | this.groupBox1.ResumeLayout(false); 509 | this.groupBox1.PerformLayout(); 510 | this.mnuListView.ResumeLayout(false); 511 | this.splitContainer1.Panel1.ResumeLayout(false); 512 | this.splitContainer1.Panel2.ResumeLayout(false); 513 | this.splitContainer1.Panel2.PerformLayout(); 514 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); 515 | this.splitContainer1.ResumeLayout(false); 516 | this.tabControl1.ResumeLayout(false); 517 | this.tabPageCFRanges.ResumeLayout(false); 518 | this.tabPageCFRanges.PerformLayout(); 519 | this.tabPageResults.ResumeLayout(false); 520 | this.tabPageResults.PerformLayout(); 521 | this.ResumeLayout(false); 522 | 523 | } 524 | 525 | #endregion 526 | 527 | private Button btnStart; 528 | private TextBox txtLog; 529 | private System.Windows.Forms.Timer timerBase; 530 | private Label lblLastIPRange; 531 | private System.Windows.Forms.Timer timerProgress; 532 | private Label labelLastIPChecked; 533 | private Button btnSkipCurRange; 534 | private ProgressBar prgOveral; 535 | private ProgressBar prgCurRange; 536 | private GroupBox groupBox1; 537 | private ToolTip toolTip1; 538 | private ListView listResults; 539 | private ColumnHeader hdrDelay; 540 | private ColumnHeader hdrIP; 541 | private ComboBox comboResults; 542 | private Label lblTotalWorkingIPs; 543 | private Button btnScanInPrevResults; 544 | private SplitContainer splitContainer1; 545 | private Label lblPrevResults; 546 | private ComboBox comboConcurrent; 547 | private Label lblConcurrent; 548 | private Button btnDeleteResult; 549 | private TextBox txtFastestIP; 550 | private Label lblFastestIP; 551 | private Button btnCopyFastestIP; 552 | private ContextMenuStrip mnuListView; 553 | private ToolStripMenuItem mnuListViewCopyIP; 554 | private ToolStripMenuItem mnuListViewTestThisIPAddress; 555 | private TabControl tabControl1; 556 | private TabPage tabPageResults; 557 | private TabPage tabPageCFRanges; 558 | private ListView listCFIPList; 559 | private ColumnHeader headIPRange; 560 | private ColumnHeader headTotalIPs; 561 | private Button btnSelectNoneIPRanges; 562 | private Button btnSelectAllIPRanges; 563 | private Label lblCFIPListStatus; 564 | private Label lblPrevListTotalIPs; 565 | private LinkLabel linkGithub; 566 | } 567 | } -------------------------------------------------------------------------------- /frmMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Diagnostics; 4 | using System.Net; 5 | using System.Security.Policy; 6 | using WinCFScan.Classes; 7 | using WinCFScan.Classes.Config; 8 | using WinCFScan.Classes.HTTPRequest; 9 | using WinCFScan.Classes.IP; 10 | using static System.Net.Mime.MediaTypeNames; 11 | 12 | namespace WinCFScan 13 | { 14 | public partial class frmMain : Form 15 | { 16 | private const string ourGitHubUrl = "https://github.com/goingfine/WinCFScan"; 17 | ConfigManager configManager; 18 | bool oneTimeChecked = false; // config checked once? 19 | ScanEngine scanEngine; 20 | private List currentScanResults = new(); 21 | private bool scanFnished = false; 22 | private bool isUpdatinglistCFIP; 23 | private bool isAppCongigValid = true; 24 | 25 | public frmMain() 26 | { 27 | InitializeComponent(); 28 | 29 | // load configs 30 | configManager = new(); 31 | if(!configManager.isConfigValid()) { 32 | 33 | addTextLog("App config is not valid! we can not continue."); 34 | 35 | if(configManager.errorMessage != "") 36 | { 37 | addTextLog(configManager.errorMessage); 38 | } 39 | 40 | isAppCongigValid = false; 41 | } 42 | 43 | scanEngine = new ScanEngine(); 44 | 45 | loadLastResultsComboList(); 46 | 47 | Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; 48 | DateTime buildDate = new DateTime(2000, 1, 1) 49 | .AddDays(version.Build).AddSeconds(version.Revision * 2); 50 | string displayableVersion = $" - {version}"; 51 | this.Text += displayableVersion; 52 | } 53 | 54 | // add text log to log textbox 55 | delegate void SetTextCallback(string log); 56 | public void addTextLog(string log) 57 | { 58 | try 59 | { 60 | if (this.txtLog.InvokeRequired) 61 | { 62 | SetTextCallback d = new SetTextCallback(addTextLog); 63 | this.Invoke(d, new object[] { log }); 64 | } 65 | else 66 | { 67 | txtLog.AppendText(log + Environment.NewLine); 68 | } 69 | } 70 | catch (Exception) 71 | { 72 | } 73 | } 74 | 75 | 76 | private void btnScanInPrevResults_Click(object sender, EventArgs e) 77 | { 78 | startStopScan(true); 79 | } 80 | 81 | private void btnStart_Click(object sender, EventArgs e) 82 | { 83 | startStopScan(false); 84 | } 85 | 86 | private void startStopScan(bool inPrevResult = false) 87 | { 88 | if(!isAppCongigValid) 89 | { 90 | showCanNotContinueMessage(); 91 | return; 92 | } 93 | 94 | if (scanEngine.progressInfo.isScanRunning) 95 | { 96 | // stop scan 97 | waitUntilScannerStoped(); 98 | updateUIControlls(false); 99 | } 100 | else 101 | { // start scan 102 | if (!inPrevResult) 103 | { 104 | // set cf ip list to scan engine 105 | string[] ipRanges = getCheckedCFIPList(); 106 | if (ipRanges.Length == 0) 107 | { 108 | tabControl1.SelectTab(0); 109 | MessageBox.Show($"No Cloudflare IP ranges are selected. Please select some IP ranges.", 110 | "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 111 | return; 112 | } 113 | scanEngine.setCFIPRangeList(ipRanges); 114 | addTextLog($"Start scanning {ipRanges.Length} Cloudflare IP ranges..."); 115 | } 116 | else 117 | { 118 | if(currentScanResults.Count == 0) 119 | { 120 | addTextLog("Current result list is empty!"); 121 | return; 122 | } 123 | addTextLog($"Start scanning {currentScanResults.Count} IPs in previous result..."); 124 | } 125 | 126 | updateUIControlls(true); 127 | scanEngine.workingIPsFromPrevScan = inPrevResult ? currentScanResults : null; 128 | var scanType = inPrevResult ? ScanType.SCAN_IN_PERV_RESULTS : ScanType.SCAN_CLOUDFLARE_IPS; 129 | 130 | // start scan job in new thread 131 | Task.Factory.StartNew(() => scanEngine.start(scanType)) 132 | .ContinueWith(done => { 133 | scanFnished = true; 134 | this.currentScanResults = scanEngine.progressInfo.scanResults.workingIPs; 135 | addTextLog($"{scanEngine.progressInfo.totalCheckedIP:n0} IPs tested and found {scanEngine.progressInfo.scanResults.totalFoundWorkingIPs:n0} working IPs."); 136 | }); 137 | 138 | tabControl1.SelectTab(1); 139 | } 140 | } 141 | 142 | private void updateUIControlls(bool isStarting) 143 | { 144 | if (isStarting) 145 | { 146 | loadLastResultsComboList(); 147 | listResults.Items.Clear(); 148 | btnStart.Text = "Stop Scan"; 149 | btnScanInPrevResults.Enabled = false; 150 | btnDeleteResult.Enabled = false; 151 | comboConcurrent.Enabled = false; 152 | timerProgress.Enabled = true; 153 | btnSkipCurRange.Enabled = true; 154 | comboResults.Enabled = false; 155 | tabPageCFRanges.Enabled = false; 156 | } 157 | else 158 | { // is stopping 159 | btnStart.Text = "Start Scan"; 160 | btnScanInPrevResults.Enabled = true; 161 | btnDeleteResult.Enabled = true; 162 | timerProgress.Enabled = false; 163 | btnSkipCurRange.Enabled = false; 164 | comboResults.Enabled = true; 165 | comboConcurrent.Enabled = true; 166 | tabPageCFRanges.Enabled = true; 167 | 168 | // save result file if found working IPs 169 | var scanResults = scanEngine.progressInfo.scanResults; 170 | if (scanResults.totalFoundWorkingIPs != 0) 171 | { 172 | // save results into disk 173 | if (! scanResults.save()) 174 | { 175 | addTextLog($"Could not save scan result into the file: {scanResults.resultsFileName}"); 176 | } 177 | } 178 | else 179 | { 180 | // delete result file if there is no woriking ip 181 | scanResults.remove(); 182 | } 183 | 184 | loadLastResultsComboList(); 185 | 186 | } 187 | } 188 | 189 | private void timerBase_Tick(object sender, EventArgs e) 190 | { 191 | oneTimeChecks(); 192 | if (scanFnished) 193 | { 194 | scanFnished = false; 195 | updateConrtolsProgress(true); 196 | updateUIControlls(false); 197 | } 198 | } 199 | 200 | 201 | private void timerProgress_Tick(object sender, EventArgs e) 202 | { 203 | updateConrtolsProgress(); 204 | } 205 | 206 | private void updateConrtolsProgress(bool forceUpdate = false) 207 | { 208 | var pInf = scanEngine.progressInfo; 209 | if (scanEngine.progressInfo.isScanRunning || forceUpdate) 210 | { 211 | lblLastIPRange.Text = $"Current IP range: {pInf.currentIPRange} ({pInf.currentIPRangesNumber:n0}/{pInf.totalIPRanges:n0})"; 212 | labelLastIPChecked.Text = $"Last checked IP: {pInf.lastCheckedIP} ({pInf.totalCheckedIPInCurIPRange:n0}/{pInf.currentIPRangeTotalIPs:n0})"; 213 | lblTotalWorkingIPs.Text = $"Total working IPs found: {pInf.scanResults.totalFoundWorkingIPs:n0}"; 214 | if(pInf.scanResults.fastestIP !=null) 215 | { 216 | txtFastestIP.Text = $"{pInf.scanResults.fastestIP.ip} - {pInf.scanResults.fastestIP.delay:n0} ms"; 217 | } 218 | 219 | prgOveral.Maximum = pInf.totalIPRanges; 220 | prgOveral.Value = pInf.currentIPRangesNumber; 221 | 222 | prgCurRange.Maximum = pInf.currentIPRangeTotalIPs; 223 | prgCurRange.Value = pInf.totalCheckedIPInCurIPRange; 224 | fetchWorkingIPResults(); 225 | pInf.scanResults.autoSave(); 226 | } 227 | 228 | 229 | } 230 | 231 | // fetch new woriking ips and add to the list view while scanning 232 | private void fetchWorkingIPResults() 233 | { 234 | List scanResults = scanEngine.progressInfo.scanResults.fetchWorkingIPs(); 235 | addResulItemsToListView(scanResults); 236 | } 237 | 238 | private void btnSkipCurRange_Click(object sender, EventArgs e) 239 | { 240 | scanEngine.skipCurrentIPRange(); 241 | } 242 | 243 | private void loadLastResultsComboList() 244 | { 245 | comboResults.Items.Clear(); 246 | comboResults.Items.Add("Current Scan Results"); 247 | var resultFiles = Directory.GetFiles("results/", "*.json"); 248 | foreach (var resultFile in resultFiles) 249 | { 250 | comboResults.Items.Add(resultFile); 251 | } 252 | comboResults.SelectedIndex= 0; 253 | } 254 | 255 | private void comboResults_SelectedIndexChanged(object sender, EventArgs e) 256 | { 257 | string? filename = getSelectedScanResultFilename(); 258 | if (filename != null) 259 | { 260 | fillResultsListView(filename); 261 | } 262 | } 263 | 264 | // get filename of selected scan result 265 | private string? getSelectedScanResultFilename() 266 | { 267 | string? filename = comboResults.SelectedItem.ToString(); 268 | if (filename != null && File.Exists(filename) && filename != "Current Scan Results") 269 | { 270 | return filename; 271 | } 272 | 273 | return null; 274 | } 275 | 276 | // load previous results into list view 277 | private void fillResultsListView(string resultsFileName) 278 | { 279 | var results = new ScanResults(resultsFileName); 280 | if (results.load()) 281 | { 282 | listResults.Items.Clear(); 283 | var loaded = results.getLoadedInstance(); 284 | this.currentScanResults = loaded.workingIPs; 285 | addResulItemsToListView(currentScanResults); 286 | 287 | addTextLog($"'{resultsFileName}' loaded with {loaded.totalFoundWorkingIPs:n0} working IPs, scan time: {loaded.startDate}"); 288 | } 289 | else 290 | { 291 | addTextLog($"Could not load scan result file from disk: {resultsFileName}"); 292 | } 293 | } 294 | 295 | private void addResulItemsToListView(List? workingIPs) 296 | { 297 | if (workingIPs != null) 298 | { 299 | foreach (ResultItem resultItem in workingIPs) 300 | { 301 | listResults.Items.Add(new ListViewItem(new string[] { resultItem.delay.ToString(), resultItem.ip })); 302 | } 303 | lblPrevListTotalIPs.Text = $"{listResults.Items.Count:n0} IPs"; 304 | } 305 | } 306 | 307 | 308 | private void oneTimeChecks() 309 | { 310 | if (!oneTimeChecked && isAppCongigValid) 311 | { 312 | //Load cf ip ranges 313 | loadCFIPListView(); 314 | 315 | // check if config real file is exists and update 316 | if (configManager.getRealConfig() != null && configManager.getRealConfig().isConfigRealOld()) 317 | { 318 | addTextLog("Updating real config from remote..."); 319 | bool result = configManager.getRealConfig().remoteUpdateConfigReal(); 320 | if (result) 321 | { 322 | addTextLog("'real config' is successfully updated."); 323 | if (!configManager.getRealConfig().isConfigValid()) 324 | { 325 | addTextLog("'real config' data is not valid!"); 326 | } 327 | } 328 | else 329 | { 330 | addTextLog("Failed to update real config. check your internet connection or maybe real config update url is blocked by your ISP!"); 331 | } 332 | } 333 | 334 | // check fronting domain 335 | Task.Factory.StartNew(() => 336 | { 337 | var checker = new CheckIPWorking(); 338 | if (!checker.checkFronting(false, 5)) 339 | { 340 | addTextLog($"Fronting domain is not accesible! you might need to get new frontig url from our github or check your internet connection."); 341 | } 342 | }); 343 | 344 | oneTimeChecked = true; 345 | } 346 | } 347 | 348 | private void comboConcurrent_TextChanged(object sender, EventArgs e) 349 | { 350 | var con = getConcurentProcess(); 351 | comboConcurrent.Text = con.ToString(); 352 | scanEngine.concurrentProcess = con; 353 | } 354 | 355 | private int getConcurentProcess() 356 | { 357 | int val = 0; 358 | bool isInteger = int.TryParse(comboConcurrent.Text, out val); 359 | if (!isInteger || val < 1 || val > 16) 360 | { 361 | val = 4; 362 | } 363 | 364 | return val; 365 | } 366 | 367 | private void btnCopyFastestIP_Click(object sender, EventArgs e) 368 | { 369 | try 370 | { 371 | if (scanEngine.progressInfo.scanResults?.fastestIP != null) 372 | { 373 | Clipboard.SetText(scanEngine.progressInfo.scanResults.fastestIP.ip); 374 | } 375 | } 376 | catch (Exception ex) { } 377 | } 378 | 379 | // delete result 380 | private void btnDeleteResult_Click(object sender, EventArgs e) 381 | { 382 | string? filename = getSelectedScanResultFilename(); 383 | if (filename != null) 384 | { 385 | var result = MessageBox.Show($"Are you sure you want to delete {filename}?", 386 | "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); 387 | if (result == DialogResult.Yes) 388 | { 389 | try 390 | { 391 | File.Delete(filename); 392 | addTextLog($"'{filename}' has been deleted."); 393 | loadLastResultsComboList(); 394 | listResults.Items.Clear(); 395 | currentScanResults = new(); 396 | lblPrevListTotalIPs.Text = "0 IPs"; 397 | 398 | } 399 | catch (Exception){ 400 | addTextLog($"Could not delete '{filename}'"); 401 | } 402 | } 403 | } 404 | } 405 | 406 | // user selected ip list of cloudflare 407 | private string[] getCheckedCFIPList(bool getIPCount = false) 408 | { 409 | return listCFIPList.CheckedItems.Cast() 410 | .Select(item => { 411 | return getIPCount ? item.SubItems[1].Text : item.SubItems[0].Text; 412 | }) 413 | .ToArray(); 414 | 415 | 416 | } 417 | 418 | // list view right click 419 | private void listResults_MouseClick(object sender, MouseEventArgs e) 420 | { 421 | if(e.Button == MouseButtons.Right) { 422 | mnuListViewCopyIP.Text = "Copy IP Address " + getSelectedIPAddress(); 423 | mnuListView.Show(listResults, e.X, e.Y); 424 | } 425 | } 426 | 427 | // add cloudflare ip ranges to list view 428 | private void loadCFIPListView() 429 | { 430 | if(scanEngine.cfIPList == null) 431 | { 432 | addTextLog("Cloudflare IP range file is not found!"); 433 | lblCFIPListStatus.Text = "Failed to load IP ranges."; 434 | lblCFIPListStatus.ForeColor = Color.Red; 435 | return; 436 | } 437 | 438 | listCFIPList.BeginUpdate(); 439 | isUpdatinglistCFIP = true; 440 | uint totalIPs = 0; 441 | addTextLog($"Loading Cloudflare IPs ranges..."); 442 | 443 | foreach (var ipRange in scanEngine.cfIPList) 444 | { 445 | if (ipRange != "") 446 | { 447 | var rangeTotalIPs = IPAddressExtensions.getIPRangeTotalIPs(ipRange); 448 | var item = listCFIPList.Items.Add(new ListViewItem(new string[] { ipRange, $"{rangeTotalIPs:n0}" })); 449 | item.Checked = true; 450 | totalIPs += rangeTotalIPs; 451 | } 452 | } 453 | 454 | listCFIPList.EndUpdate(); 455 | isUpdatinglistCFIP = false; 456 | addTextLog($"Total {totalIPs:n0} Cloudflare IPs are ready to be scanned."); 457 | updateCFIPListStatusText(); 458 | } 459 | 460 | 461 | private void mnuListViewTestThisIPAddress_Click(object sender, EventArgs e) 462 | { 463 | var IPAddress = getSelectedIPAddress(); 464 | if(IPAddress != null) 465 | { 466 | testSingleIP(IPAddress); 467 | } 468 | } 469 | 470 | private void testSingleIP(string IPAddress) 471 | { 472 | addTextLog($"Testing {IPAddress} ..."); 473 | var checker = new CheckIPWorking(IPAddress); 474 | var success = checker.check(); 475 | if (success) 476 | addTextLog($"{IPAddress} is working. Delay: {checker.downloadDuration:n0} ms."); 477 | else 478 | addTextLog($"{IPAddress} is NOT working."); 479 | } 480 | 481 | private string? getSelectedIPAddress() 482 | { 483 | try 484 | { 485 | return listResults.SelectedItems[0].SubItems[1].Text; 486 | } 487 | catch (Exception ex) {} 488 | 489 | return null; 490 | } 491 | 492 | private void listResults_MouseDoubleClick(object sender, MouseEventArgs e) 493 | { 494 | var IPAddress = getSelectedIPAddress(); 495 | if (IPAddress != null) 496 | { 497 | testSingleIP(IPAddress); 498 | } 499 | } 500 | 501 | private void updateCFIPListStatusText() 502 | { 503 | var ipRangeCounts = getCheckedCFIPList(true); 504 | uint sum = 0; 505 | foreach (var item in ipRangeCounts) 506 | { 507 | sum += uint.Parse(item.Replace(",","")); 508 | } 509 | lblCFIPListStatus.Text = $"{ipRangeCounts.Length} Cloudflare IP ranges are selected, contains {sum:n0} IPs"; 510 | } 511 | 512 | private void btnSelectAllIPRanges_Click(object sender, EventArgs e) 513 | { 514 | changeCFListViewItemsCheckState(true); 515 | } 516 | 517 | private void btnSelectNoneIPRanges_Click(object sender, EventArgs e) 518 | { 519 | changeCFListViewItemsCheckState(false); 520 | } 521 | 522 | private void changeCFListViewItemsCheckState(bool isChecked) 523 | { 524 | listCFIPList.BeginUpdate(); 525 | isUpdatinglistCFIP = true; 526 | foreach (ListViewItem item in listCFIPList.Items) 527 | { 528 | item.Checked = isChecked; 529 | } 530 | listCFIPList.EndUpdate(); 531 | isUpdatinglistCFIP = false; 532 | updateCFIPListStatusText(); 533 | } 534 | 535 | private void listCFIPList_ItemChecked(object sender, ItemCheckedEventArgs e) 536 | { 537 | if(!isUpdatinglistCFIP) 538 | updateCFIPListStatusText(); 539 | } 540 | 541 | private void showCanNotContinueMessage() 542 | { 543 | MessageBox.Show("App configuration file is not valid. We can not continue.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 544 | 545 | } 546 | 547 | private void frmMain_FormClosing(object sender, FormClosingEventArgs e) 548 | { 549 | addTextLog("Exiting..."); 550 | waitUntilScannerStoped(); 551 | } 552 | 553 | private void waitUntilScannerStoped() 554 | { 555 | if (scanEngine.progressInfo.isScanRunning) 556 | { 557 | // stop scan 558 | scanEngine.stop(); 559 | do 560 | { 561 | System.Windows.Forms.Application.DoEvents(); 562 | Thread.Sleep(100); 563 | } while (scanEngine.progressInfo.isScanRunning); 564 | 565 | } 566 | } 567 | 568 | private void linkGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 569 | { 570 | try 571 | { 572 | ProcessStartInfo sInfo = new ProcessStartInfo(ourGitHubUrl) { UseShellExecute = true }; 573 | Process.Start(sInfo); 574 | } 575 | catch (Exception) 576 | { 577 | addTextLog($"Visit us on {ourGitHubUrl}"); 578 | throw; 579 | } 580 | } 581 | } 582 | } -------------------------------------------------------------------------------- /frmMain.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | 61 | 249, 17 62 | 63 | 64 | 17, 17 65 | 66 | 67 | 122, 17 68 | 69 | 70 | 346, 17 71 | 72 | --------------------------------------------------------------------------------