Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Windows Server 2016 RDP Bağlantı Saat Aralığı Belirleme
#1
Merhabalar,

Çok bilgim yok açıkcası. Biraz araştırdım fakat kayda değer bir şey bulamadım.
Yardımlarınızı rica ediyorum. Şimdiden herkese teşekkür ederim.

Windows Server 2016 kurulu bir sistem mevcut. Bu sisteme RDP (uzak masaüstü bağlantısı) ile
kullanıcılar (10 kişi) bağlanıyor.

İstenen ise, kullanıcılara RDP bağlantısı yaparken saat 11:00 ile 16:00 arası izin verilsin.
Diğer saatler arasında sisteme bağlantı kuramasın ve mevcut ise sistem açılış esnasında bağlantı zaman aralığında değilsiniz
gibi bir uyarıda verebilirmi.

Teşekkürler.
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla
#2
(02-12-2020, Saat: 13:11)hi_selamlar Adlı Kullanıcıdan Alıntı: Merhabalar,

Çok bilgim yok açıkcası. Biraz araştırdım fakat kayda değer bir şey bulamadım.
Yardımlarınızı rica ediyorum. Şimdiden herkese teşekkür ederim.

Windows Server 2016 kurulu bir sistem mevcut. Bu sisteme RDP (uzak masaüstü bağlantısı) ile
kullanıcılar (10 kişi) bağlanıyor.

İstenen ise, kullanıcılara RDP bağlantısı yaparken saat 11:00 ile 16:00 arası izin verilsin.
Diğer saatler arasında sisteme bağlantı kuramasın ve mevcut ise sistem açılış esnasında bağlantı zaman aralığında değilsiniz
gibi bir uyarıda verebilirmi.

Teşekkürler.

yapmanız gereken listening rdp portuna gelen bağlantıları red etmek zamanlamayıda kendiniz ufak bir fonksiyon ile yapabilirsiniz.

bunu windows firewall ına zaman aralıkları ile kural ekleyerek çıkararakda yapabilirsiniz,
yada kullanıcı oturum açtığında explorer.exe den önce çalıştırılacak sizin exe niz zamana ve açık kullanıcı adına bakarak kullanıcıyı logout eden mesaj yayınlar, kullanıcı bağlanır dialogda uyarıyı görür 3sn sonra log out edilir.

veya sistemde bir hesapda çalışan bir uygulama 1sn de bir loggedin olmuş kullanıcı listesini alıp, zaman göre logout edebilir,
diğer kullanıcı hesabına net send apisi gibi bir yöntemle sistem mesajı gönderir dialog açıp, 3sn sonra oturumunu kapatılacakdır uyarısıda gösterebilir.

aşağıda size basit bir firewall kaynak kodu paylaşıyorum, eklenen ruleleri silebilirsinizde zaman aralıklarına göre.


Kullanım Örneği;
program netblock1;
{$APPTYPE CONSOLE}

uses
 Windows,
 SysUtils,
 Classes,
 IPFilter,
 winsock;

Begin
 // Create filter object
 with TIpFilter.Create do
 begin
    // Set active
    Active:=True;
    // Some example filters
    AddOutboundFilter(EmptyStr, protoUdp, 5001); // Filter all outbound udp requests going to port 5001
    AddOutboundFilter(EmptyStr, protoIcmp, FILTER_ICMP_TYPE_ANY); // Filter all outgoing ICMP requests
    AddInboundFilter('www.experts-exchange.com', protoTcp, 80); // Filter any incoming request from EE on port 80
    AddOutboundFilter('www.google.com.tr', protoTcp, 80); // Filter outgoing request to google      
    AddInboundFilter('www.google.com.tr', protoTcp, 80);
    Readln;
    // Free (this will remove all filters)
    Free;
 end;


end.

IPFilter.Pas;
unit IPFilter;
////////////////////////////////////////////////////////////////////////////////
//
//   Description    :  TCPIP network connection blocking unit
//
////////////////////////////////////////////////////////////////////////////////
interface

////////////////////////////////////////////////////////////////////////////////
//   Include units
////////////////////////////////////////////////////////////////////////////////
uses
 Windows,
 SysUtils,
 Classes,
 WinSock;

////////////////////////////////////////////////////////////////////////////////
//   IP helper library
////////////////////////////////////////////////////////////////////////////////
const
 IPHLPAPI                      =  'IPHLPAPI.DLL';

////////////////////////////////////////////////////////////////////////////////
//   Data types
////////////////////////////////////////////////////////////////////////////////
type
 PByteArray                    =  ^TByteArray;
 TByteArray                    =  Array [0..Pred(MaxInt)] of Byte;
 PIpBytes                      =  ^TIpBytes;
 TIpBytes                      =  Array [0..3] of Byte;

////////////////////////////////////////////////////////////////////////////////
//   FltDefs translation
////////////////////////////////////////////////////////////////////////////////
Const
INADDR_NONE             =$ffffffff;

type
 FILTER_HANDLE                 =  Pointer;
 PFILTER_HANDLE                =  ^FILTER_HANDLE;
 INTERFACE_HANDLE              =  Pointer;
 PINTERFACE_HANDLE             =  ^INTERFACE_HANDLE;

const
 GF_FRAGMENTS                  =  2;
 GF_STRONGHOST                 =  8;
 GF_FRAGCACHE                  =  9;

type
 GLOBAL_FILTER                 =  Integer;
 PGLOBAL_FILTER                =  ^GLOBAL_FILTER;

const
 PF_IPV4                       =  0;
 PF_IPV6                       =  1;

type
 PFADDRESSTYPE                 =  Integer;
 PPFADDRESSTYPE                =  ^PFADDRESSTYPE;

const
 PF_ACTION_FORWARD             =  0;
 PF_ACTION_DROP                =  1;

type
 PFFORWARD_ACTION              =  Integer;
 PPFFORWARD_ACTION             =  ^PPFFORWARD_ACTION;

const
 PFFT_FILTER                   =  1;
 PFFT_FRAG                     =  2;
 PFFT_SPOOF                    =  3;

type
 PFFRAMETYPE                   =  Integer;
 PPFFRAMETYPE                  =  ^PFFRAMETYPE;

type
 _PF_FILTER_DESCRIPTOR         =  packed record
    dwFilterFlags:             DWORD;
    dwRule:                    DWORD;
    pfatType:                  PFADDRESSTYPE;
    SrcAddr:                   PIpBytes;
    SrcMask:                   PIpBytes;
    DstAddr:                   PIpBytes;
    DstMask:                   PIpBytes;
    dwProtocol:                DWORD;
    fLateBound:                DWORD;
    wSrcPort:                  Word;
    wDstPort:                  Word;
    wSrcPortHighRange:         Word;
    wDstPortHighRange:         Word;
 end;
 PF_FILTER_DESCRIPTOR          =  _PF_FILTER_DESCRIPTOR;
 PPF_FILTER_DESCRIPTOR         =  ^PF_FILTER_DESCRIPTOR;

type
 _PF_FILTER_STATS              =  packed record
    dwNumPacketsFiltered:      DWORD;
    info:                      PF_FILTER_DESCRIPTOR;
 end;
 PF_FILTER_STATS               =  _PF_FILTER_STATS;
 PPF_FILTER_STATS              =  ^PF_FILTER_STATS;

type
 _PF_INTERFACE_STATS           =  packed record
    pvDriverContext:           Pointer;
    dwFlags:                   DWORD;
    dwInDrops:                 DWORD;
    dwOutDrops:                DWORD;
    eaInAction:                PFFORWARD_ACTION;
    eaOutAction:               PFFORWARD_ACTION;
    dwNumInFilters:            DWORD;
    dwNumOutFilters:           DWORD;
    dwFrag:                    DWORD;
    dwSpoof:                   DWORD;
    dwReserved1:               DWORD;
    dwReserved2:               DWORD;
    liSyn:                     LARGE_INTEGER;
    liTotalLogged:             LARGE_INTEGER;
    dwLostLogEntries:          DWORD;
    FilterInfo:                Array [0..0] of PF_FILTER_STATS;
 end;
 PF_INTERFACE_STATS            =  _PF_INTERFACE_STATS;
 PPF_INTERFACE_STATS           =  ^PF_INTERFACE_STATS;

type
 _PF_LATEBIND_INFO             =  packed record
    SrcAddr:                   PByteArray;
    DstAddr:                   PByteArray;
    Mask:                      PByteArray;
 end;
 PF_LATEBIND_INFO              =  _PF_LATEBIND_INFO;
 PPF_LATEBIND_INFO             =  ^PF_LATEBIND_INFO;

type
 _PFLOGFRAME                   =  packed record
    Timestamp:                 LARGE_INTEGER;
    pfeTypeOfFrame:            PFFRAMETYPE;
    dwTotalSizeUsed:           DWORD;
    dwFilterRule:              DWORD;
    wSizeOfAdditionalData:     Word;
    wSizeOfIpHeader:           Word;
    dwInterfaceName:           DWORD;
    dwIPIndex:                 DWORD;
    bPacketData:               Array [0..0] of Byte;
 end;
 PFLOGFRAME                    =  _PFLOGFRAME;
 PPFLOGFRAME                   =  ^PFLOGFRAME;

const
 FILTER_PROTO_ANY              =  $00;
 FILTER_PROTO_ICMP             =  $01;
 FILTER_PROTO_TCP              =  $06;
 FILTER_PROTO_UDP              =  $11;
 FILTER_TCPUDP_PORT_ANY        =  $00;

const
 FILTER_ICMP_TYPE_ANY          =  $FF;
 FILTER_ICMP_CODE_ANY          =  $FF;

const
 FD_FLAGS_NOSYN                =  $01;
 FD_FLAGS_ALLFLAGS             =  FD_FLAGS_NOSYN;

const
 LB_SRC_ADDR_USE_SRCADDR_FLAG  =  $00000001;
 LB_SRC_ADDR_USE_DSTADDR_FLAG  =  $00000002;
 LB_DST_ADDR_USE_SRCADDR_FLAG  =  $00000004;
 LB_DST_ADDR_USE_DSTADDR_FLAG  =  $00000008;
 LB_SRC_MASK_LATE_FLAG         =  $00000010;
 LB_DST_MASK_LATE_FLAG         =  $00000020;

const
 ERROR_BASE                    =  23000;
 PFERROR_NO_PF_INTERFACE       =  (ERROR_BASE + 0); // never returned.
 PFERROR_NO_FILTERS_GIVEN      =  (ERROR_BASE + 1);
 PFERROR_BUFFER_TOO_SMALL      =  (ERROR_BASE + 2);
 ERROR_IPV6_NOT_IMPLEMENTED    =  (ERROR_BASE + 3);

