MalwareSourceCode/MSIL/Virus/Win32/S/Virus.Win32.Sality.sil-66a8bf80b7d1c03c218a77899ddc10c75b21c3784127eb96343f22ad5b31b4d6/PinnacleSys/FirewallConfig/WinXPFirewall.cs

135 lines
3.8 KiB
C#
Raw Normal View History

2022-08-18 11:28:56 +00:00
// Decompiled with JetBrains decompiler
// Type: PinnacleSys.FirewallConfig.WinXPFirewall
// Assembly: PMSInstallInit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 1143B458-69F7-4F72-9059-A13F9AB730BC
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare.00004-msil\Virus.Win32.Sality.sil-66a8bf80b7d1c03c218a77899ddc10c75b21c3784127eb96343f22ad5b31b4d6.exe
using System;
using System.Collections;
namespace PinnacleSys.FirewallConfig
{
public class WinXPFirewall
{
private INetFwMgr m_Mgr = (INetFwMgr) null;
public WinXPFirewall()
{
try
{
this.m_Mgr = (INetFwMgr) Activator.CreateInstance(Type.GetTypeFromProgID("hnetcfg.fwmgr"));
}
catch (Exception ex)
{
}
}
public bool Available => this.m_Mgr != null;
public bool AddApp(
string AppName,
string ProcessImageFileName,
bool bEnable,
NET_FW_SCOPE_ scope)
{
bool flag = false;
try
{
INetFwAuthorizedApplication instance = (INetFwAuthorizedApplication) Activator.CreateInstance(Type.GetTypeFromProgID("hnetcfg.fwauthorizedapplication"));
instance.Name = AppName;
instance.ProcessImageFileName = ProcessImageFileName;
instance.Enabled = bEnable;
instance.Scope = scope;
this.m_Mgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(instance);
flag = true;
}
catch
{
}
return flag;
}
public bool AddPort(
int port,
NET_FW_IP_PROTOCOL_ protocol,
string name,
bool enable,
bool local)
{
try
{
INetFwOpenPort port1 = this.GetPort(port, protocol);
if (port1 != null)
{
port1.Enabled = enable;
port1.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_LOCAL_SUBNET;
return true;
}
INetFwOpenPort instance = (INetFwOpenPort) Activator.CreateInstance(Type.GetTypeFromProgID("hnetcfg.FwOpenPort"));
instance.Enabled = enable;
instance.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_LOCAL_SUBNET;
instance.Name = name;
instance.Port = port;
instance.Protocol = protocol;
this.m_Mgr.LocalPolicy.CurrentProfile.GloballyOpenPorts.Add(instance);
return true;
}
catch (Exception ex)
{
return false;
}
}
public bool RemovePort(int port, NET_FW_IP_PROTOCOL_ protocol)
{
try
{
this.m_Mgr.LocalPolicy.CurrentProfile.GloballyOpenPorts.Remove(port, protocol);
return true;
}
catch (Exception ex)
{
return false;
}
}
public bool IsPortEnabled(int port, NET_FW_IP_PROTOCOL_ protocol)
{
INetFwOpenPort port1 = this.GetPort(port, protocol);
return port1 != null && port1.Enabled;
}
public INetFwOpenPort GetPort(int port, NET_FW_IP_PROTOCOL_ protocol)
{
INetFwProfile currentProfile = this.m_Mgr.LocalPolicy.CurrentProfile;
IEnumerator enumerator1 = currentProfile.GloballyOpenPorts.GetEnumerator();
INetFwOpenPort port1 = this.__GetPort(port, protocol, enumerator1);
if (port1 != null)
return port1;
foreach (INetFwService service in currentProfile.Services)
{
IEnumerator enumerator2 = service.GloballyOpenPorts.GetEnumerator();
INetFwOpenPort port2 = this.__GetPort(port, protocol, enumerator2);
if (port2 != null)
return port2;
}
return (INetFwOpenPort) null;
}
private INetFwOpenPort __GetPort(
int port,
NET_FW_IP_PROTOCOL_ protocol,
IEnumerator iter)
{
iter.Reset();
while (iter.MoveNext())
{
INetFwOpenPort current = (INetFwOpenPort) iter.Current;
if (current.Port == port && current.Protocol == protocol)
return current;
}
return (INetFwOpenPort) null;
}
}
}