.NET Native 应用程序相当于修改标头 Firefox Addon
我正在尝试用 C# 开发一个袜子隧道应用程序,该应用程序能够通过使用添加和修改的标头请求来打开网站(类似于 修改标头 Firefox 插件)并通过代理(最好是袜子)传输数据。请问有人可以指定我可能需要的任何资源吗?或者任何可以执行相同功能的替代方案,我可以构建的开源,等等。谢谢!
ps:应用程序还应该能够打开https和其他常见的网络协议
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是使用
HttpSys
并创建本地代理服务器来处理环回127.0.0.1
地址上的请求。您可以将系统代理更改为该地址/端口,并位于客户端和服务器之间。这将允许您修改请求/响应数据包和标头。 这里有一个 C# 方法的示例,我下面对此进行了修改以展示其工作原理。
这种方法的缺点是它的级别相当低,并且会影响用户计算机上的所有流量,这可能是不可取的。您必须处理 SSL 请求,并且它还会影响任何现有的已配置代理。
另一种替代方法是使用 Microsoft Internet Controls COM 组件并扩展 WebBrowser 类。这里有一个问题展示了这种方法。不幸的是,.NET 命名空间中的
WebBrowser
版本没有实现请求响应对象。有趣的部分如下。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.