function   PfCreateInterface(
          dwName:              DWORD;
          inAction:            PFFORWARD_ACTION;
          outAction:           PFFORWARD_ACTION;
          bUseLog:             BOOL;
          bMustBeUnique:       BOOL;
          var ppInterface:     INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfCreateInterface@24';

function   PfDeleteInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteInterface@4';

function   PfAddFiltersToInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR;
          pfHandle:            PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';

function   PfRemoveFiltersFromInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';

function   PfRemoveFilterHandles(
          pInterface:          INTERFACE_HANDLE;
          cFilters:            DWORD;
          pvHandles:           PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';

function   PfUnBindInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfUnBindInterface@4';

function   PfBindInterfaceToIndex(
          pInterface:          INTERFACE_HANDLE;
          dwIndex:             DWORD;
          pfatLinkType:        PFADDRESSTYPE;
          LinkIPAddress:       PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';

function   PfBindInterfaceToIPAddress(
          pInterface:          INTERFACE_HANDLE;
          pfatLinkType:        PFADDRESSTYPE;
          IPAddress:           PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';

function   PfRebindFilters(
          pInterface:          INTERFACE_HANDLE;
          pLateBindInfo:       PPF_LATEBIND_INFO): DWORD;
          stdcall; external IPHLPAPI name '_PfRebindFilters@8';

function   PfAddGlobalFilterToInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';

function   PfRemoveGlobalFilterFromInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';

function   PfMakeLog(
          hEvent:              THandle): DWORD;
          stdcall; external IPHLPAPI name '_PfMakeLog@4';

function   PfSetLogBuffer(
          pbBuffer:            PByteArray;
          dwSize:              DWORD;
          dwThreshold:         DWORD;
          dwEntries:           DWORD;
          pdwLoggedEntries:    PDWORD;
          pdwLostEntries:      PDWORD;
          pdwSizeUsed:         PDWORD): DWORD;
          stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';

function   PfDeleteLog: DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteLog@0';

function   PfGetInterfaceStatistics(
          pInterface:          INTERFACE_HANDLE;
          ppfStats:            PPF_INTERFACE_STATS;
          pdwBufferSize:       PDWORD;
          fResetCounters:      BOOL): DWORD;
          stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';

function   PfTestPacket(
          pInInterface:        INTERFACE_HANDLE;
          pOutInterface:       INTERFACE_HANDLE;
          cBytes:              DWORD;
          pbPacket:            PByteArray;
          ppAction:            PPFFORWARD_ACTION): DWORD;
          stdcall; external IPHLPAPI name '_PfTestPacket@20';

////////////////////////////////////////////////////////////////////////////////
//   IP filter class wrapper
////////////////////////////////////////////////////////////////////////////////
const
 IP_LOCALHOST      =  'localhost';
 IP_MASKALL        =  '0.0.0.0';
 IP_MASKNONE       =  '255.255.255.255';

type
 TIpProtocol       =  (protoAny, protoIcmp, protoTcp, protoUdp);
 TIpFilter         =  class(TObject)
 private
    // Private declarations
    FHandle:       INTERFACE_HANDLE;
    FLocalIP:      TIpBytes;
    FActive:       Boolean;
    FOutbound:     TList;
    FInbound:      TList;
    function       AllocIpBytes(Address: String): PIpBytes;
    function       AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
    procedure      FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
 protected
    // Protected declarations
    function       GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetInboundFilterCount: Integer;
    function       GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetOutboundFilterCount: Integer;
    function       Startup: Boolean;
    procedure      SetActive(Value: Boolean);
    procedure      Cleanup;
 public
    // Public declarations
    constructor    Create;
    destructor     Destroy; override;
    function       AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    function       AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    procedure      ClearInboundFilters;
    procedure      ClearOutboundFilters;
    procedure      DeleteInboundFilter(Index: Integer);
    procedure      DeleteOutboundFilter(Index: Integer);
    property       Active: Boolean read FActive write SetActive;
    property       InterfaceHandle: INTERFACE_HANDLE read FHandle;
    property       InboundFilterCount: Integer read GetInboundFilterCount;
    property       InboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetInboundFilter;
    property       OutboundFilterCount: Integer read GetOutboundFilterCount;
    property       OutboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetOutboundFilter;
 end;

////////////////////////////////////////////////////////////////////////////////
//   Utility functions
////////////////////////////////////////////////////////////////////////////////
function   StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
function   GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;

implementation

////////////////////////////////////////////////////////////////////////////////
//   Protected variables
////////////////////////////////////////////////////////////////////////////////
var
 wsaData:       TWSAData;

////////////////////////////////////////////////////////////////////////////////
//   TIpFilter
////////////////////////////////////////////////////////////////////////////////
procedure TIpFilter.ClearInboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FInbound.Count) downto 0 do DeleteInboundFilter(dwIndex);

end;

procedure TIpFilter.ClearOutboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FOutbound.Count) downto 0 do DeleteOutboundFilter(dwIndex);

end;

procedure TIpFilter.DeleteInboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FInbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FInbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 1, lpFilter, 0, nil) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

procedure TIpFilter.DeleteOutboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FOutbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FOutbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 0, nil, 1, lpFilter) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

function TIpFilter.GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FInbound[Index]^);

end;

function TIpFilter.GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FOutbound[Index]^);

end;

function TIpFilter.GetInboundFilterCount: Integer;
begin

 // Return filter count
 result:=FInbound.Count;

end;

function TIpFilter.GetOutboundFilterCount: Integer;
begin

 // Return filter count
 result:=FOutbound.Count;

end;

function TIpFilter.AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wDstPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wDstPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    lpFilter^.wSrcPort:=Port;
    lpFilter^.wSrcPortHighRange:=Port;
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.SrcAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.SrcMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.SrcAddr:=AllocIpBytes(Address);
       lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Set destination address
    lpFilter^.DstAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 1, lpFilter, 0, nil, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FInbound.Add(lpFilter);
 end;

end;

function TIpFilter.AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    // Filter all remote ports coming into specified port
    lpFilter^.wDstPort:=Port;
    lpFilter^.wDstPortHighRange:=Port;
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wSrcPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wSrcPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Set source address
    lpFilter^.SrcAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.DstAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.DstMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.DstAddr:=AllocIpBytes(Address);
       lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 0, nil, 1, lpFilter, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FOutbound.Add(lpFilter);
 end;

end;

function TIpFilter.AllocIpBytes(Address: String): PIpBytes;
begin

 // Allocate memory for IP byte setting and convert address
 result:=StrToIp(PChar(Address), AllocMem(SizeOf(TIpBytes)));

end;

function TIpFilter.AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 result:=AllocMem(SizeOf(PF_FILTER_DESCRIPTOR));

 // Set defaults for all filters
 result^.dwFilterFlags:=FD_FLAGS_NOSYN;
 result^.dwRule:=0;
 result^.pfatType:=PF_IPV4;
 result^.fLateBound:=0;

 // Set protocol filtering
 case Protocol of
    protoAny    :  result^.dwProtocol:=FILTER_PROTO_ANY;
    protoIcmp   :  result^.dwProtocol:=FILTER_PROTO_ICMP;
    protoTcp    :  result^.dwProtocol:=FILTER_PROTO_TCP;
    protoUdp    :  result^.dwProtocol:=FILTER_PROTO_UDP;
 else
    // Sanity check
    result^.dwProtocol:=FILTER_PROTO_ANY;
 end;

end;

procedure TIpFilter.FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
begin

 // Check filter
 if Assigned(Filter) then
 begin
    // Free memory for addresses and masks
    if Assigned(Filter^.SrcAddr) then FreeMem(Filter.SrcAddr);
    if Assigned(Filter^.SrcMask) then FreeMem(Filter.SrcMask);
    if Assigned(Filter^.DstAddr) then FreeMem(Filter.DstAddr);
    if Assigned(Filter^.DstMask) then FreeMem(Filter.DstMask);
    // Free memory for record struct
    FreeMem(Filter);
 end;

end;

procedure TIpFilter.SetActive(Value: Boolean);
begin

 // Check for state change
 if (Value <> FActive) then
 begin
    // Check old state
    if FActive then
       // Unbind the interface
       Win32Check(PfUnBindInterface(FHandle) = NO_ERROR)
    else
       Win32Check(PfBindInterfaceToIPAddress(FHandle, PF_IPV4, @FLocalIP) = NO_ERROR);
    // Set new state
    FActive:=Value;
 end;

end;

function TIpFilter.Startup: Boolean;
begin

 // Get the local IP address
 GetLocalIPAddr(@FLocalIP);

 // Create the interface (do not bind yet)
 result:=(PfCreateInterface(0, PF_ACTION_FORWARD, PF_ACTION_FORWARD, False, True, FHandle) = NO_ERROR);

end;

procedure TIpFilter.Cleanup;
var  dwIndex:       Integer;
begin

 // Resource protection
 try
    // Clear all filters from outbound list (do not worry about removing them)
    for dwIndex:=Pred(FOutbound.Count) downto 0 do FreeFilter(FOutbound[dwIndex]);
    // Clear all filters from inbound list (do not worry about removing them)
    for dwIndex:=Pred(FInbound.Count) downto 0 do FreeFilter(FInbound[dwIndex]);
 finally
    // Clear the lists
    FOutbound.Clear;
    FInbound.Clear;
    // Unbind the interface handle (if active)
    if FActive then PfUnBindInterface(FHandle);
    // Delete the interface handle
    PfDeleteInterface(FHandle);
 end;

end;

constructor TIpFilter.Create;
begin

 // Perform inherited
 inherited Create;

 // Create internal lists
 FActive:=False;
 FOutbound:=TList.Create;
 FInbound:=TList.Create;

 // Startup
 Win32Check(Startup);

end;

destructor TIpFilter.Destroy;
begin

 // Resource protection
 try
    // Cleanup lists and delete the interface
    Cleanup;
    // Free the lists
    FreeAndNil(FOutbound);
    FreeAndNil(FInbound);
 finally
    // Perform inherited
    inherited Destroy;
 end;

end;

function StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
var  dwAddr:     LongWord;
    pheAddr:    PHostEnt;
begin

 // Check for common settings
 if Assigned(lpszIP) and (StrIComp(lpszIP, IP_LOCALHOST) = 0) then
    // Get the local ip address
    GetLocalIPAddr(lpipAddr)
 else
 begin
    // Check assignment
    if Assigned(lpszIp) then
    begin
       // Check mask all
       if (StrIComp(lpszIP, IP_MASKALL) = 0) then
          dwAddr:=0
       // Check mask none
       else if (StrIComp(lpszIP, IP_MASKNONE) = 0) then
          dwAddr:=INADDR_NONE
       else
       begin
          // Attempt . notation conversion
          dwAddr:=inet_addr(lpszIP);
          // Check conversion (IP_MASKNONE will have already been handled)
          if (dwAddr = LongWord(INADDR_NONE)) then
          begin
             // Attempt host name conversion
             pheAddr:=gethostbyname(lpszIP);
             // Check conversion
             if Assigned(pheAddr) then
                // Get the ip address
                Move(pheAddr^.h_addr_list^^, dwAddr, SizeOf(LongWord))
             else
                // Failed to get the ip address, use none
                dwAddr:=INADDR_NONE;
          end;
       end
    end
    else
       // Convert IP_MASKALL
       dwAddr:=inet_addr(IP_MASKALL);
    // Move the longword into the byte array
    Move(dwAddr, lpipAddr^, SizeOf(LongWord));
 end;

 // Result is the pointer to passed ip address buffer
 result:=lpipAddr;

