Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried this code to deny browsing on port 80 but I still able to browse via this port. Source code:
C++
if(::PfCreateInterface(0,PF_ACTION_FORWARD,PF_ACTION_FORWARD,false,true,&ihandle)==NO_ERROR)
{
  AfxMessageBox("Step 1 Done");
  BYTE ip[4]={202,165,250,50};
  BYTE msk[4]={255,255,255,0};
  BYTE dm[4]={0,0,0,0};
  
  inFilter.dwFilterFlags = FD_FLAGS_NOSYN; //always this value
  inFilter.dwRule   = 0;   //always this value
  inFilter.pfatType  = PF_IPV4;  //using ipV4 addresses
   inFilter.SrcAddr  = (PBYTE)dm;
  inFilter.SrcMask  = (PBYTE)dm;   //mask for local ip
  inFilter.DstAddr  = (PBYTE)ip; //any destination
  inFilter.DstMask  = (PBYTE)msk;   
   inFilter.wSrcPort  =0;//any source port 
  inFilter.wSrcPortHighRange=4000;
  inFilter.wDstPort  = 80;   //destination port 80(http service)
  inFilter.wDstPortHighRange=80;
  inFilter.dwProtocol =(DWORD)FILTER_PROTO_ANY; //Tcp protocol
  DWORD err;
  err=::PfAddFiltersToInterface(ihandle,1,&inFilter,0,NULL,&fHandle);
  if(err==NO_ERROR)
   {
     if(::PfBindInterfaceToIPAddress(ihandle,PF_IPV4,(PBYTE)ip)==NO_ERROR)
    {
    AfxMessageBox("IP Adress Binded");
    }
 
  }
 }
Posted
Updated 20-Jun-10 7:23am
v2

1 solution

This not the right way to filter network traffic.

The best ways to filter network Traffic is as follows:

1. NDIS Protocol Driver Combined with NDIS Intermediate Drivers.
2. Hooks. (kind of a workaround in my humble opinion)

Good Luck!!

D,Kurt.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900