如何通过 Socks5/SSH/HTTPS 隧道重定向应用程序的连接?有什么推荐的 SDK 来完成这样的任务吗?

发布于 2024-08-31 19:19:13 字数 270 浏览 2 评论 0 原文

我需要通过 Socks5、SSH 或 HTTPS 对应用程序建立的连接(主要是 TCP)进行隧道传输。

到目前为止,我已经找到了 3 种方法来做到这一点:api hooks、winsock lsp 和驱动程序。

我正在寻找有关处理此问题的最佳方法的建议,以及任何可以为我抽象此任务的 SDK 的建议(首选免费/开源,但只要价格不高,也欢迎商业的) -人创办公司负担得起)。

附注我正在使用 .Net(C# 和/或 C++/CLI)

编辑:我无法控制目标应用程序。

I need to tunnel the connections (mostly TCP) made by an application through Socks5, SSH or HTTPS.

So far, I've found 3 ways to do this: api hooks, winsock lsp and a driver.

I'm looking for advice on the best way to handle this, and any recommendations on SDK's that could abstract this task for me (free/open-source preferred, but commercial ones are welcome as long as the price is not high for a one-man-starting-company to afford).

ps. I'm using .Net (C# and-or C++/CLI)

edit: I have no control whatsoever of the target application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

送君千里 2024-09-07 19:19:13

您可以直接调用 plink 命令行来创建隧道,然后从您的应用程序连接到本地主机。 Plink 是 Putty 的命令行版本,您有大量的选项,它是一个非常流行、安全且经过测试的应用程序。

您有一个应用程序(SSH 隧道客户端) 可以通过漂亮的 UI 为您完成此操作。它有点问题,但工作得很好。

此示例将远程计算机中的端口 80 连接到本地主机的端口 8000。

plink.exe -L 127.0.0.1:8000:127.0.0.1:80 -C -pw 1234 -2  -l user myserver.com

我不推荐这种方法的是,命令行包含密码,并且很容易使用任何流程管理器查看,现在 plink 的好处是您拥有可用的源代码,因此您可以将其集成到您的项目中。

编辑

现在假设您的应用程序连接到“yahoo.com”以获取一些数据,您无法修改应用程序,但可以设置中间人。您可以执行下一个命令:

plink.exe -L 127.0.0.1:80:google.com:80 -C -pw 1234 -2  -l user myserver.com

其中 myserver.com 是一个 SSH 服务器,允许您建立隧道并可以访问 google.com
现在以管理员身份转到 C:\windows\system32\drivers\etc\ 中的主机文件并添加下一个条目:

127.0.0.1 yahoo.com

您可以使用浏览器测试设置并导航到 yahoo.com,您将看到 google.com 页面。这看起来很简单,但真正的力量在于所有流量都通过 myserver.com 传递。

一些优点是

  1. 到 yahoo.com 的所有流量都是加密的
  2. 您可以使用此方法绕过代理限制
  3. 如果您可以从外部连接到 myserver.com 所在的内联网,则可以访问该内网
  4. 您可以记录或修改 yahoo.com 的数据连接

请注意,由于证书身份验证,此方法很可能在 HTTPS 连接上出现问题。

As a straight way you can invoke plink command line to create the tunnel and then connect to the localhost from your application. Plink is the commandline version of Putty, you have tons of options and it is a very popular, safe and tested application.

You have an application (SSH Tunnel Client) that does it for you with a nice UI. It is a bit buggy but it works just fine.

This example connects the port 80 in the remote machine to the port 8000 of your local host.

plink.exe -L 127.0.0.1:8000:127.0.0.1:80 -C -pw 1234 -2  -l user myserver.com

What I don't recommend of this method is that the commandline contains the password and it is easy to see with any process manager, now the good thing of plink is that you have the source code available so you can integrate it in your project.

Edit

Now imagine that your application connects to "yahoo.com" to get some data, you can't modify the application but you can setup a Man in the Middle. You can execute the next command:

plink.exe -L 127.0.0.1:80:google.com:80 -C -pw 1234 -2  -l user myserver.com

Where myserver.com is a SSH sever that allows you to do tunnels and has access to google.com
Now go to your hosts file in C:\windows\system32\drivers\etc\ as administrator and add the next entry:

127.0.0.1 yahoo.com

You can test the setup with your browser and navigate to yahoo.com an you will see the google.com page. It seems simple but the real power is that all the traffic is passing through myserver.com.

Some advantages are

  1. All the traffic to yahoo.com is encrypted
  2. You can bypass proxy restrictions with this method
  3. You can get access to the intranet where myserver.com is located if you can connect to it from the outside
  4. You can log or modify the data of the connection

Be aware that this method is very likely to have problems with HTTPS connections because of the certificates authentication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文