From 6b11ddb5fb2c981825af1d46c3e7b80e9cdd6afa Mon Sep 17 00:00:00 2001 From: WaGi Date: Thu, 26 Sep 2019 13:50:15 +0200 Subject: [PATCH 1/4] Check for update every 10 minutes --- WaGis IP-Blacklister/Form1.Designer.cs | 23 ++++++---- WaGis IP-Blacklister/Form1.cs | 58 +++++++++++++++----------- WaGis IP-Blacklister/Form1.resx | 3 ++ 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/WaGis IP-Blacklister/Form1.Designer.cs b/WaGis IP-Blacklister/Form1.Designer.cs index 1c3bb0e..3c7c244 100644 --- a/WaGis IP-Blacklister/Form1.Designer.cs +++ b/WaGis IP-Blacklister/Form1.Designer.cs @@ -80,13 +80,14 @@ private void InitializeComponent() this.ToolstripMenuItemREMOVE = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.infoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.updateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.minimizeToSystemTrayToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timerUpdateBlink = new System.Windows.Forms.Timer(this.components); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.trayIconContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.timerCheckForUpdate = new System.Windows.Forms.Timer(this.components); this.contextMenuStrip1.SuspendLayout(); this.pnlOptions.SuspendLayout(); this.pnlDirection.SuspendLayout(); @@ -687,6 +688,13 @@ private void InitializeComponent() this.infoToolStripMenuItem.Text = "Info"; this.infoToolStripMenuItem.Click += new System.EventHandler(this.infoToolStripMenuItem_Click); // + // minimizeToSystemTrayToolStripMenuItem + // + this.minimizeToSystemTrayToolStripMenuItem.Name = "minimizeToSystemTrayToolStripMenuItem"; + this.minimizeToSystemTrayToolStripMenuItem.Size = new System.Drawing.Size(147, 20); + this.minimizeToSystemTrayToolStripMenuItem.Text = "Minimize to System Tray"; + this.minimizeToSystemTrayToolStripMenuItem.Click += new System.EventHandler(this.minimizeToSystemTrayToolStripMenuItem_Click); + // // updateToolStripMenuItem // this.updateToolStripMenuItem.BackColor = System.Drawing.Color.Crimson; @@ -696,13 +704,6 @@ private void InitializeComponent() this.updateToolStripMenuItem.Visible = false; this.updateToolStripMenuItem.Click += new System.EventHandler(this.updateToolStripMenuItem_Click); // - // minimizeToSystemTrayToolStripMenuItem - // - this.minimizeToSystemTrayToolStripMenuItem.Name = "minimizeToSystemTrayToolStripMenuItem"; - this.minimizeToSystemTrayToolStripMenuItem.Size = new System.Drawing.Size(147, 20); - this.minimizeToSystemTrayToolStripMenuItem.Text = "Minimize to System Tray"; - this.minimizeToSystemTrayToolStripMenuItem.Click += new System.EventHandler(this.minimizeToSystemTrayToolStripMenuItem_Click); - // // timerUpdateBlink // this.timerUpdateBlink.Interval = 1000; @@ -739,6 +740,11 @@ private void InitializeComponent() this.closeToolStripMenuItem.Text = "Close"; this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click); // + // timerCheckForUpdate + // + this.timerCheckForUpdate.Interval = 600000; + this.timerCheckForUpdate.Tick += new System.EventHandler(this.timerCheckForUpdate_Tick); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -842,6 +848,7 @@ private void InitializeComponent() private System.Windows.Forms.ContextMenuStrip trayIconContextMenuStrip; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem; + private System.Windows.Forms.Timer timerCheckForUpdate; } } diff --git a/WaGis IP-Blacklister/Form1.cs b/WaGis IP-Blacklister/Form1.cs index 4dca744..7a4c735 100644 --- a/WaGis IP-Blacklister/Form1.cs +++ b/WaGis IP-Blacklister/Form1.cs @@ -100,40 +100,44 @@ private void MainForm_Load(object sender, EventArgs e) } // Maybe Check for Updates - NOT DONE - try - { - newV = WaGiRequest("https://api.github.com/repos/WaGi-Coding/WaGis-Mass-IP-Blacklister-Windows/releases/latest"); - - JObject jObject = JObject.Parse(newV); - newV = Convert.ToString(jObject.SelectToken("tag_name")); + CheckForUpdate(); + timerCheckForUpdate.Start(); + } + + } - var versionNow = new Version(Application.ProductVersion); - var versionWeb = new Version(newV); + private void CheckForUpdate() + { + try + { + newV = WaGiRequest("https://api.github.com/repos/WaGi-Coding/WaGis-Mass-IP-Blacklister-Windows/releases/latest"); - var result = versionNow.CompareTo(versionWeb); + JObject jObject = JObject.Parse(newV); + newV = Convert.ToString(jObject.SelectToken("tag_name")); - if (result < 0) - { - //MessageBox.Show($"New version {versionWeb} available! Your version: {Application.ProductVersion}"); - Update updateform = new Update(); - updateform.ShowDialog(); - updateToolStripMenuItem.Visible = true; - timerUpdateBlink.Start(); - } + var versionNow = new Version(Application.ProductVersion); + var versionWeb = new Version(newV); - ///////////////////////// + var result = versionNow.CompareTo(versionWeb); - //HideCaret(richTextBox2.Handle); - richtbList.SelectionStart = richtbList.Text.Length; - firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2")); - } - catch (Exception) + if (result < 0) { + //MessageBox.Show($"New version {versionWeb} available! Your version: {Application.ProductVersion}"); + Update updateform = new Update(); + updateform.ShowDialog(); + updateToolStripMenuItem.Visible = true; + timerUpdateBlink.Start(); } - + ///////////////////////// + + //HideCaret(richTextBox2.Handle); + richtbList.SelectionStart = richtbList.Text.Length; + firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2")); + } + catch (Exception) + { } - } private void richtbList_TextChanged(object sender, EventArgs e) @@ -802,5 +806,9 @@ private void closeToolStripMenuItem_Click(object sender, EventArgs e) Application.Exit(); } + private void timerCheckForUpdate_Tick(object sender, EventArgs e) + { + CheckForUpdate(); + } } } diff --git a/WaGis IP-Blacklister/Form1.resx b/WaGis IP-Blacklister/Form1.resx index 1710c0f..3710d03 100644 --- a/WaGis IP-Blacklister/Form1.resx +++ b/WaGis IP-Blacklister/Form1.resx @@ -141,6 +141,9 @@ 961, 19 + + 1156, 19 + 66 From 450b67dec1a14021875c85c126feaa9de6599e6b Mon Sep 17 00:00:00 2001 From: WaGi <38970388+WaGi-Coding@users.noreply.github.com> Date: Thu, 26 Sep 2019 13:52:55 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 886caef..711e8ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WaGi's IP-Blacklister (Windows Firewall) [>DOWNLOAD HERE<](https://github.com/WaGi-Coding/WaGis-Mass-IP-Blacklister-Windows/releases) -![Application Overview](https://i.imgur.com/uBFNba4.png) +![Application Overview](https://i.imgur.com/Pn7tANy.png) @@ -8,7 +8,7 @@ __Why you made this?__ -I had to automatically block a mass of IP-Addresses. I did it with a Batch script first, but hell that was taking about 2 hours every time for 20k IPs. +I had to automatically block a mass of IP-Addresses. I did it with a simple Batch script first, but hell that was taking about 2 hours every time for 20k IPs, so i decided to create this app after realizing the creating of rules is much much faster that way. __What is this Application for?__ @@ -37,8 +37,8 @@ __Additional Info__ __.NET Framework 4.6.1__ __Tested on:__ -* Windows 10 +* Windows 10 Pro * Windows Server 2012 R2 -* Windows Server 2008 R2(in compatibility mode for Windows 7 only - need to fix that) +* Windows Server 2008 R2 * Windows Server 2016 * Windows 7 (1k Block Size instead of 10k - Programm now does this automatically) From 59282ebfaa545fdf06b1a872c6b6be7dae8a81fe Mon Sep 17 00:00:00 2001 From: WaGi Date: Thu, 26 Sep 2019 15:41:31 +0200 Subject: [PATCH 3/4] 1.3.7.5 update --- WaGis IP-Blacklister/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WaGis IP-Blacklister/Properties/AssemblyInfo.cs b/WaGis IP-Blacklister/Properties/AssemblyInfo.cs index 79c7ee3..48b5675 100644 --- a/WaGis IP-Blacklister/Properties/AssemblyInfo.cs +++ b/WaGis IP-Blacklister/Properties/AssemblyInfo.cs @@ -20,5 +20,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.7")] -[assembly: AssemblyFileVersion("1.3.7")] +[assembly: AssemblyVersion("1.3.7.5")] +[assembly: AssemblyFileVersion("1.3.7.5")] From 80b8d57e3916d02ef49b2a8df831476d64d23c00 Mon Sep 17 00:00:00 2001 From: WaGi Date: Thu, 26 Sep 2019 15:42:04 +0200 Subject: [PATCH 4/4] Improved IP matching --- WaGis IP-Blacklister/Form1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WaGis IP-Blacklister/Form1.cs b/WaGis IP-Blacklister/Form1.cs index 7a4c735..72b99ee 100644 --- a/WaGis IP-Blacklister/Form1.cs +++ b/WaGis IP-Blacklister/Form1.cs @@ -203,7 +203,7 @@ private void btnADD_Click(object sender, EventArgs e) //IPv6 CIDR aka. IP-Range support REGEX by WaGi-Coding--- (\b((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?\b)(?!\/) //IPv4 CIDR aka IP-Range support by WaGi-Coding---- (\b([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?\b)(?!\/) - allips.AddRange(Regex.Matches(richtbList.Text, @"((\b((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?\b)(?!\/))|((\b([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?\b)(?!\/))") + allips.AddRange(Regex.Matches(richtbList.Text, @"((\b((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(\/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?\b)(?!\/))|((\b([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?\b)(?!\/))", RegexOptions.IgnoreCase) .Cast() .Select(m => m.Value) .ToList());