end;

function GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;
var  lpszLocal:  Array [0..255] of Char;
    pheAddr:    PHostEnt;
begin

 // Get the host name
 if (gethostname(lpszLocal, SizeOf(lpszLocal)) = 0) then
 begin
    // Get the host ent structure
    pheAddr:=gethostbyname(lpszLocal);
    if Assigned(pheAddr) then
    begin
       // Get the ip address
       Move(pheAddr^.h_addr_list^^, lpipAddr^, 4);
       result:=True;
    end
    else
       // Failure
       result:=False;
 end
 else
    // Failure
    result:=False;

end;

initialization

 // Initialize winsock so we can get the local ip address and call winsock functions
 WSAStartup(MakeWord(1, 1), wsaData);

finalization

 // Cleanup
 WSACleanup;

end.


ipheader.pas
Unit ipheader;

Interface

Uses
 windows, winsock;

Const
 TCPFlag_URG = 0;
 TCPFlag_ACK = 2;
 TCPFlag_PSH = 4;
 TCPFlag_RST = 8;
 TCPFlag_SYN = 16;
 TCPFlag_FYN = 32;

 IPPROTO_IP = 0; //dummy for IP
 IPPROTO_ICMP = 1; // control message protocol
 IPPROTO_IGMP = 2; //internet group management protocol
 IPPROTO_GGP = 3; //  gateway^2 (deprecated)
 IPPROTO_TCP = 6; //   tcp
 IPPROTO_PUP = 12; //  pup
 IPPROTO_UDP = 17; //  user datagram protocol
 IPPROTO_IDP = 22; //  xns idp
 IPPROTO_ND = 77; //  UNOFFICIAL net disk proto

 IPPROTO_RAW = 255; // raw IP packet
 IPPROTO_MAX = 256;

 SIO_RCVALL = $98000001;

Type

 TIPPROTO = Record
   itype: word;
   name: String;
 End;

 PIP_Header = ^TIP_Header;
 TIP_Header = Packed Record
   ip_verlen: Byte;  
   ip_tos: Byte; 
   ip_totallength: Word;  
   ip_id: Word;  
   ip_offset: Word;  
   ip_ttl: Byte;  
   ip_protocol: Byte;  
   ip_checksum: Word; 
   ip_srcaddr: LongWord;  
   ip_destaddr: LongWord; 
 End;
 PUDP_Header = ^TUDP_Header;
 TUDP_Header = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   udp_length: Word;  
   udp_checksum: Word;  
 End;
 PTCP_Hearder = ^TTCP_Hearder;
 TTCP_Hearder = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   Sequenceno: LongWord;  
   Acknowledgeno: LongWord;  
   DataOffset: Byte; //
   flag: byte;
   Windows: WORD;  
   checksum: WORD;  
   UrgentPointer: WORD; 
 End;

Const
 IPPROTO: Array[0..8] Of TIPPROTO = (
   (iType: IPPROTO_IP; name: 'IP'),
   (iType: IPPROTO_ICMP; name: 'ICMP'),
   (iType: IPPROTO_IGMP; name: 'IGMP'),
   (iType: IPPROTO_GGP; name: 'GGP'),
   (iType: IPPROTO_TCP; name: 'TCP'),
   (iType: IPPROTO_PUP; name: 'PUP'),
   (iType: IPPROTO_UDP; name: 'UDP'),
   (iType: IPPROTO_IDP; name: 'IDP'),
   (iType: IPPROTO_ND; name: 'ND'));

Implementation

End.

Cevapla
#3
(02-12-2020, Saat: 13:23)hayalyilmaz43 Adlı Kullanıcıdan Alıntı:
(02-12-2020, Saat: 13:11)hi_selamlar Adlı Kullanıcıdan Alıntı: Merhabalar,

Çok bilgim yok açıkcası. Biraz araştırdım fakat kayda değer bir şey bulamadım.
Yardımlarınızı rica ediyorum. Şimdiden herkese teşekkür ederim.

Windows Server 2016 kurulu bir sistem mevcut. Bu sisteme RDP (uzak masaüstü bağlantısı) ile
kullanıcılar (10 kişi) bağlanıyor.

İstenen ise, kullanıcılara RDP bağlantısı yaparken saat 11:00 ile 16:00 arası izin verilsin.
Diğer saatler arasında sisteme bağlantı kuramasın ve mevcut ise sistem açılış esnasında bağlantı zaman aralığında değilsiniz
gibi bir uyarıda verebilirmi.

Teşekkürler.

yapmanız gereken listening rdp portuna gelen bağlantıları red etmek zamanlamayıda kendiniz ufak bir fonksiyon ile yapabilirsiniz.

bunu windows firewall ına zaman aralıkları ile kural ekleyerek çıkararakda yapabilirsiniz,
yada kullanıcı oturum açtığında explorer.exe den önce çalıştırılacak sizin exe niz zamana ve açık kullanıcı adına bakarak kullanıcıyı logout eden mesaj yayınlar, kullanıcı bağlanır dialogda uyarıyı görür 3sn sonra log out edilir.

aşağıda size basit bir firewall kaynak kodu paylaşıyorum, eklenen ruleleri silebilirsinizde zaman aralıklarına göre.


Kullanım Örneği;
program netblock1;
{$APPTYPE CONSOLE}

uses
 Windows,
 SysUtils,
 Classes,
 IPFilter,
 winsock;

Begin
 // Create filter object
 with TIpFilter.Create do
 begin
    // Set active
    Active:=True;
    // Some example filters
    AddOutboundFilter(EmptyStr, protoUdp, 5001); // Filter all outbound udp requests going to port 5001
    AddOutboundFilter(EmptyStr, protoIcmp, FILTER_ICMP_TYPE_ANY); // Filter all outgoing ICMP requests
    AddInboundFilter('www.experts-exchange.com', protoTcp, 80); // Filter any incoming request from EE on port 80
    AddOutboundFilter('www.google.com.tr', protoTcp, 80); // Filter outgoing request to google      
    AddInboundFilter('www.google.com.tr', protoTcp, 80);
    Readln;
    // Free (this will remove all filters)
    Free;
 end;


end.

IPFilter.Pas;
unit IPFilter;
////////////////////////////////////////////////////////////////////////////////
//
//   Description    :  TCPIP network connection blocking unit
//
////////////////////////////////////////////////////////////////////////////////
interface

////////////////////////////////////////////////////////////////////////////////
//   Include units
////////////////////////////////////////////////////////////////////////////////
uses
 Windows,
 SysUtils,
 Classes,
 WinSock;

////////////////////////////////////////////////////////////////////////////////
//   IP helper library
////////////////////////////////////////////////////////////////////////////////
const
 IPHLPAPI                      =  'IPHLPAPI.DLL';

////////////////////////////////////////////////////////////////////////////////
//   Data types
////////////////////////////////////////////////////////////////////////////////
type
 PByteArray                    =  ^TByteArray;
 TByteArray                    =  Array [0..Pred(MaxInt)] of Byte;
 PIpBytes                      =  ^TIpBytes;
 TIpBytes                      =  Array [0..3] of Byte;

////////////////////////////////////////////////////////////////////////////////
//   FltDefs translation
////////////////////////////////////////////////////////////////////////////////
Const
INADDR_NONE             =$ffffffff;

type
 FILTER_HANDLE                 =  Pointer;
 PFILTER_HANDLE                =  ^FILTER_HANDLE;
 INTERFACE_HANDLE              =  Pointer;
 PINTERFACE_HANDLE             =  ^INTERFACE_HANDLE;

const
 GF_FRAGMENTS                  =  2;
 GF_STRONGHOST                 =  8;
 GF_FRAGCACHE                  =  9;

type
 GLOBAL_FILTER                 =  Integer;
 PGLOBAL_FILTER                =  ^GLOBAL_FILTER;

const
 PF_IPV4                       =  0;
 PF_IPV6                       =  1;

type
 PFADDRESSTYPE                 =  Integer;
 PPFADDRESSTYPE                =  ^PFADDRESSTYPE;

const
 PF_ACTION_FORWARD             =  0;
 PF_ACTION_DROP                =  1;

type
 PFFORWARD_ACTION              =  Integer;
 PPFFORWARD_ACTION             =  ^PPFFORWARD_ACTION;

const
 PFFT_FILTER                   =  1;
 PFFT_FRAG                     =  2;
 PFFT_SPOOF                    =  3;

type
 PFFRAMETYPE                   =  Integer;
 PPFFRAMETYPE                  =  ^PFFRAMETYPE;

type
 _PF_FILTER_DESCRIPTOR         =  packed record
    dwFilterFlags:             DWORD;
    dwRule:                    DWORD;
    pfatType:                  PFADDRESSTYPE;
    SrcAddr:                   PIpBytes;
    SrcMask:                   PIpBytes;
    DstAddr:                   PIpBytes;
    DstMask:                   PIpBytes;
    dwProtocol:                DWORD;
    fLateBound:                DWORD;
    wSrcPort:                  Word;
    wDstPort:                  Word;
    wSrcPortHighRange:         Word;
    wDstPortHighRange:         Word;
 end;
 PF_FILTER_DESCRIPTOR          =  _PF_FILTER_DESCRIPTOR;
 PPF_FILTER_DESCRIPTOR         =  ^PF_FILTER_DESCRIPTOR;

type
 _PF_FILTER_STATS              =  packed record
    dwNumPacketsFiltered:      DWORD;
    info:                      PF_FILTER_DESCRIPTOR;
 end;
 PF_FILTER_STATS               =  _PF_FILTER_STATS;
 PPF_FILTER_STATS              =  ^PF_FILTER_STATS;

type
 _PF_INTERFACE_STATS           =  packed record
    pvDriverContext:           Pointer;
    dwFlags:                   DWORD;
    dwInDrops:                 DWORD;
    dwOutDrops:                DWORD;
    eaInAction:                PFFORWARD_ACTION;
    eaOutAction:               PFFORWARD_ACTION;
    dwNumInFilters:            DWORD;
    dwNumOutFilters:           DWORD;
    dwFrag:                    DWORD;
    dwSpoof:                   DWORD;
    dwReserved1:               DWORD;
    dwReserved2:               DWORD;
    liSyn:                     LARGE_INTEGER;
    liTotalLogged:             LARGE_INTEGER;
    dwLostLogEntries:          DWORD;
    FilterInfo:                Array [0..0] of PF_FILTER_STATS;
 end;
 PF_INTERFACE_STATS            =  _PF_INTERFACE_STATS;
 PPF_INTERFACE_STATS           =  ^PF_INTERFACE_STATS;

