title: Windows Filtering Platform to filter HTTPS from managed code
body: <p>I want to develop a host-based firewall for Windows mainly to filter URLs starting with HTTPS ! I know that Microsoft is presenting WFP as a substitution to the deprecated old techniques such as firewall/filter hooks, NDIS, TDI, WSA and Winsock 2 (LSP). But WFP does not currently support filters with hostname or URL. Also, WFP is only in C/C++ and there is no available C# wrappers in .NET. </p>
  
  <p>I tried @basil 's <a href="http://reqrypt.org/windivert.html" rel="nofollow">WinDivert</a> demo app webfilter which parses packets in outbound traffic for IPv4 on TCP port 80 (default HTTP), reset server connection (TCP RST) and send a HTML response to the client (browser) followed by a TCP FIN in case the URL matches any of the blacklisted entries given in a text file as command line argument and re inject them otherwise...</p>
  
  <pre><code> handle = WinDivertOpen(
          "outbound &amp;&amp; "              // Outbound traffic only
          "ip &amp;&amp; "                    // Only IPv4 supported
          "tcp.DstPort == 80 &amp;&amp; "     // HTTP (port 80) only
          "tcp.PayloadLength &gt; 0",    // TCP data packets only
          WINDIVERT_LAYER_NETWORK, priority, 0
      );
  </code></pre>
  
  <p>My question is : can I change this code to support HTTPS (change port to default 443) and also IPv6 ? If so, I'm willing to write a P\Invoke wrapper class to call it from managed C# code. </p>
  
  <p>Extra : This solution can be bypassed using SSH tunneling, is there another way to bypass it ?</p>