Einzelnen Beitrag anzeigen

Morphie

Registriert seit: 27. Apr 2008
Ort: Rahden
630 Beiträge
 
#35

Re: mini Firewall programmieren ??

  Alt 26. Jun 2008, 08:33
Hmmm, dann bin ich da wohl zu blööd zu
Delphi-Quellcode:
procedure netzsperren(MyIP: String);
var
   IpLocal : TIpBytes;
   ipOther : TIpBytes;
   ipOtherMask : TIpBytes;
   ipMy : TIpBytes;
   ipMyMask : TIpBytes;
begin
   if (MyIP <> '') and Not Assigned(Handle_Interface) then begin
      FillChar(IpLocal, 4, #0);
      IpLocal := StrToIpBytes(MyIP);

      PfCreateInterface(0, PF_ACTION_DROP, PF_ACTION_DROP, False, False, Handle_Interface);
      PfBindInterfaceToIPAddress(Handle_Interface, PF_IPV4, @ipLocal);


      ipMy := StrToIpBytes(PChar(MyIP));
      ipMyMask := StrToIpBytes('255.255.255.255');
      //
      ipOther := StrToIpBytes('0.0.0.0');
      ipOtherMask := StrToIpBytes('0.0.0.0');

      // Eingehende Pakete
      ZeroMemory(@ipFltIn, SizeOf(ipFltIn));
      ipFltIn.dwFilterFlags := 0;
      ipFltIn.dwRule := 0;
      ipFltIn.pfatType := PF_IPV4;
      ipFltIn.fLateBound := 0;
      ipFltIn.dwProtocol := FILTER_PROTO_TCP;

      ipFltIn.wDstPort := FILTER_TCPUDP_PORT_ANY;
      ipFltIn.wDstPortHighRange := FILTER_TCPUDP_PORT_ANY;
      ipFltIn.DstAddr := @ipMy;
      ipFltIn.DstMask := @ipMyMask;
      ipFltIn.wSrcPort := 3389;
      ipFltIn.wSrcPortHighRange := 3389;
      ipFltIn.SrcAddr := @ipOther;
      ipFltIn.SrcMask := @ipOtherMask;

      // Ausgehende Pakete
      ZeroMemory(@ipFltOut, SizeOf(ipFltOut));
      ipFltOut.dwFilterFlags := 0;
      ipFltOut.dwRule := 0;
      ipFltOut.pfatType := PF_IPV4;
      ipFltOut.fLateBound := 0;
      ipFltOut.dwProtocol := FILTER_PROTO_TCP;
      ipFltOut.wDstPort := 3389;
      ipFltOut.wDstPortHighRange := 3389;
      ipFltOut.DstAddr := @ipOther;
      ipFltOut.DstMask := @ipOtherMask;
      ipFltOut.wSrcPort := FILTER_TCPUDP_PORT_ANY;
      ipFltOut.wSrcPortHighRange := FILTER_TCPUDP_PORT_ANY;
      ipFltOut.SrcAddr := @ipMy;
      ipFltOut.SrcMask := @ipMyMask;

      PfAddFiltersToInterface(Handle_Interface, 1, @ipFltIn, 1, @ipFltOut, nil);
      //portfreigeben(3389,MyIP); //RDP
      {portfreigeben(137,MyIP); //NetBIOS Name Service
      portfreigeben(139,MyIP); //NetBIOS File and Printer Sharing
      portfreigeben(445,MyIP); //NetBIOS File and Printer Sharing
      portfreigeben(135,MyIP); //RPC
      portfreigeben(1025,MyIP); //RPC
      portfreigeben(2049,MyIP); //NFS
      portfreigeben(1080,MyIP); //SOCKS
      portfreigeben(7,MyIP); //PING Request
      portfreigeben(8700,MyIP); //DER SERVER!!!}

   end;
end;
Da sollte er doch eigentlich alle Ports blockieren, außer 3389, richtig?
Bin über RDP auf dem Rechner drauf, auf dem ich das Programm ausführe, die Verbindung wird trotzdem unterbrochen...
Gedankenfehler von mir?
  Mit Zitat antworten Zitat