type
 _PF_LATEBIND_INFO             =  packed record
    SrcAddr:                   PByteArray;
    DstAddr:                   PByteArray;
    Mask:                      PByteArray;
 end;
 PF_LATEBIND_INFO              =  _PF_LATEBIND_INFO;
 PPF_LATEBIND_INFO             =  ^PF_LATEBIND_INFO;

type
 _PFLOGFRAME                   =  packed record
    Timestamp:                 LARGE_INTEGER;
    pfeTypeOfFrame:            PFFRAMETYPE;
    dwTotalSizeUsed:           DWORD;
    dwFilterRule:              DWORD;
    wSizeOfAdditionalData:     Word;
    wSizeOfIpHeader:           Word;
    dwInterfaceName:           DWORD;
    dwIPIndex:                 DWORD;
    bPacketData:               Array [0..0] of Byte;
 end;
 PFLOGFRAME                    =  _PFLOGFRAME;
 PPFLOGFRAME                   =  ^PFLOGFRAME;

const
 FILTER_PROTO_ANY              =  $00;
 FILTER_PROTO_ICMP             =  $01;
 FILTER_PROTO_TCP              =  $06;
 FILTER_PROTO_UDP              =  $11;
 FILTER_TCPUDP_PORT_ANY        =  $00;

const
 FILTER_ICMP_TYPE_ANY          =  $FF;
 FILTER_ICMP_CODE_ANY          =  $FF;

const
 FD_FLAGS_NOSYN                =  $01;
 FD_FLAGS_ALLFLAGS             =  FD_FLAGS_NOSYN;

const
 LB_SRC_ADDR_USE_SRCADDR_FLAG  =  $00000001;
 LB_SRC_ADDR_USE_DSTADDR_FLAG  =  $00000002;
 LB_DST_ADDR_USE_SRCADDR_FLAG  =  $00000004;
 LB_DST_ADDR_USE_DSTADDR_FLAG  =  $00000008;
 LB_SRC_MASK_LATE_FLAG         =  $00000010;
 LB_DST_MASK_LATE_FLAG         =  $00000020;

const
 ERROR_BASE                    =  23000;
 PFERROR_NO_PF_INTERFACE       =  (ERROR_BASE + 0); // never returned.
 PFERROR_NO_FILTERS_GIVEN      =  (ERROR_BASE + 1);
 PFERROR_BUFFER_TOO_SMALL      =  (ERROR_BASE + 2);
 ERROR_IPV6_NOT_IMPLEMENTED    =  (ERROR_BASE + 3);

function   PfCreateInterface(
          dwName:              DWORD;
          inAction:            PFFORWARD_ACTION;
          outAction:           PFFORWARD_ACTION;
          bUseLog:             BOOL;
          bMustBeUnique:       BOOL;
          var ppInterface:     INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfCreateInterface@24';

function   PfDeleteInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteInterface@4';

function   PfAddFiltersToInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR;
          pfHandle:            PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';

function   PfRemoveFiltersFromInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';

function   PfRemoveFilterHandles(
          pInterface:          INTERFACE_HANDLE;
          cFilters:            DWORD;
          pvHandles:           PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';

function   PfUnBindInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfUnBindInterface@4';

function   PfBindInterfaceToIndex(
          pInterface:          INTERFACE_HANDLE;
          dwIndex:             DWORD;
          pfatLinkType:        PFADDRESSTYPE;
          LinkIPAddress:       PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';

function   PfBindInterfaceToIPAddress(
          pInterface:          INTERFACE_HANDLE;
          pfatLinkType:        PFADDRESSTYPE;
          IPAddress:           PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';

function   PfRebindFilters(
          pInterface:          INTERFACE_HANDLE;
          pLateBindInfo:       PPF_LATEBIND_INFO): DWORD;
          stdcall; external IPHLPAPI name '_PfRebindFilters@8';

function   PfAddGlobalFilterToInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';

function   PfRemoveGlobalFilterFromInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';

function   PfMakeLog(
          hEvent:              THandle): DWORD;
          stdcall; external IPHLPAPI name '_PfMakeLog@4';

function   PfSetLogBuffer(
          pbBuffer:            PByteArray;
          dwSize:              DWORD;
          dwThreshold:         DWORD;
          dwEntries:           DWORD;
          pdwLoggedEntries:    PDWORD;
          pdwLostEntries:      PDWORD;
          pdwSizeUsed:         PDWORD): DWORD;
          stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';

function   PfDeleteLog: DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteLog@0';

function   PfGetInterfaceStatistics(
          pInterface:          INTERFACE_HANDLE;
          ppfStats:            PPF_INTERFACE_STATS;
          pdwBufferSize:       PDWORD;
          fResetCounters:      BOOL): DWORD;
          stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';

function   PfTestPacket(
          pInInterface:        INTERFACE_HANDLE;
          pOutInterface:       INTERFACE_HANDLE;
          cBytes:              DWORD;
          pbPacket:            PByteArray;
          ppAction:            PPFFORWARD_ACTION): DWORD;
          stdcall; external IPHLPAPI name '_PfTestPacket@20';

////////////////////////////////////////////////////////////////////////////////
//   IP filter class wrapper
////////////////////////////////////////////////////////////////////////////////
const
 IP_LOCALHOST      =  'localhost';
 IP_MASKALL        =  '0.0.0.0';
 IP_MASKNONE       =  '255.255.255.255';

type
 TIpProtocol       =  (protoAny, protoIcmp, protoTcp, protoUdp);
 TIpFilter         =  class(TObject)
 private
    // Private declarations
    FHandle:       INTERFACE_HANDLE;
    FLocalIP:      TIpBytes;
    FActive:       Boolean;
    FOutbound:     TList;
    FInbound:      TList;
    function       AllocIpBytes(Address: String): PIpBytes;
    function       AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
    procedure      FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
 protected
    // Protected declarations
    function       GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetInboundFilterCount: Integer;
    function       GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetOutboundFilterCount: Integer;
    function       Startup: Boolean;
    procedure      SetActive(Value: Boolean);
    procedure      Cleanup;
 public
    // Public declarations
    constructor    Create;
    destructor     Destroy; override;
    function       AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    function       AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    procedure      ClearInboundFilters;
    procedure      ClearOutboundFilters;
    procedure      DeleteInboundFilter(Index: Integer);
    procedure      DeleteOutboundFilter(Index: Integer);
    property       Active: Boolean read FActive write SetActive;
    property       InterfaceHandle: INTERFACE_HANDLE read FHandle;
    property       InboundFilterCount: Integer read GetInboundFilterCount;
    property       InboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetInboundFilter;
    property       OutboundFilterCount: Integer read GetOutboundFilterCount;
    property       OutboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetOutboundFilter;
 end;

////////////////////////////////////////////////////////////////////////////////
//   Utility functions
////////////////////////////////////////////////////////////////////////////////
function   StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
function   GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;

implementation

////////////////////////////////////////////////////////////////////////////////
//   Protected variables
////////////////////////////////////////////////////////////////////////////////
var
 wsaData:       TWSAData;

////////////////////////////////////////////////////////////////////////////////
//   TIpFilter
////////////////////////////////////////////////////////////////////////////////
procedure TIpFilter.ClearInboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FInbound.Count) downto 0 do DeleteInboundFilter(dwIndex);

end;

procedure TIpFilter.ClearOutboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FOutbound.Count) downto 0 do DeleteOutboundFilter(dwIndex);

end;

procedure TIpFilter.DeleteInboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FInbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FInbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 1, lpFilter, 0, nil) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

procedure TIpFilter.DeleteOutboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FOutbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FOutbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 0, nil, 1, lpFilter) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

function TIpFilter.GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FInbound[Index]^);

end;

function TIpFilter.GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FOutbound[Index]^);

end;

function TIpFilter.GetInboundFilterCount: Integer;
begin

 // Return filter count
 result:=FInbound.Count;

end;

function TIpFilter.GetOutboundFilterCount: Integer;
begin

 // Return filter count
 result:=FOutbound.Count;

end;

function TIpFilter.AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wDstPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wDstPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    lpFilter^.wSrcPort:=Port;
    lpFilter^.wSrcPortHighRange:=Port;
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.SrcAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.SrcMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.SrcAddr:=AllocIpBytes(Address);
       lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Set destination address
    lpFilter^.DstAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 1, lpFilter, 0, nil, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FInbound.Add(lpFilter);
 end;

end;

function TIpFilter.AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    // Filter all remote ports coming into specified port
    lpFilter^.wDstPort:=Port;
    lpFilter^.wDstPortHighRange:=Port;
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wSrcPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wSrcPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Set source address
    lpFilter^.SrcAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.DstAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.DstMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.DstAddr:=AllocIpBytes(Address);
       lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 0, nil, 1, lpFilter, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FOutbound.Add(lpFilter);
 end;

end;

function TIpFilter.AllocIpBytes(Address: String): PIpBytes;
begin

 // Allocate memory for IP byte setting and convert address
 result:=StrToIp(PChar(Address), AllocMem(SizeOf(TIpBytes)));

end;

function TIpFilter.AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 result:=AllocMem(SizeOf(PF_FILTER_DESCRIPTOR));

 // Set defaults for all filters
 result^.dwFilterFlags:=FD_FLAGS_NOSYN;
 result^.dwRule:=0;
 result^.pfatType:=PF_IPV4;
 result^.fLateBound:=0;

 // Set protocol filtering
 case Protocol of
    protoAny    :  result^.dwProtocol:=FILTER_PROTO_ANY;
    protoIcmp   :  result^.dwProtocol:=FILTER_PROTO_ICMP;
    protoTcp    :  result^.dwProtocol:=FILTER_PROTO_TCP;
    protoUdp    :  result^.dwProtocol:=FILTER_PROTO_UDP;
 else
    // Sanity check
    result^.dwProtocol:=FILTER_PROTO_ANY;
 end;

end;

procedure TIpFilter.FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
begin

 // Check filter
 if Assigned(Filter) then
 begin
    // Free memory for addresses and masks
    if Assigned(Filter^.SrcAddr) then FreeMem(Filter.SrcAddr);
    if Assigned(Filter^.SrcMask) then FreeMem(Filter.SrcMask);
    if Assigned(Filter^.DstAddr) then FreeMem(Filter.DstAddr);
    if Assigned(Filter^.DstMask) then FreeMem(Filter.DstMask);
    // Free memory for record struct
    FreeMem(Filter);
 end;

end;

procedure TIpFilter.SetActive(Value: Boolean);
begin

 // Check for state change
 if (Value <> FActive) then
 begin
    // Check old state
    if FActive then
       // Unbind the interface
       Win32Check(PfUnBindInterface(FHandle) = NO_ERROR)
    else
       Win32Check(PfBindInterfaceToIPAddress(FHandle, PF_IPV4, @FLocalIP) = NO_ERROR);
    // Set new state
    FActive:=Value;
 end;

end;

