嗅探并显示UTF-8中的TCP数据包 [英] Sniffing and displaying TCP packets in UTF-8
问题描述
我正在尝试使用tcpdump显示在我的网络上流动的tcp数据包的内容. 我有类似的东西:
I am trying to use tcpdump to display the content of tcp packets flowing on my network. I have something like:
tcpdump -i wlan0 -l -A
-A选项将内容显示为ASCII文本,但我的文本似乎是UTF-8.有没有一种方法可以使用tcpdump正确显示UTF-8?您知道其他任何有帮助的工具吗?
The -A option displays the content as ASCII text, but my text seems to be UTF-8. Is there a way to display UTF-8 properly using tcpdump? Do you know any other tools which could help?
非常感谢
推荐答案
请确保您的终端支持输出UTF-8,并将输出通过管道传递到替换不可打印字符的地方:
Make sure your terminal supports outputting UTF-8 and pipe the output to something which replaces non printable characters:
tcpdump -lnpi lo tcp port 80 -s 16000 -w - | tr -t '[^[:print:]]' ''
tcpdump -lnpi lo tcp port 80 -s 16000 -w - | strings -e S -n 1
如果您的终端不支持UTF-8,则必须将输出转换为支持的编码.例如:
If your terminal does not support UTF-8 you have to convert the output to a supported encoding . E.g.:
tcpdump -lnpi lo tcp port 80 -s 16000 -w - | tr -t '[^[:print:]]' '' | iconv -c -f utf-8 -t cp1251
-c
选项告诉iconv
忽略目标编码中没有有效表示的字符.
-c
option tells iconv
to omit character which does not have valid representation in the target encoding.
这篇关于嗅探并显示UTF-8中的TCP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!