tcpdump 与 tcpflow(或“为什么 tcpdump ASCII 数据包数据不可读?”)
我已经使用了两者,我的结论是我可以使用 tcpflow 从网页读取 html 数据,但不能使用 tcpdump 这样做。我得到的最好的结果是一些丑陋的 ASCII 文本,其中有很多句点符号。
我的理解是 tcpdump 不会重新组装数据包,而 tcpflow 会。但如果这是关键的区别,那么来自 tcpdump 的数据包数据是否仍然是人类可读的 - 只是以较小的块形式?问题是 tcpdump 仅限于 ASCII 而大多数网络流量都以 UTF-8 编码吗?
我是网络分析/编程的新手,所以如果我遗漏了一些明显的东西,请原谅我。
I have used both, and I conclude that I can read html data from webpages with tcpflow but cannot do so with tcpdump. The best I get is some ugly ASCII text with lots of period symbols.
My understanding is that tcpdump doesn't reassemble packets, whereas tcpflow does. But if that was the key difference, wouldn't the packet data from tcpdump still be human readable - just in smaller chunks? Is the problem that tcpdump is limited to ASCII and most network traffic is encoded in UTF-8?
I'm a rookie on network analysis/programming so forgive me if I'm missing something obvious.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取加密数据,应使用 tcpdump 和选项
tcpdump –A
(大写 a)。它传输没有任何标题的文本,主要用于网页。因此我们很容易获得响应页面。我认为您对应用程序层和传输层数据包感到困惑。
我不知道 tcpflow 但 tcpdump 捕获整个数据包(包括标头和所有其他内容)而不仅仅是数据。您提到的 html 数据将位于 tcp/udp/icmp 数据包的数据部分中,无论您使用哪种数据包因此它还需要您了解 tcp/udp/icmp 数据包的结构...
我在我的机器上捕获此数据包并且 HTML 数据清晰可见,您需要编写脚本以从输出中获取它,并了解以下知识包 结构。
最后 7-8 行描述了 html 数据。
使用
-s0
捕获整个帧,使用-X
以上述 ASCII 人类可读格式打印。要获取加密数据,应使用带有选项 –A(大写 a)的 TCPDUMP。它传输没有任何标题的文本,主要用于网页。因此我们很容易得到响应页面。
例如:
我在端口80请求index.html到172.31.9.84
然后我请求GET/index.html(一个示例页面仅包含文本“印度理工学院这是测试页面”)
此时当我捕获数据包时我得到的东西是:
To get that encrypted data one should use tcpdump with option
tcpdump –A
(capital a). It transfers text without any headers and is used mainly for web pages. Hence we get response page easily.I think you are getting confused between an application layer and transport layer packet.
I do not know about tcpflow but tcpdump capture the whole packet (including header and all other stuff) not just the data.The html data which you are mentioning would be in the data part of a tcp/udp/icmp packet whichever you are using and so it needs you to understand the structure of tcp/udp/icmp packet as well ...
I capture this packet on my machine and HTML data is clearly visible , you need to write script to get it from the output with a knowledge of packet structure.
The last 7-8 lines describe the html data.
use
-s0
to capture whole frame and-X
to print in above ASCII human readable format.To get that encrypted data one should use TCPDUMP with option –A (capital a). It transfers text without any headers and is used mainly for web pages. Hence we get response page easily.
For eg:
I request index.html to 172.31.9.84 at port 80
Then I requested GET/index.html (an example page that contains only text “Indian institute of technology this is the test page”)
At this moment when I captured packets I got something as:
当尝试使用 tcpdump 获取 HTTP 数据时,如果应用 -A 选项,您将看到 ASCII 格式的明文文本。然而,HTTP 数据几乎总是使用 gzip 模式或其他模式进行压缩。您可以在标题中看到它:
因此,tcpdump 将在屏幕上输出几个字节,它们是压缩数据!您需要使用 tshark 或wireshark 来查看平面数据。那么你的问题不是UTF8。
您可以在 Apache Web 服务器中禁用 deflate 模块来测试 tcpdump 数据显示。
希望这有帮助。
When trying to get HTTP data using tcpdump, you will see clear text in ASCII if you apply the -A option. However, a HTTP data is almost always compressed with gzip mode or other. You can see it in headers:
Thus, tcpdump will output in your screen several bytes and they are the compressed data!!! You will need to use tshark or wireshark to see flat data. Then your problem isn't UTF8.
You can test tcpdump data display disabling deflate module in Apache web server.
Hope this help.