function TIpFilter.Startup: Boolean;
begin

 // Get the local IP address
 GetLocalIPAddr(@FLocalIP);

 // Create the interface (do not bind yet)
 result:=(PfCreateInterface(0, PF_ACTION_FORWARD, PF_ACTION_FORWARD, False, True, FHandle) = NO_ERROR);

end;

procedure TIpFilter.Cleanup;
var  dwIndex:       Integer;
begin

 // Resource protection
 try
    // Clear all filters from outbound list (do not worry about removing them)
    for dwIndex:=Pred(FOutbound.Count) downto 0 do FreeFilter(FOutbound[dwIndex]);
    // Clear all filters from inbound list (do not worry about removing them)
    for dwIndex:=Pred(FInbound.Count) downto 0 do FreeFilter(FInbound[dwIndex]);
 finally
    // Clear the lists
    FOutbound.Clear;
    FInbound.Clear;
    // Unbind the interface handle (if active)
    if FActive then PfUnBindInterface(FHandle);
    // Delete the interface handle
    PfDeleteInterface(FHandle);
 end;

end;

constructor TIpFilter.Create;
begin

 // Perform inherited
 inherited Create;

 // Create internal lists
 FActive:=False;
 FOutbound:=TList.Create;
 FInbound:=TList.Create;

 // Startup
 Win32Check(Startup);

end;

destructor TIpFilter.Destroy;
begin

 // Resource protection
 try
    // Cleanup lists and delete the interface
    Cleanup;
    // Free the lists
    FreeAndNil(FOutbound);
    FreeAndNil(FInbound);
 finally
    // Perform inherited
    inherited Destroy;
 end;

end;

function StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
var  dwAddr:     LongWord;
    pheAddr:    PHostEnt;
begin

 // Check for common settings
 if Assigned(lpszIP) and (StrIComp(lpszIP, IP_LOCALHOST) = 0) then
    // Get the local ip address
    GetLocalIPAddr(lpipAddr)
 else
 begin
    // Check assignment
    if Assigned(lpszIp) then
    begin
       // Check mask all
       if (StrIComp(lpszIP, IP_MASKALL) = 0) then
          dwAddr:=0
       // Check mask none
       else if (StrIComp(lpszIP, IP_MASKNONE) = 0) then
          dwAddr:=INADDR_NONE
       else
       begin
          // Attempt . notation conversion
          dwAddr:=inet_addr(lpszIP);
          // Check conversion (IP_MASKNONE will have already been handled)
          if (dwAddr = LongWord(INADDR_NONE)) then
          begin
             // Attempt host name conversion
             pheAddr:=gethostbyname(lpszIP);
             // Check conversion
             if Assigned(pheAddr) then
                // Get the ip address
                Move(pheAddr^.h_addr_list^^, dwAddr, SizeOf(LongWord))
             else
                // Failed to get the ip address, use none
                dwAddr:=INADDR_NONE;
          end;
       end
    end
    else
       // Convert IP_MASKALL
       dwAddr:=inet_addr(IP_MASKALL);
    // Move the longword into the byte array
    Move(dwAddr, lpipAddr^, SizeOf(LongWord));
 end;

 // Result is the pointer to passed ip address buffer
 result:=lpipAddr;

end;

function GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;
var  lpszLocal:  Array [0..255] of Char;
    pheAddr:    PHostEnt;
begin

 // Get the host name
 if (gethostname(lpszLocal, SizeOf(lpszLocal)) = 0) then
 begin
    // Get the host ent structure
    pheAddr:=gethostbyname(lpszLocal);
    if Assigned(pheAddr) then
    begin
       // Get the ip address
       Move(pheAddr^.h_addr_list^^, lpipAddr^, 4);
       result:=True;
    end
    else
       // Failure
       result:=False;
 end
 else
    // Failure
    result:=False;

end;

initialization

 // Initialize winsock so we can get the local ip address and call winsock functions
 WSAStartup(MakeWord(1, 1), wsaData);

finalization

 // Cleanup
 WSACleanup;

end.


ipheader.pas
Unit ipheader;

Interface

Uses
 windows, winsock;

Const
 TCPFlag_URG = 0;
 TCPFlag_ACK = 2;
 TCPFlag_PSH = 4;
 TCPFlag_RST = 8;
 TCPFlag_SYN = 16;
 TCPFlag_FYN = 32;

 IPPROTO_IP = 0; //dummy for IP
 IPPROTO_ICMP = 1; // control message protocol
 IPPROTO_IGMP = 2; //internet group management protocol
 IPPROTO_GGP = 3; //  gateway^2 (deprecated)
 IPPROTO_TCP = 6; //   tcp
 IPPROTO_PUP = 12; //  pup
 IPPROTO_UDP = 17; //  user datagram protocol
 IPPROTO_IDP = 22; //  xns idp
 IPPROTO_ND = 77; //  UNOFFICIAL net disk proto

 IPPROTO_RAW = 255; // raw IP packet
 IPPROTO_MAX = 256;

 SIO_RCVALL = $98000001;

Type

 TIPPROTO = Record
   itype: word;
   name: String;
 End;

 PIP_Header = ^TIP_Header;
 TIP_Header = Packed Record
   ip_verlen: Byte;  
   ip_tos: Byte; 
   ip_totallength: Word;  
   ip_id: Word;  
   ip_offset: Word;  
   ip_ttl: Byte;  
   ip_protocol: Byte;  
   ip_checksum: Word; 
   ip_srcaddr: LongWord;  
   ip_destaddr: LongWord; 
 End;
 PUDP_Header = ^TUDP_Header;
 TUDP_Header = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   udp_length: Word;  
   udp_checksum: Word;  
 End;
 PTCP_Hearder = ^TTCP_Hearder;
 TTCP_Hearder = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   Sequenceno: LongWord;  
   Acknowledgeno: LongWord;  
   DataOffset: Byte; //
   flag: byte;
   Windows: WORD;  
   checksum: WORD;  
   UrgentPointer: WORD; 
 End;

Const
 IPPROTO: Array[0..8] Of TIPPROTO = (
   (iType: IPPROTO_IP; name: 'IP'),
   (iType: IPPROTO_ICMP; name: 'ICMP'),
   (iType: IPPROTO_IGMP; name: 'IGMP'),
   (iType: IPPROTO_GGP; name: 'GGP'),
   (iType: IPPROTO_TCP; name: 'TCP'),
   (iType: IPPROTO_PUP; name: 'PUP'),
   (iType: IPPROTO_UDP; name: 'UDP'),
   (iType: IPPROTO_IDP; name: 'IDP'),
   (iType: IPPROTO_ND; name: 'ND'));

Implementation

End.



Teşekkürler hocam.

Bu işlemi Windows üzerinden yapma durumu mevcut mu acaba?
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla
#4
(02-12-2020, Saat: 13:33)hi_selamlar Adlı Kullanıcıdan Alıntı:
(02-12-2020, Saat: 13:23)hayalyilmaz43 Adlı Kullanıcıdan Alıntı: yapmanız gereken listening rdp portuna gelen bağlantıları red etmek zamanlamayıda kendiniz ufak bir fonksiyon ile yapabilirsiniz.

bunu windows firewall ına zaman aralıkları ile kural ekleyerek çıkararakda yapabilirsiniz,
yada kullanıcı oturum açtığında explorer.exe den önce çalıştırılacak sizin exe niz zamana ve açık kullanıcı adına bakarak kullanıcıyı logout eden mesaj yayınlar, kullanıcı bağlanır dialogda uyarıyı görür 3sn sonra log out edilir.

aşağıda size basit bir firewall kaynak kodu paylaşıyorum, eklenen ruleleri silebilirsinizde zaman aralıklarına göre.


Kullanım Örneği;
program netblock1;
{$APPTYPE CONSOLE}

uses
 Windows,
 SysUtils,
 Classes,
 IPFilter,
 winsock;

Begin
 // Create filter object
 with TIpFilter.Create do
 begin
    // Set active
    Active:=True;
    // Some example filters
    AddOutboundFilter(EmptyStr, protoUdp, 5001); // Filter all outbound udp requests going to port 5001
    AddOutboundFilter(EmptyStr, protoIcmp, FILTER_ICMP_TYPE_ANY); // Filter all outgoing ICMP requests
    AddInboundFilter('www.experts-exchange.com', protoTcp, 80); // Filter any incoming request from EE on port 80
    AddOutboundFilter('www.google.com.tr', protoTcp, 80); // Filter outgoing request to google      
    AddInboundFilter('www.google.com.tr', protoTcp, 80);
    Readln;
    // Free (this will remove all filters)
    Free;
 end;


end.

IPFilter.Pas;
unit IPFilter;
////////////////////////////////////////////////////////////////////////////////
//
//   Description    :  TCPIP network connection blocking unit
//
////////////////////////////////////////////////////////////////////////////////
interface

////////////////////////////////////////////////////////////////////////////////
//   Include units
////////////////////////////////////////////////////////////////////////////////
uses
 Windows,
 SysUtils,
 Classes,
 WinSock;

////////////////////////////////////////////////////////////////////////////////
//   IP helper library
////////////////////////////////////////////////////////////////////////////////
const
 IPHLPAPI                      =  'IPHLPAPI.DLL';

////////////////////////////////////////////////////////////////////////////////
//   Data types
////////////////////////////////////////////////////////////////////////////////
type
 PByteArray                    =  ^TByteArray;
 TByteArray                    =  Array [0..Pred(MaxInt)] of Byte;
 PIpBytes                      =  ^TIpBytes;
 TIpBytes                      =  Array [0..3] of Byte;

////////////////////////////////////////////////////////////////////////////////
//   FltDefs translation
////////////////////////////////////////////////////////////////////////////////
Const
INADDR_NONE             =$ffffffff;

type
 FILTER_HANDLE                 =  Pointer;
 PFILTER_HANDLE                =  ^FILTER_HANDLE;
 INTERFACE_HANDLE              =  Pointer;
 PINTERFACE_HANDLE             =  ^INTERFACE_HANDLE;

const
 GF_FRAGMENTS                  =  2;
 GF_STRONGHOST                 =  8;
 GF_FRAGCACHE                  =  9;

type
 GLOBAL_FILTER                 =  Integer;
 PGLOBAL_FILTER                =  ^GLOBAL_FILTER;

const
 PF_IPV4                       =  0;
 PF_IPV6                       =  1;

type
 PFADDRESSTYPE                 =  Integer;
 PPFADDRESSTYPE                =  ^PFADDRESSTYPE;

const
 PF_ACTION_FORWARD             =  0;
 PF_ACTION_DROP                =  1;

type
 PFFORWARD_ACTION              =  Integer;
 PPFFORWARD_ACTION             =  ^PPFFORWARD_ACTION;

const
 PFFT_FILTER                   =  1;
 PFFT_FRAG                     =  2;
 PFFT_SPOOF                    =  3;

type
 PFFRAMETYPE                   =  Integer;
 PPFFRAMETYPE                  =  ^PFFRAMETYPE;

