I am trying to develop a socks tunneling application in c# that is able to open a website by using add and modified header requests (something similar to Modify Header Firefox Addon) and tunnel the data through a proxy (socks preferable). Please can anyone specify any resources I might need for this? Or any alternative that can perform the same function, open source that I can build on maybe, etc. Thanks!
ps: the applications should also be able to open https and other common network protocols
One way is to use
HttpSys
and create a local proxy server to handle request on the loopback127.0.0.1
address. You would be change the system proxy to this address/port and sit between client and server.This would allow you to modify request/response packets & headers. There's an example here of this approach in C#, and I've amended this below to show how it would work.
The downside to this approach is it's quite low level, and affects all traffic on the user machine which may not be desirable. You would have to handle SSL requests, and it would also impact any existing configured proxies.
Another alternative approach is to use the
Microsoft Internet Controls
COM component and to extend theWebBrowser
class. There's a SO question here that shows the approach. Unfortunately the version ofWebBrowser
in the .NET namespace does not implement the request response objects. The interesting bits are below.