Wireshark:转储客户端-服务器对话

Wireshark: Dump client-server dialogue

如果您在 wireshark 中使用 "Follow TCP stream",您将获得非常漂亮的客户端服务器对话显示。

一种颜色是客户端,另一种颜色是服务器。

有没有办法将其转储为 ascii 而不会丢失谁说了什么?

例如:

server> 220 "Welcome to FTP service for foo-server."
client> USER baruser
server> 331 Please specify the password.
client> supersecret

我想避免截屏。在行中添加 "server>" 和 "client>" 很容易出错。

使用 GUI 版本可能无法实现,但可以使用 console version tshark:

tshark -r capture.pcap -qz follow,tcp,ascii,<stream_id> > stream.txt

<stream_id>替换为实际的流ID(例如:1):

tshark -r capture.pcap -qz follow,tcp,ascii,1 > stream.txt

这将输出一个 ASCII 文件。它比直接从 GUI 版本保存更好吗?恩:

  • The data sent by the second node is prefixed with a tab to differentiate it from the data sent by the first node.

  • Since the output in ascii mode may contain newlines, the length of each section of output plus a newline precedes each section of output.

这使得文件易于解析。示例输出:

===================================================================
Follow: tcp,ascii
Filter: tcp.stream eq 1
Node 0: xxx.xxx.xxx.xxx:51343
Node 1: yyy.yyy.yyy.yyy:80
786
GET ...
Host: ...
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: */*
User-Agent: ...
Referer: ...
Accept-Encoding: ...
Accept-Language: ...
Cookie: ...

    235
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: ...
Expires: -1
X-Request-Guid: ...
Date: Mon, 31 Aug 2015 10:55:46 GMT
Content-Length: 0         
===================================================================

786\nNode 0 的第一个输出部分的长度。 \t235\n 是来自 Node 1 的响应部分的长度,依此类推。