type
 _PF_FILTER_DESCRIPTOR         =  packed record
    dwFilterFlags:             DWORD;
    dwRule:                    DWORD;
    pfatType:                  PFADDRESSTYPE;
    SrcAddr:                   PIpBytes;
    SrcMask:                   PIpBytes;
    DstAddr:                   PIpBytes;
    DstMask:                   PIpBytes;
    dwProtocol:                DWORD;
    fLateBound:                DWORD;
    wSrcPort:                  Word;
    wDstPort:                  Word;
    wSrcPortHighRange:         Word;
    wDstPortHighRange:         Word;
 end;
 PF_FILTER_DESCRIPTOR          =  _PF_FILTER_DESCRIPTOR;
 PPF_FILTER_DESCRIPTOR         =  ^PF_FILTER_DESCRIPTOR;

type
 _PF_FILTER_STATS              =  packed record
    dwNumPacketsFiltered:      DWORD;
    info:                      PF_FILTER_DESCRIPTOR;
 end;
 PF_FILTER_STATS               =  _PF_FILTER_STATS;
 PPF_FILTER_STATS              =  ^PF_FILTER_STATS;

type
 _PF_INTERFACE_STATS           =  packed record
    pvDriverContext:           Pointer;
    dwFlags:                   DWORD;
    dwInDrops:                 DWORD;
    dwOutDrops:                DWORD;
    eaInAction:                PFFORWARD_ACTION;
    eaOutAction:               PFFORWARD_ACTION;
    dwNumInFilters:            DWORD;
    dwNumOutFilters:           DWORD;
    dwFrag:                    DWORD;
    dwSpoof:                   DWORD;
    dwReserved1:               DWORD;
    dwReserved2:               DWORD;
    liSyn:                     LARGE_INTEGER;
    liTotalLogged:             LARGE_INTEGER;
    dwLostLogEntries:          DWORD;
    FilterInfo:                Array [0..0] of PF_FILTER_STATS;
 end;
 PF_INTERFACE_STATS            =  _PF_INTERFACE_STATS;
 PPF_INTERFACE_STATS           =  ^PF_INTERFACE_STATS;

type
 _PF_LATEBIND_INFO             =  packed record
    SrcAddr:                   PByteArray;
    DstAddr:                   PByteArray;
    Mask:                      PByteArray;
 end;
 PF_LATEBIND_INFO              =  _PF_LATEBIND_INFO;
 PPF_LATEBIND_INFO             =  ^PF_LATEBIND_INFO;

type
 _PFLOGFRAME                   =  packed record
    Timestamp:                 LARGE_INTEGER;
    pfeTypeOfFrame:            PFFRAMETYPE;
    dwTotalSizeUsed:           DWORD;
    dwFilterRule:              DWORD;
    wSizeOfAdditionalData:     Word;
    wSizeOfIpHeader:           Word;
    dwInterfaceName:           DWORD;
    dwIPIndex:                 DWORD;
    bPacketData:               Array [0..0] of Byte;
 end;
 PFLOGFRAME                    =  _PFLOGFRAME;
 PPFLOGFRAME                   =  ^PFLOGFRAME;

const
 FILTER_PROTO_ANY              =  $00;
 FILTER_PROTO_ICMP             =  $01;
 FILTER_PROTO_TCP              =  $06;
 FILTER_PROTO_UDP              =  $11;
 FILTER_TCPUDP_PORT_ANY        =  $00;

const
 FILTER_ICMP_TYPE_ANY          =  $FF;
 FILTER_ICMP_CODE_ANY          =  $FF;

const
 FD_FLAGS_NOSYN                =  $01;
 FD_FLAGS_ALLFLAGS             =  FD_FLAGS_NOSYN;

const
 LB_SRC_ADDR_USE_SRCADDR_FLAG  =  $00000001;
 LB_SRC_ADDR_USE_DSTADDR_FLAG  =  $00000002;
 LB_DST_ADDR_USE_SRCADDR_FLAG  =  $00000004;
 LB_DST_ADDR_USE_DSTADDR_FLAG  =  $00000008;
 LB_SRC_MASK_LATE_FLAG         =  $00000010;
 LB_DST_MASK_LATE_FLAG         =  $00000020;

const
 ERROR_BASE                    =  23000;
 PFERROR_NO_PF_INTERFACE       =  (ERROR_BASE + 0); // never returned.
 PFERROR_NO_FILTERS_GIVEN      =  (ERROR_BASE + 1);
 PFERROR_BUFFER_TOO_SMALL      =  (ERROR_BASE + 2);
 ERROR_IPV6_NOT_IMPLEMENTED    =  (ERROR_BASE + 3);

function   PfCreateInterface(
          dwName:              DWORD;
          inAction:            PFFORWARD_ACTION;
          outAction:           PFFORWARD_ACTION;
          bUseLog:             BOOL;
          bMustBeUnique:       BOOL;
          var ppInterface:     INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfCreateInterface@24';

function   PfDeleteInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteInterface@4';

function   PfAddFiltersToInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR;
          pfHandle:            PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfAddFiltersToInterface@24';

function   PfRemoveFiltersFromInterface(
          ih:                  INTERFACE_HANDLE;
          cInFilters:          DWORD;
          pfiltIn:             PPF_FILTER_DESCRIPTOR;
          cOutFilters:         DWORD;
          pfiltOut:            PPF_FILTER_DESCRIPTOR): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFiltersFromInterface@20';

function   PfRemoveFilterHandles(
          pInterface:          INTERFACE_HANDLE;
          cFilters:            DWORD;
          pvHandles:           PFILTER_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveFilterHandles@12';

function   PfUnBindInterface(
          pInterface:          INTERFACE_HANDLE): DWORD;
          stdcall; external IPHLPAPI name '_PfUnBindInterface@4';

function   PfBindInterfaceToIndex(
          pInterface:          INTERFACE_HANDLE;
          dwIndex:             DWORD;
          pfatLinkType:        PFADDRESSTYPE;
          LinkIPAddress:       PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIndex@16';

function   PfBindInterfaceToIPAddress(
          pInterface:          INTERFACE_HANDLE;
          pfatLinkType:        PFADDRESSTYPE;
          IPAddress:           PByteArray): DWORD;
          stdcall; external IPHLPAPI name '_PfBindInterfaceToIPAddress@12';

function   PfRebindFilters(
          pInterface:          INTERFACE_HANDLE;
          pLateBindInfo:       PPF_LATEBIND_INFO): DWORD;
          stdcall; external IPHLPAPI name '_PfRebindFilters@8';

function   PfAddGlobalFilterToInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfAddGlobalFilterToInterface@8';

function   PfRemoveGlobalFilterFromInterface(
          pInterface:          INTERFACE_HANDLE;
          gfFilter:            GLOBAL_FILTER): DWORD;
          stdcall; external IPHLPAPI name '_PfRemoveGlobalFilterFromInterface@8';

function   PfMakeLog(
          hEvent:              THandle): DWORD;
          stdcall; external IPHLPAPI name '_PfMakeLog@4';

function   PfSetLogBuffer(
          pbBuffer:            PByteArray;
          dwSize:              DWORD;
          dwThreshold:         DWORD;
          dwEntries:           DWORD;
          pdwLoggedEntries:    PDWORD;
          pdwLostEntries:      PDWORD;
          pdwSizeUsed:         PDWORD): DWORD;
          stdcall; external IPHLPAPI name '_PfSetLogBuffer@28';

function   PfDeleteLog: DWORD;
          stdcall; external IPHLPAPI name '_PfDeleteLog@0';

function   PfGetInterfaceStatistics(
          pInterface:          INTERFACE_HANDLE;
          ppfStats:            PPF_INTERFACE_STATS;
          pdwBufferSize:       PDWORD;
          fResetCounters:      BOOL): DWORD;
          stdcall; external IPHLPAPI name '_PfGetInterfaceStatistics@16';

function   PfTestPacket(
          pInInterface:        INTERFACE_HANDLE;
          pOutInterface:       INTERFACE_HANDLE;
          cBytes:              DWORD;
          pbPacket:            PByteArray;
          ppAction:            PPFFORWARD_ACTION): DWORD;
          stdcall; external IPHLPAPI name '_PfTestPacket@20';

////////////////////////////////////////////////////////////////////////////////
//   IP filter class wrapper
////////////////////////////////////////////////////////////////////////////////
const
 IP_LOCALHOST      =  'localhost';
 IP_MASKALL        =  '0.0.0.0';
 IP_MASKNONE       =  '255.255.255.255';

type
 TIpProtocol       =  (protoAny, protoIcmp, protoTcp, protoUdp);
 TIpFilter         =  class(TObject)
 private
    // Private declarations
    FHandle:       INTERFACE_HANDLE;
    FLocalIP:      TIpBytes;
    FActive:       Boolean;
    FOutbound:     TList;
    FInbound:      TList;
    function       AllocIpBytes(Address: String): PIpBytes;
    function       AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
    procedure      FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
 protected
    // Protected declarations
    function       GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetInboundFilterCount: Integer;
    function       GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
    function       GetOutboundFilterCount: Integer;
    function       Startup: Boolean;
    procedure      SetActive(Value: Boolean);
    procedure      Cleanup;
 public
    // Public declarations
    constructor    Create;
    destructor     Destroy; override;
    function       AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    function       AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
    procedure      ClearInboundFilters;
    procedure      ClearOutboundFilters;
    procedure      DeleteInboundFilter(Index: Integer);
    procedure      DeleteOutboundFilter(Index: Integer);
    property       Active: Boolean read FActive write SetActive;
    property       InterfaceHandle: INTERFACE_HANDLE read FHandle;
    property       InboundFilterCount: Integer read GetInboundFilterCount;
    property       InboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetInboundFilter;
    property       OutboundFilterCount: Integer read GetOutboundFilterCount;
    property       OutboundFilters[Index: Integer]: PF_FILTER_DESCRIPTOR read GetOutboundFilter;
 end;

////////////////////////////////////////////////////////////////////////////////
//   Utility functions
////////////////////////////////////////////////////////////////////////////////
function   StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
function   GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;

implementation

////////////////////////////////////////////////////////////////////////////////
//   Protected variables
////////////////////////////////////////////////////////////////////////////////
var
 wsaData:       TWSAData;

////////////////////////////////////////////////////////////////////////////////
//   TIpFilter
////////////////////////////////////////////////////////////////////////////////
procedure TIpFilter.ClearInboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FInbound.Count) downto 0 do DeleteInboundFilter(dwIndex);

end;

procedure TIpFilter.ClearOutboundFilters;
var  dwIndex:       Integer;
begin

 // Walk all filters and remove them
 for dwIndex:=Pred(FOutbound.Count) downto 0 do DeleteOutboundFilter(dwIndex);

end;

procedure TIpFilter.DeleteInboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FInbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FInbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 1, lpFilter, 0, nil) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

procedure TIpFilter.DeleteOutboundFilter(Index: Integer);
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Get the filter from the list
 lpFilter:=FOutbound[Index];

 // Resource protection
 try
    // Remove filter from the list
    FOutbound.Delete(Index);
    // Remove the filter
    Win32Check(PfRemoveFiltersFromInterface(FHandle, 0, nil, 1, lpFilter) = NO_ERROR);
 finally
    // Free the filter
    FreeFilter(lpFilter);
 end;

end;

function TIpFilter.GetInboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FInbound[Index]^);

