是否有一个实用程序可以从文件中的原始数据生成 UDP 和 TCP 数据包?

发布于 2024-08-01 21:14:21 字数 245 浏览 11 评论 0原文

我正在寻找一个实用程序,可以根据我在文件中提供给它的原始数据生成 UDP 或 TCP 数据包。 当然,我必须提供用于生成这些数据包的参数,如下所示:

UDP 端口号、TCP IP 地址、哪种 IP 类型(IPv4 或 IPv6)等

我可以将这些参数作为命令行或在某些配置文件中提供。 但它应该能够生成 UDP 或 TCP 数据包,并将其放在某个文本文件中供我查看。 我需要这个,因为我想使用该数据作为以太网驱动程序之一的输入数据。

I am looking for a utility which can generate UDP or TCP packets from the raw data which I provide to it in a file. Certainly I have to provide the parameters for generating those packets like below:

UDP port #, TCP IP address, which IP type (IPv4 or IPv6) etc

I can provide those parameters as command line or in some config file. But it should be able to generate the UDP or TCP packet out of it and give me that in some text file to view. I need this because I want to use that data as in put data to one of the ethernet driver.

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

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

发布评论

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

评论(4

空气里的味道 2024-08-08 21:14:21

您似乎正在寻找 hping

You appear to be looking for hping.

隐诗 2024-08-08 21:14:21

实际上,看起来您想要做的是将一些原始数据包装在 UDP 或 TCP 和 IP 标头中的文件中,然后获取“包装”数据输出? 请注意,这对于 TCP 来说是有问题的,因为它是双向协议,并且“包装”流将取决于远程站点的响应(重新传输、数据包大小等)。

实现此目的的一种快速但肮脏的方法是将数据传输到远程主机(对于 UDP 来说可能不存在,尽管您需要远程上的 TCP 侦听套接字。您可以通过 netcat 或 netcat6 for IPv6 传输此数据。然后您可以在同一台主机上运行 tcpdump 或wireshark机器将完整包装的流捕获到 PCAP 格式的文件中。此 PCAP 会将您的原始数据打包(UDP/TCP、IP 和以太网标头内的数据),

这听起来对于您的应用程序来说,您可能希望去掉以太网。在使用数据之前,

之前对此问题的回答建议使用 hping,这可能会给您带来更大的灵活性,但需要更长的学习曲线才能获得您想要的结果。

Effectively, it looks like what you are trying to do is wrap some raw data you already have in a file in UDP or TCP and IP headers and then get the 'wrapped' data output? Note that this will be problematic for TCP since its a two way protocol and the 'wrapped' stream would be dependant on the responses from the remote site (re transmissions, packet sizes, etc)

One quick and dirty way to accomplish this would be to transmit the data to a remote host (could be nonexistant for UDP, though you'd need a listening socket on the remote for TCP. You could transmit this data via netcat or netcat6 for IPv6. Then you can run tcpdump or wireshark on the same machine to capture the full wrapped stream to a file in PCAP format. This PCAP would have your raw data packetized (data inside UDP/TCP, IP, and Ethernet headers)

It sounds like for your application, you would want to strip out the ethernet headers before using the data.

A previous answer to this question recommended hping, which would probably give you more flexability at the expense of a longer learning curve to get the results you want.

静赏你的温柔 2024-08-08 21:14:21

Nmap 人员构建了一个 netcat 后继者,称为 Ncat,它包含在 Nmap 5 中。

The Nmap folk have built a netcat successor, called Ncat, which is included as part of Nmap 5.

心凉怎暖 2024-08-08 21:14:21

Python 完成这些任务的开销也很低。

http://www.amk.ca/python/howto/sockets/ 有关于如何开始的一个很好的教程。

Python also has low overhead to accomplish something along these lines.

http://www.amk.ca/python/howto/sockets/ has a good tutorial on how to get started.

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