我可以使用tcpdump获得HTTP请求,响应头和响应体?可以使用、tcpdump、HTTP

2023-09-04 07:44:10 作者:陪你沦陷

我使用 tcpdump的通过执行以下命令获取HTTP数据:

I am using tcpdump to get HTTP data by executing the below command:

sudo tcpdump -A -s 1492 dst port 80

以上命令的结果是:

The result of above command:

标题,我想请求和响应头。 无法读取数据。 网址 GET /modules/mod_news_pro_gk1/cache/stories.ilbalad.ajayeb.strange-tractor.jpg 。 Headers, I think request and response headers. Unreadable data. The url GET /modules/mod_news_pro_gk1/cache/stories.ilbalad.ajayeb.strange-tractor.jpg.

我需要一个更明确的结果,例如,读取请求>响应头>响应主体等。 我如何过滤我的结果?

I need a more clear result, for example, readable request > response header > response body etc. How can I filter my results?

推荐答案

我会建议使用 Wireshark的,该有一个跟随TCP流选项,使得它很容易看到完整的请求和响应特定的TCP连接。如果你想preFER使用命令行,你可以试试 tcpflow ,一个专门的工具捕获和重建技术合作计划的内容流。

I would recommend using Wireshark, which has a "Follow TCP Stream" option that makes it very easy to see the full requests and responses for a particular TCP connection. If you would prefer to use the command line, you can try tcpflow, a tool dedicated to capturing and reconstructing the contents of TCP streams.

其他选项将使用一个HTTP调试代理,如查尔斯或的提琴手为EricLaw建议。这些都具有用于HTTP特定的支持,使其更容易与各种各样的编码和其他功能来处理像节能要求重放它们或编辑请求的优​​势。

Other options would be using an HTTP debugging proxy, like Charles or Fiddler as EricLaw suggests. These have the advantage of having specific support for HTTP to make it easier to deal with various sorts of encodings, and other features like saving requests to replay them or editing requests.

您也可以使用如萤火虫(火狐)的 Web检查(Safari浏览器,Chrome和其它基于WebKit的浏览器),或者的 Opera蜻蜓,所有这些都提供了一定的能力,以查看请求和响应标题和正文(虽然他们大多不会让你看到确切的字节流,而是如何浏览器解析的请求)。

You could also use a tool like Firebug (Firefox), Web Inspector (Safari, Chrome, and other WebKit-based browsers), or Opera Dragonfly, all of which provide some ability to view the request and response headers and bodies (though most of them don't allow you to see the exact byte stream, but instead how the browsers parsed the requests).

最后,你总是可以构建由手工请求,使用类似的telnet, netcat的或 socat 连接到端口80和人工输入请求,或类似的 htty 以帮助轻松地构建一个请求,并检查响应。

And finally, you can always construct requests by hand, using something like telnet, netcat, or socat to connect to port 80 and type the request in manually, or a tool like htty to help easily construct a request and inspect the response.