end;

function TIpFilter.GetOutboundFilter(Index: Integer): PF_FILTER_DESCRIPTOR;
begin

 // Get the filter descriptor
 result:=PF_FILTER_DESCRIPTOR(FOutbound[Index]^);

end;

function TIpFilter.GetInboundFilterCount: Integer;
begin

 // Return filter count
 result:=FInbound.Count;

end;

function TIpFilter.GetOutboundFilterCount: Integer;
begin

 // Return filter count
 result:=FOutbound.Count;

end;

function TIpFilter.AddInboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wDstPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wDstPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wDstPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    lpFilter^.wSrcPort:=Port;
    lpFilter^.wSrcPortHighRange:=Port;
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.SrcAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.SrcMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.SrcAddr:=AllocIpBytes(Address);
       lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Set destination address
    lpFilter^.DstAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 1, lpFilter, 0, nil, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FInbound.Add(lpFilter);
 end;

end;

function TIpFilter.AddOutboundFilter(Address: String; Protocol: TIpProtocol; Port: Word): Integer;
var  lpFilter:      PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 lpFilter:=AllocFilter(Protocol);

 // Resource protection
 try
    // Note: UDP number needs to be decremented by one (ie 5000 blocks 5001)
    if (Protocol = protoUdp) and (Port > 0) then Dec(Port);
    // Filter all remote ports coming into specified port
    lpFilter^.wDstPort:=Port;
    lpFilter^.wDstPortHighRange:=Port;
    // Check protocol
    if (Protocol = protoIcmp) then
    begin
       // Icmp handling
       lpFilter^.wSrcPort:=FILTER_ICMP_CODE_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_ICMP_CODE_ANY;
    end
    else
    begin
       // Tcp/Udp handling
       lpFilter^.wSrcPort:=FILTER_TCPUDP_PORT_ANY;
       lpFilter^.wSrcPortHighRange:=FILTER_TCPUDP_PORT_ANY;
    end;
    // Set source address
    lpFilter^.SrcAddr:=AllocIpBytes(IP_LOCALHOST);
    lpFilter^.SrcMask:=AllocIpBytes(IP_MASKNONE);
    // Check remote address
    if (Length(Address) = 0)then
    begin
       // Filter from all remote addresses
       lpFilter^.DstAddr:=AllocIpBytes(IP_MASKALL);
       lpFIlter^.DstMask:=AllocIpBytes(IP_MASKALL);
    end
    else
    begin
       // Filter from specific remote address
       lpFilter^.DstAddr:=AllocIpBytes(Address);
       lpFilter^.DstMask:=AllocIpBytes(IP_MASKNONE);
    end;
    // Add filter to interface
    Win32Check(PfAddFiltersToInterface(FHandle, 0, nil, 1, lpFilter, nil) = NO_ERROR);
 finally
    // Add filter to list
    result:=FOutbound.Add(lpFilter);
 end;

end;

function TIpFilter.AllocIpBytes(Address: String): PIpBytes;
begin

 // Allocate memory for IP byte setting and convert address
 result:=StrToIp(PChar(Address), AllocMem(SizeOf(TIpBytes)));

end;

function TIpFilter.AllocFilter(Protocol: TIpProtocol): PPF_FILTER_DESCRIPTOR;
begin

 // Allocate memory for filter
 result:=AllocMem(SizeOf(PF_FILTER_DESCRIPTOR));

 // Set defaults for all filters
 result^.dwFilterFlags:=FD_FLAGS_NOSYN;
 result^.dwRule:=0;
 result^.pfatType:=PF_IPV4;
 result^.fLateBound:=0;

 // Set protocol filtering
 case Protocol of
    protoAny    :  result^.dwProtocol:=FILTER_PROTO_ANY;
    protoIcmp   :  result^.dwProtocol:=FILTER_PROTO_ICMP;
    protoTcp    :  result^.dwProtocol:=FILTER_PROTO_TCP;
    protoUdp    :  result^.dwProtocol:=FILTER_PROTO_UDP;
 else
    // Sanity check
    result^.dwProtocol:=FILTER_PROTO_ANY;
 end;

end;

procedure TIpFilter.FreeFilter(Filter: PPF_FILTER_DESCRIPTOR);
begin

 // Check filter
 if Assigned(Filter) then
 begin
    // Free memory for addresses and masks
    if Assigned(Filter^.SrcAddr) then FreeMem(Filter.SrcAddr);
    if Assigned(Filter^.SrcMask) then FreeMem(Filter.SrcMask);
    if Assigned(Filter^.DstAddr) then FreeMem(Filter.DstAddr);
    if Assigned(Filter^.DstMask) then FreeMem(Filter.DstMask);
    // Free memory for record struct
    FreeMem(Filter);
 end;

end;

procedure TIpFilter.SetActive(Value: Boolean);
begin

 // Check for state change
 if (Value <> FActive) then
 begin
    // Check old state
    if FActive then
       // Unbind the interface
       Win32Check(PfUnBindInterface(FHandle) = NO_ERROR)
    else
       Win32Check(PfBindInterfaceToIPAddress(FHandle, PF_IPV4, @FLocalIP) = NO_ERROR);
    // Set new state
    FActive:=Value;
 end;

end;

function TIpFilter.Startup: Boolean;
begin

 // Get the local IP address
 GetLocalIPAddr(@FLocalIP);

 // Create the interface (do not bind yet)
 result:=(PfCreateInterface(0, PF_ACTION_FORWARD, PF_ACTION_FORWARD, False, True, FHandle) = NO_ERROR);

end;

procedure TIpFilter.Cleanup;
var  dwIndex:       Integer;
begin

 // Resource protection
 try
    // Clear all filters from outbound list (do not worry about removing them)
    for dwIndex:=Pred(FOutbound.Count) downto 0 do FreeFilter(FOutbound[dwIndex]);
    // Clear all filters from inbound list (do not worry about removing them)
    for dwIndex:=Pred(FInbound.Count) downto 0 do FreeFilter(FInbound[dwIndex]);
 finally
    // Clear the lists
    FOutbound.Clear;
    FInbound.Clear;
    // Unbind the interface handle (if active)
    if FActive then PfUnBindInterface(FHandle);
    // Delete the interface handle
    PfDeleteInterface(FHandle);
 end;

end;

constructor TIpFilter.Create;
begin

 // Perform inherited
 inherited Create;

 // Create internal lists
 FActive:=False;
 FOutbound:=TList.Create;
 FInbound:=TList.Create;

 // Startup
 Win32Check(Startup);

end;

destructor TIpFilter.Destroy;
begin

 // Resource protection
 try
    // Cleanup lists and delete the interface
    Cleanup;
    // Free the lists
    FreeAndNil(FOutbound);
    FreeAndNil(FInbound);
 finally
    // Perform inherited
    inherited Destroy;
 end;

end;

function StrToIp(lpszIP: PChar; lpipAddr: PIpBytes): PIpBytes;
var  dwAddr:     LongWord;
    pheAddr:    PHostEnt;
begin

 // Check for common settings
 if Assigned(lpszIP) and (StrIComp(lpszIP, IP_LOCALHOST) = 0) then
    // Get the local ip address
    GetLocalIPAddr(lpipAddr)
 else
 begin
    // Check assignment
    if Assigned(lpszIp) then
    begin
       // Check mask all
       if (StrIComp(lpszIP, IP_MASKALL) = 0) then
          dwAddr:=0
       // Check mask none
       else if (StrIComp(lpszIP, IP_MASKNONE) = 0) then
          dwAddr:=INADDR_NONE
       else
       begin
          // Attempt . notation conversion
          dwAddr:=inet_addr(lpszIP);
          // Check conversion (IP_MASKNONE will have already been handled)
          if (dwAddr = LongWord(INADDR_NONE)) then
          begin
             // Attempt host name conversion
             pheAddr:=gethostbyname(lpszIP);
             // Check conversion
             if Assigned(pheAddr) then
                // Get the ip address
                Move(pheAddr^.h_addr_list^^, dwAddr, SizeOf(LongWord))
             else
                // Failed to get the ip address, use none
                dwAddr:=INADDR_NONE;
          end;
       end
    end
    else
       // Convert IP_MASKALL
       dwAddr:=inet_addr(IP_MASKALL);
    // Move the longword into the byte array
    Move(dwAddr, lpipAddr^, SizeOf(LongWord));
 end;

 // Result is the pointer to passed ip address buffer
 result:=lpipAddr;

end;

function GetLocalIPAddr(lpipAddr: PIpBytes): Boolean;
var  lpszLocal:  Array [0..255] of Char;
    pheAddr:    PHostEnt;
begin

 // Get the host name
 if (gethostname(lpszLocal, SizeOf(lpszLocal)) = 0) then
 begin
    // Get the host ent structure
    pheAddr:=gethostbyname(lpszLocal);
    if Assigned(pheAddr) then
    begin
       // Get the ip address
       Move(pheAddr^.h_addr_list^^, lpipAddr^, 4);
       result:=True;
    end
    else
       // Failure
       result:=False;
 end
 else
    // Failure
    result:=False;

end;

initialization

 // Initialize winsock so we can get the local ip address and call winsock functions
 WSAStartup(MakeWord(1, 1), wsaData);

finalization

 // Cleanup
 WSACleanup;

end.


ipheader.pas
Unit ipheader;

Interface

Uses
 windows, winsock;

Const
 TCPFlag_URG = 0;
 TCPFlag_ACK = 2;
 TCPFlag_PSH = 4;
 TCPFlag_RST = 8;
 TCPFlag_SYN = 16;
 TCPFlag_FYN = 32;

 IPPROTO_IP = 0; //dummy for IP
 IPPROTO_ICMP = 1; // control message protocol
 IPPROTO_IGMP = 2; //internet group management protocol
 IPPROTO_GGP = 3; //  gateway^2 (deprecated)
 IPPROTO_TCP = 6; //   tcp
 IPPROTO_PUP = 12; //  pup
 IPPROTO_UDP = 17; //  user datagram protocol
 IPPROTO_IDP = 22; //  xns idp
 IPPROTO_ND = 77; //  UNOFFICIAL net disk proto

 IPPROTO_RAW = 255; // raw IP packet
 IPPROTO_MAX = 256;

 SIO_RCVALL = $98000001;

