Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PoKeRGT committed Jul 26, 2020
1 parent bd392f3 commit ad9cab2
Show file tree
Hide file tree
Showing 6 changed files with 821 additions and 0 deletions.
45 changes: 45 additions & 0 deletions FirewallCleanup/FWIfz.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.IO;
using System.Text.RegularExpressions;
using NetFwTypeLib;

namespace FirewallCleanup
{
class FWIfz
{
String pattern = @"\b[c-zC-Z]:\\";

public FWIfz()
{
int counter = 0;
Type tNetFwPolicy2 = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
INetFwPolicy2 fwPolicy2 = (INetFwPolicy2)Activator.CreateInstance(tNetFwPolicy2);
INetFwRules Rules = fwPolicy2.Rules;
IEnumerator rulesEnumerator = Rules.GetEnumerator();
foreach(INetFwRule rule in Rules)
{
String exePath = rule.ApplicationName as string;
if (exePath != null && exePath.Length > 0)
{
if (rule.Action == 0)
{
if (!File.Exists(exePath))
{
if (Regex.IsMatch(exePath, pattern))
{
counter += 1;
Console.WriteLine(exePath);
fwPolicy2.Rules.Remove(rule.Name);
}
}
}
}
}
Console.WriteLine("-");
Console.WriteLine(counter + " rules deleted.");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
16 changes: 16 additions & 0 deletions FirewallCleanup/FirewallCleanup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -43,11 +46,24 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FWIfz.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<COMReference Include="NetFwTypeLib">
<Guid>{58FBCF7C-E7A9-467C-80B3-FC65E8FCCA08}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
1 change: 1 addition & 0 deletions FirewallCleanup/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Program
{
static void Main(string[] args)
{
FWIfz fwi = new FWIfz();
}
}
}
76 changes: 76 additions & 0 deletions FirewallCleanup/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- Opciones del manifiesto UAC
Si quiere cambiar el nivel del Control de cuentas de usuario de Windows reemplace el
nodo requestedExecutionLevel por uno de los siguientes.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Especificar el elemento requestedExecutionLevel deshabilitará la virtualización de archivos y registros.
Quite este elemento si la aplicación necesita esta virtualización para la compatibilidad
con versiones anteriores.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Una lista de las versiones de Windows en la que se ha probado esta aplicación y
con la que se ha diseñado para que trabaje. Quite la marca de comentario de los elementos adecuados y Windows seleccionará
automáticamente el entorno más compatible. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indica que la aplicación tiene reconocimiento de PPP y Windows no la escalará de forma automática a
PPP superiores. Las aplicaciones de Windows Presentation Foundation (WPF) tienen reconocimiento de PPP automático y no necesitan
participar. Las aplicaciones de Windows Forms que apuntan a .NET Framework 4.6 que participan en esta configuración, también
deben establecer la configuración 'EnableWindowsFormsHighDpiAutoResizing' en 'true' en app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->

<!-- Habilitar los temas para los controles y cuadros de diálogo comunes de Windows (Windows XP y versiones posteriores) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
Loading

0 comments on commit ad9cab2

Please sign in to comment.