如何使用 tcpdump 捕获所有 HTTP 数据包
我想使用一些参数运行 tcpdump(仍然不知道该使用什么),然后加载 stackoverflow.com 页面。
输出应该是 HTTP 通信。后来,我想将其用作 shell 脚本,因此每当我想检查站点 site.com 的 HTTP 通信时,我只需运行 script.sh site.com
即可。
HTTP 通信应该足够简单。像这样:
GET /questions/9241391/how-to-capture-all-the-http-communication-data-using-tcp-dump
Host: stackoverflow.com
...
...
HTTP/1.1 200 OK
Cache-Control: public, max-age=60
Content-Length: 35061
Content-Type: text/html; charset=utf-8
Expires: Sat, 11 Feb 2012 15:36:46 GMT
Last-Modified: Sat, 11 Feb 2012 15:35:46 GMT
Vary: *
Date: Sat, 11 Feb 2012 15:35:45 GMT
....
decoded deflated data
....
现在,我应该使用 tcpdump 的哪些选项来捕获它?
I want to run tcpdump
with some parameters (still don't know what to use), then load the stackoverflow.com page.
Output should be the HTTP communication. Later, I want to use it as a shell script, so whenever I want to check the HTTP communication of a site site.com, I just can run script.sh site.com
.
The HTTP communication should be simple enough. Like this:
GET /questions/9241391/how-to-capture-all-the-http-communication-data-using-tcp-dump
Host: stackoverflow.com
...
...
HTTP/1.1 200 OK
Cache-Control: public, max-age=60
Content-Length: 35061
Content-Type: text/html; charset=utf-8
Expires: Sat, 11 Feb 2012 15:36:46 GMT
Last-Modified: Sat, 11 Feb 2012 15:35:46 GMT
Vary: *
Date: Sat, 11 Feb 2012 15:35:45 GMT
....
decoded deflated data
....
Now, which options should I use with tcpdump
to capture it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可以通过
ngrep
来完成It can be done by
ngrep
根据您所提到的,ngrep(在 Unix 上)和 Fiddler(Windows)可能是更好/更简单的解决方案。
如果您绝对想使用 tcpdump,请尝试以下选项
Based on what you have mentioned, ngrep (on Unix) and Fiddler (Windows) might be better/easier solutions.
If you absolutely want to use tcpdump, try out the following options
请参阅http://www.tcpdump.org/manpages/tcpdump.1.html
see http://www.tcpdump.org/manpages/tcpdump.1.html