Type

 TIPPROTO = Record
   itype: word;
   name: String;
 End;

 PIP_Header = ^TIP_Header;
 TIP_Header = Packed Record
   ip_verlen: Byte;  
   ip_tos: Byte; 
   ip_totallength: Word;  
   ip_id: Word;  
   ip_offset: Word;  
   ip_ttl: Byte;  
   ip_protocol: Byte;  
   ip_checksum: Word; 
   ip_srcaddr: LongWord;  
   ip_destaddr: LongWord; 
 End;
 PUDP_Header = ^TUDP_Header;
 TUDP_Header = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   udp_length: Word;  
   udp_checksum: Word;  
 End;
 PTCP_Hearder = ^TTCP_Hearder;
 TTCP_Hearder = Packed Record
   src_portno: Word;  
   dst_portno: Word;  
   Sequenceno: LongWord;  
   Acknowledgeno: LongWord;  
   DataOffset: Byte; //
   flag: byte;
   Windows: WORD;  
   checksum: WORD;  
   UrgentPointer: WORD; 
 End;

Const
 IPPROTO: Array[0..8] Of TIPPROTO = (
   (iType: IPPROTO_IP; name: 'IP'),
   (iType: IPPROTO_ICMP; name: 'ICMP'),
   (iType: IPPROTO_IGMP; name: 'IGMP'),
   (iType: IPPROTO_GGP; name: 'GGP'),
   (iType: IPPROTO_TCP; name: 'TCP'),
   (iType: IPPROTO_PUP; name: 'PUP'),
   (iType: IPPROTO_UDP; name: 'UDP'),
   (iType: IPPROTO_IDP; name: 'IDP'),
   (iType: IPPROTO_ND; name: 'ND'));

Implementation

End.



Teşekkürler hocam.

Bu işlemi Windows üzerinden yapma durumu mevcut mu acaba?

son yazdığım yukarıdaki mesajı terkar gözden geçirin 1 kaç kez editledim.

windows un böyle bir özelliği varmı bilmiyorum, şöyle bir yazılım var, veya buda olabilir,
veya windows un schedulesini kullanarak görev eklenir, o görevde zaman aralıklarına göre kullanıcı hesaplarını disable enable yapar.
Cevapla
#5
Merhaba,
Buradaki konuyu bir inceleyin derim belki işinizi görür. Ebeveyn denetimi vardı önceden, oradan aklıma geldi. Smile

İyi Çalışmalar.
Cevapla
#6
(02-12-2020, Saat: 13:34)hayalyilmaz43 Adlı Kullanıcıdan Alıntı:
(02-12-2020, Saat: 13:33)hi_selamlar Adlı Kullanıcıdan Alıntı: Teşekkürler hocam.

Bu işlemi Windows üzerinden yapma durumu mevcut mu acaba?

son yazdığım yukarıdaki mesajı terkar gözden geçirin 1 kaç kez editledim.

windows un böyle bir özelliği varmı bilmiyorum, şöyle bir yazılım var, veya buda olabilir,
veya windows un schedulesini kullanarak görev eklenir, o görevde zaman aralıklarına göre kullanıcı hesaplarını disable enable yapar.

Paylaşımlarınız için teşekkür ederim.

Linkleri kontrol ettim ama çok algılayamadım.

Bu işlemi Windows üzerinde Firewall dan mı yapmam gerekli. 
Inbounds Rules > RDP > içerisinde zaman kısıtlama ile ilgili bir yöntem ben göremedim.

Yanlış mı bakıyorum acaba?

Herkese teşekkür ederim.

Şimdilik bu şekilde işlemi çözümledim.

net user KULLANICIADI /times:monday-Saturday,15-17     kısıtlama

net user KULLANICIADI /times:ALL                                   kısıtlama iptal  


Sadece bu saatler arasında kullanıcı bağlanabiliyor.
Fakat kullanıcı aktif ise bağlantıyı sonlandırmıyor.

Daha kapsamlı bir ayar söz konusu ise paylaşırsanız sevinirim.

Kolay gelsin.
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla
#7
Bu tarz işler için kod yazmanıza gerek yok windows içinde böyle bir olduğundan eminim ama nerede olduğunu hatırlamıyorum belki group policy içinde olabilir. Araştırırsanız sonuç çıkacaktır.

Başka alternatif çözüm ise firewall üzerinde içeri giriş anında block yapabilirsiniz. Çoğu firewall da böyle zamanlı port kısıtlama veya veya erişime açma ayarları mevcuttur
PostgreSQL - Linux - Delphi, Poliüretan
WWW
Cevapla
#8
Kızmazsanız farklı bir önerim olacak.
Küçük ölçekli bir firewall kurun. (Yazılım değil fiziksel firewall) yerli 25 kullanıcılı ürünün fiyatı ve özellikleri çok iyi)
ihtiyacınız kadar kurallar oluşturun (saatler arası, günler arası v.s gibi)
sonra bu kuralları ilgili kullanıcılara ekleyin.

Amaç uzak bağlantıyı kontrol altına almak, kripto saldırıları
Kullanıcı ve makine bazlı kontroller  v.s  kesin çözüm

@3ddark mesajın altını görmedim benzer öneri olmuş.  Smile
"…De ki: "Hiç bilenlerle bilmeyenler bir olur mu? Şüphesiz, temiz akıl sahipleri öğüt alıp-düşünürler" (Zümer Suresi, 9)
Cevapla
#9
(02-12-2020, Saat: 13:11)hi_selamlar Adlı Kullanıcıdan Alıntı: Merhabalar,

Çok bilgim yok açıkcası. Biraz araştırdım fakat kayda değer bir şey bulamadım.
Yardımlarınızı rica ediyorum. Şimdiden herkese teşekkür ederim.

Windows Server 2016 kurulu bir sistem mevcut. Bu sisteme RDP (uzak masaüstü bağlantısı) ile
kullanıcılar (10 kişi) bağlanıyor.

İstenen ise, kullanıcılara RDP bağlantısı yaparken saat 11:00 ile 16:00 arası izin verilsin.
Diğer saatler arasında sisteme bağlantı kuramasın ve mevcut ise sistem açılış esnasında bağlantı zaman aralığında değilsiniz
gibi bir uyarıda verebilirmi.

Teşekkürler.

Merhaba,

Buradaki linki incelerseniz, sizin işlemi GPO'lar ile yapabileceğinizi düşünüyorum.

*Eğer server bulut bir sunucuysa, bu ayarları yanlış yapmanız sonucu sunucuya erişiminizi tamamen kaybedebilirsiniz.

İyi çalışmalar.
Cevapla
#10
(02-12-2020, Saat: 18:16)3ddark Adlı Kullanıcıdan Alıntı: Bu tarz işler için kod yazmanıza gerek yok windows içinde böyle bir olduğundan eminim ama nerede olduğunu hatırlamıyorum belki group policy içinde olabilir. Araştırırsanız sonuç çıkacaktır.

Başka alternatif çözüm ise firewall üzerinde içeri giriş anında block yapabilirsiniz. Çoğu firewall da böyle zamanlı port kısıtlama veya veya erişime açma ayarları mevcuttur

Merhabalar, haklısınız benim de düşüncem bu yönde. Fakat çok araştırdım bir sonuca ulaşamadım.  Teşekkürler.

(02-12-2020, Saat: 20:21)cinarbil Adlı Kullanıcıdan Alıntı: Kızmazsanız farklı bir önerim olacak.
Küçük ölçekli bir firewall kurun. (Yazılım değil fiziksel firewall) yerli 25 kullanıcılı ürünün fiyatı ve özellikleri çok iyi)
ihtiyacınız kadar kurallar oluşturun (saatler arası, günler arası v.s gibi)
sonra bu kuralları ilgili kullanıcılara ekleyin.

Amaç uzak bağlantıyı kontrol altına almak, kripto saldırıları
Kullanıcı ve makine bazlı kontroller  v.s  kesin çözüm

@3ddark mesajın altını görmedim benzer öneri olmuş.  Smile

Merhabalar, Estağfurullah neden kızılsın ki Smile herkes fikir ve tecrübelerini paylaşıyor aksine çok mutlu olurum.
Sanal sunucu kullandığımız için firewall mevcut. Ama bunu biz yapamıyoruz. Server sisteme mesaj göndermemiz gerekiyor.
Bunun dönüşü bekleme süresi vs. derken iş biraz uzayabiliyor.


(03-12-2020, Saat: 09:00)pro_imaj Adlı Kullanıcıdan Alıntı:
(02-12-2020, Saat: 13:11)hi_selamlar Adlı Kullanıcıdan Alıntı: Merhabalar,

Çok bilgim yok açıkcası. Biraz araştırdım fakat kayda değer bir şey bulamadım.
Yardımlarınızı rica ediyorum. Şimdiden herkese teşekkür ederim.

Windows Server 2016 kurulu bir sistem mevcut. Bu sisteme RDP (uzak masaüstü bağlantısı) ile
kullanıcılar (10 kişi) bağlanıyor.

İstenen ise, kullanıcılara RDP bağlantısı yaparken saat 11:00 ile 16:00 arası izin verilsin.
Diğer saatler arasında sisteme bağlantı kuramasın ve mevcut ise sistem açılış esnasında bağlantı zaman aralığında değilsiniz
gibi bir uyarıda verebilirmi.

Teşekkürler.

Merhaba,

Buradaki linki incelerseniz, sizin işlemi GPO'lar ile yapabileceğinizi düşünüyorum.

*Eğer server bulut bir sunucuysa, bu ayarları yanlış yapmanız sonucu sunucuya erişiminizi tamamen kaybedebilirsiniz.

İyi çalışmalar.

Merhabalar, Admin haric diğer kullanıcılara uyguluyor. Ama dediğiniz gibi yanlışlıkla Admin içinde uygulanırsa o zaman biraz sorun oluşabilir. Smile
Link'i inceledim. Araştırmalarımda gözüme çarpmıştı. Detaylı incelediğimde ise, bu işlem kullanıcı uzak masaüstü bağlantı penceresini Sign Out yapmadan çıktığında kullanıcı belli bir süre sonrasında (belirlenen) oturumdan çıkma işlemi için kullanılan bir özellikti. 

Herkese cevaplarından ve desteklerinden ötürü teşekkür ederim
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Delphi IDE ve Snapdragon CPU'lu Windows 11 csunguray 20 7.798 22-07-2024, Saat: 23:12
Son Yorum: engerex
  Windows Home yüklü laptopu farkla pro nasıl yaparız? delphicim 5 2.617 12-02-2024, Saat: 08:22
Son Yorum: SercanTEK
  Windows 7 Siyah Ekran black screen Hatası Çözümü Javs 1 2.751 06-01-2020, Saat: 20:50
Son Yorum: Javs
  SQL Server Eğitimi Hakkında adelphiforumz 7 7.911 06-06-2018, Saat: 23:30
Son Yorum: FiRewaLL
  SQL Server Bağlantı Şekilleri Hakkında adelphiforumz 1 2.817 21-05-2018, Saat: 17:45
Son Yorum: DelphiCan



Konuyu Okuyanlar: 1 Ziyaretçi