1

当 Fiddler 不在 Mac OS X 或 Ubuntu 上时,如果我们不安装/使用 Wireshark 或任何其他更重型的工具,那么有什么方法可以tcpdump使用

1) 可以打印

GET /foo/bar HTTP/1.1
    [request content in RAW text]
    [response content in RAW text]
POST /foo/... HTTP/1.1

这应该可以通过 tcpdump 或在简短的 shell 脚本或 Ruby / Python / Perl 脚本中使用 tcpdump 来完成。

2)实际上,如果一个脚本可以输出HTML,那就太好了,

GET /foo/bar HTTP/1.1
POST /foo/... HTTP/1.1

在页面上,任何浏览器都可以显示,然后当单击任何这些行时,它将展开以显示 RAW 内容,如上面的 (1) 所示。再次单击,它将隐藏详细信息。扩展 UI 可以使用 jQuery 或任何 JS 库来完成。脚本可能很短......可能少于 20 行?有人知道如何为(1)或(2)做吗?

4

1 回答 1

1

这里有两个用于 HTTP GET 和 HTTP POST 的 tcpdump 过滤器:

# tcpdump filter for HTTP GET 
sudo tcpdump -s 0 -A 'tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420'

# tcpdump filter for HTTP POST 
sudo tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'
于 2011-03-13T14:45:58.117 回答