更改 tcp/ip 数据包 c++或java
情况是这样的。网络中有服务器和客户端。它们的通信方式如下:
- 客户端发送对某些功能的请求。
- 服务器向客户端发送函数参数。
- 客户端尝试执行功能并向服务器发送应答。
- 服务器向客户端发送它应该显示的数据。
但有时客户端无法执行功能并发送错误。我想捕获步骤 2 中的所有数据包,分析它们(我已经有相应的工具),防止其中一些数据包到达客户端,用我的程序处理它们并像步骤 3 中那样形成数据包。这必须在客户端上完成边。我既无法访问服务器也无法访问客户端。
所以,问题是:是否有用于在 C++ 或 Java 中更改、注入和删除 tcp/ip 数据包的库?该解决方案应该适用于 Win 和 Linux 系统。 另外,您是否有更好的想法来扩展客户端功能?
感谢您的帮助! 我试图用谷歌搜索如何更改数据包,但我得到的只是未回答的问题和嗅探器=(
编辑:实际上,我真的不需要注入和删除数据包,我可以仅通过更改数据包数据来管理它。此外,没有同一数据包中的多个请求,以及跨多个数据包的单个请求都不是问题。
Here is the situation. There are server and client in network. They communicate like this:
- Client sends request for some function.
- Server sends to client function parameters.
- Client trying to perform function and sends answer to server.
- Server sends to client data which it should show.
But sometimes client can't perform function and sends error. I want to catch all packets from step 2, analyze them (I've already have tools for that), prevent some of them to reach client, process them with my program and form packet like in step 3. This must be done on client side. I have no access neither to server nor to client.
So, the question is: Is there libraries for changing, injecting and removing tcp/ip packet in c++ or java? The solution should be working in both Win and Linux systems.
Also, may be you have better ideas to expand client functionality?
Thanks for any help!
I tried to google how to change packets, but all I got were unanswered questions and sniffers=(
Edit: Actually, I don't really need injecting and removing packets, I can manage it with only changing packet data. Also, there is no multiple requests in the same packet, and a single request across multiple packets is not a problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须为您的服务器构建一个代理。客户端连接到代理,代理本身连接到服务器。它只是在客户端和服务器之间路由所有包。
但它现在能够拦截特定消息并修改它们。想象一下一个过滤 HTTP 代理,它的工作方式是相同的。
You have to build a Proxy for your server. The client connects to the proxy, and the proxy itself connects to the server. It just routes all the packages between client and server.
BUT it is now able to intercept specific messages and to modify them. Imagine a filtering HTTP proxy, it works the same way.
我对 Linux 和 freeBSD 上的 libpcap 有个人经验,它是一种有助于捕获或注入数据包的低级库。我确实在 IPV6 网桥项目中使用了它...但我知道它有一个 Windows 端口。
http://sourceforge.net/projects/libpcap/
您可以让库:
但是您必须以非常原始的方式处理内部数据。该库的最佳文档是其头文件中的注释,这是最新的信息。也许有一些更舒适的高级库。
I have personal experience with libpcap on linux and freeBSD, a kind of lowlevel library that helps to catch or inject packets. I did use it in an IPV6 network bridge project... But i know there is a windows port for it.
http://sourceforge.net/projects/libpcap/
You can let the library to:
But you would have to work with internal data in a quite raw matter. Best documentation for this library are comments inside its header file, that is the most up to date info. Maybe there are some more comfortable highlevel libraries.