this slowpoke moves

Ermittle alle Firewall Regeln

uses ComObj, ActiveX

procedure TForm1.FormCreate(Sender: TObject);
var
 CurrentProfiles : Integer;
 fwPolicy2       : OleVariant;
 RulesObject     : OleVariant;
 rule            : OleVariant;
 oEnum           : IEnumvariant;
 iValue          : LongWord;

 Const
 NET_FW_IP_PROTOCOL_TCP = 6;
 NET_FW_ACTION_ALLOW = 1;
 NET_FW_IP_PROTOCOL_UDP = 6;
begin
  fwPolicy2   := CreateOleObject('HNetCfg.FwPolicy2');
  RulesObject := fwPolicy2.Rules;
  CurrentProfiles := fwPolicy2.CurrentProfileTypes;

  //Writeln('Rules:');

  oEnum         := IUnknown(Rulesobject._NewEnum) as IEnumVariant;
  while oEnum.Next(1, rule, iValue) = 0 do
  begin
    if (rule.Profiles And CurrentProfiles)<>0 then
    begin
        Memo1.Lines.Add('  Rule Name:          ' + rule.Name);
        Memo1.Lines.Add('   ----------------------------------------------');
        Memo1.Lines.Add('  Description:        ' + rule.Description);
        Memo1.Lines.Add('  Application Name:   ' + rule.ApplicationName);
        Memo1.Lines.Add('  Service Name:       ' + rule.ServiceName);

        if (rule.Protocol = NET_FW_IP_PROTOCOL_TCP) or (rule.Protocol = NET_FW_IP_PROTOCOL_UDP) then
        begin
          Memo1.Lines.Add('  Local Ports:        ' + rule.LocalPorts);
          Memo1.Lines.Add('  Remote Ports:       ' + rule.RemotePorts);
          Memo1.Lines.Add('  LocalAddresses:     ' + rule.LocalAddresses);
          Memo1.Lines.Add('  RemoteAddresses:    ' + rule.RemoteAddresses);
        end;
      end;
   end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate