Linux 文本编辑器类似于记事本++用于处理数据包捕获

发布于 2024-09-24 20:50:31 字数 2800 浏览 0 评论 0原文

我正在寻找 Notepad++ 在 Linux 文本编辑器中具有的非常具体的功能。

如果您使用 tcpdump -x 来获取网络流量的十六进制转储,Notepad++ 允许您通过 Alt-mouse-select 然后 轻松删除左侧的十六进制删除。一些简短的替换空格和换行符可以让你把这个:

 0x0000:  0024 b295 af65 0021 705d 1394 0800 4500  .$...e.!p]....E.
 0x0010:  01c5 c2b4 4000 4006 dfa9 c0a8 0502 adc2  ....@.@.........
 0x0020:  2368 cdf7 0050 434c f5f8 c5a6 6c30 8018  #h...PCL....l0..
 0x0030:  002e 1274 0000 0101 080a 0072 3747 3dbf  ...t.......r7G=.
 0x0040:  7f35 4745 5420 2f20 4854 5450 2f31 2e31  .5GET./.HTTP/1.1
 0x0050:  0d0a 486f 7374 3a20 676f 6f67 6c65 2e63  ..Host:.google.c
 0x0060:  6f6d 0d0a 436f 6e6e 6563 7469 6f6e 3a20  om..Connection:.
 0x0070:  6b65 6570 2d61 6c69 7665 0d0a 4163 6365  keep-alive..Acce
 0x0080:  7074 3a20 6170 706c 6963 6174 696f 6e2f  pt:.application/
 0x0090:  786d 6c2c 6170 706c 6963 6174 696f 6e2f  xml,application/
 0x00a0:  7868 746d 6c2b 786d 6c2c 7465 7874 2f68  xhtml+xml,text/h
 0x00b0:  746d 6c3b 713d 302e 392c 7465 7874 2f70  tml;q=0.9,text/p
 0x00c0:  6c61 696e 3b71 3d30 2e38 2c69 6d61 6765  lain;q=0.8,image
 0x00d0:  2f70 6e67 2c2a 2f2a 3b71 3d30 2e35 0d0a  /png,*/*;q=0.5..
 0x00e0:  5573 6572 2d41 6765 6e74 3a20 4d6f 7a69  User-Agent:.Mozi
 0x00f0:  6c6c 612f 352e 3020 2858 3131 3b20 553b  lla/5.0.(X11;.U;
 0x0100:  204c 696e 7578 2078 3836 5f36 343b 2065  .Linux.x86_64;.e
 0x0110:  6e2d 5553 2920 4170 706c 6557 6562 4b69  n-US).AppleWebKi
 0x0120:  742f 3533 342e 3320 284b 4854 4d4c 2c20  t/534.3.(KHTML,.
 0x0130:  6c69 6b65 2047 6563 6b6f 2920 4368 726f  like.Gecko).Chro
 0x0140:  6d65 2f36 2e30 2e34 3732 2e36 3220 5361  me/6.0.472.62.Sa
 0x0150:  6661 7269 2f35 3334 2e33 0d0a 4163 6365  fari/534.3..Acce
 0x0160:  7074 2d45 6e63 6f64 696e 673a 2067 7a69  pt-Encoding:.gzi
 0x0170:  702c 6465 666c 6174 652c 7364 6368 0d0a  p,deflate,sdch..
 0x0180:  4163 6365 7074 2d4c 616e 6775 6167 653a  Accept-Language:
 0x0190:  2065 6e2d 5553 2c65 6e3b 713d 302e 380d  .en-US,en;q=0.8.
 0x01a0:  0a41 6363 6570 742d 4368 6172 7365 743a  .Accept-Charset:
 0x01b0:  2049 534f 2d38 3835 392d 312c 7574 662d  .ISO-8859-1,utf-
 0x01c0:  383b 713d 302e 372c 2a3b 713d 302e 330d  8;q=0.7,*;q=0.3.
 0x01d0:  0a0d 0a                                

...变成这个,这更具可读性:

.$...e.!p]....E.....@.@.........#h...PCL....l0.....t.......r7G=..5
GET./.HTTP/1.1..Host:.google.com..Connection:.keep-alive. .Accept:.
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5..User-Agent:.Mozilla/5.0.(X11;.U;.Linux.x86
_64;.en-US).AppleWebKit/534.3.(KHTML,.like.Gecko).Chrome/6.0.472.62
.Safari/534.3..Accept-Encoding:.gzip,deflate,sdch..Accept-Language:
.en-US,en;q=0.8..Accept-Charset:.ISO-8859-1,utf-8;q=0.7,*;q=0.3....

那么,有人知道一个可以轻松剪切此类数据的 Linux 文本编辑器吗?

I am looking for a very specific functionality which Notepad++ has in a Linux text editor.

If you use tcpdump -x to get a hex dump of network traffic, Notepad++ allows you to easily strip away the left hex via Alt-mouse-select and then Delete. Some short replace spaces and line returns lets you turn this:

 0x0000:  0024 b295 af65 0021 705d 1394 0800 4500  .$...e.!p]....E.
 0x0010:  01c5 c2b4 4000 4006 dfa9 c0a8 0502 adc2  ....@.@.........
 0x0020:  2368 cdf7 0050 434c f5f8 c5a6 6c30 8018  #h...PCL....l0..
 0x0030:  002e 1274 0000 0101 080a 0072 3747 3dbf  ...t.......r7G=.
 0x0040:  7f35 4745 5420 2f20 4854 5450 2f31 2e31  .5GET./.HTTP/1.1
 0x0050:  0d0a 486f 7374 3a20 676f 6f67 6c65 2e63  ..Host:.google.c
 0x0060:  6f6d 0d0a 436f 6e6e 6563 7469 6f6e 3a20  om..Connection:.
 0x0070:  6b65 6570 2d61 6c69 7665 0d0a 4163 6365  keep-alive..Acce
 0x0080:  7074 3a20 6170 706c 6963 6174 696f 6e2f  pt:.application/
 0x0090:  786d 6c2c 6170 706c 6963 6174 696f 6e2f  xml,application/
 0x00a0:  7868 746d 6c2b 786d 6c2c 7465 7874 2f68  xhtml+xml,text/h
 0x00b0:  746d 6c3b 713d 302e 392c 7465 7874 2f70  tml;q=0.9,text/p
 0x00c0:  6c61 696e 3b71 3d30 2e38 2c69 6d61 6765  lain;q=0.8,image
 0x00d0:  2f70 6e67 2c2a 2f2a 3b71 3d30 2e35 0d0a  /png,*/*;q=0.5..
 0x00e0:  5573 6572 2d41 6765 6e74 3a20 4d6f 7a69  User-Agent:.Mozi
 0x00f0:  6c6c 612f 352e 3020 2858 3131 3b20 553b  lla/5.0.(X11;.U;
 0x0100:  204c 696e 7578 2078 3836 5f36 343b 2065  .Linux.x86_64;.e
 0x0110:  6e2d 5553 2920 4170 706c 6557 6562 4b69  n-US).AppleWebKi
 0x0120:  742f 3533 342e 3320 284b 4854 4d4c 2c20  t/534.3.(KHTML,.
 0x0130:  6c69 6b65 2047 6563 6b6f 2920 4368 726f  like.Gecko).Chro
 0x0140:  6d65 2f36 2e30 2e34 3732 2e36 3220 5361  me/6.0.472.62.Sa
 0x0150:  6661 7269 2f35 3334 2e33 0d0a 4163 6365  fari/534.3..Acce
 0x0160:  7074 2d45 6e63 6f64 696e 673a 2067 7a69  pt-Encoding:.gzi
 0x0170:  702c 6465 666c 6174 652c 7364 6368 0d0a  p,deflate,sdch..
 0x0180:  4163 6365 7074 2d4c 616e 6775 6167 653a  Accept-Language:
 0x0190:  2065 6e2d 5553 2c65 6e3b 713d 302e 380d  .en-US,en;q=0.8.
 0x01a0:  0a41 6363 6570 742d 4368 6172 7365 743a  .Accept-Charset:
 0x01b0:  2049 534f 2d38 3835 392d 312c 7574 662d  .ISO-8859-1,utf-
 0x01c0:  383b 713d 302e 372c 2a3b 713d 302e 330d  8;q=0.7,*;q=0.3.
 0x01d0:  0a0d 0a                                

...into this, which is much more readable:

.$...e.!p]....E.....@.@.........#h...PCL....l0.....t.......r7G=..5
GET./.HTTP/1.1..Host:.google.com..Connection:.keep-alive. .Accept:.
application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5..User-Agent:.Mozilla/5.0.(X11;.U;.Linux.x86
_64;.en-US).AppleWebKit/534.3.(KHTML,.like.Gecko).Chrome/6.0.472.62
.Safari/534.3..Accept-Encoding:.gzip,deflate,sdch..Accept-Language:
.en-US,en;q=0.8..Accept-Charset:.ISO-8859-1,utf-8;q=0.7,*;q=0.3....

So, does anyone know a Linux text editor which can easily cut through this type of data?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

久随 2024-10-01 20:50:31

在文本编辑器中破解十六进制表示是一种石刀和熊皮的方法去做吧。相反,请使用 Wireshark跟随 TCP 流功能。它位于“分析”菜单上。它也位于右键单击数据包列表中的一行所获得的上下文菜单中。

此功能不仅向您提供捕获的流的纯文本表示形式(这正是您的十六进制转储黑客所想要的),它还以不同的颜色交错对话的两半,以便您可以在已发送消息的上下文中看到每个回复造成了它。您可以让它仅显示发送的一半或仅显示接收的一半。它甚至可以进行一些基本的格式化,例如解释换行符,这对于 HTTP 等协议非常有帮助。

使用 Wireshark GUI 并不总是很方便。对于必须使用 tshark 或 tcpdump 进行捕获的情况,您可以使用捕获文件:

$ tshark -w stuff-to-analyze.pcap -i eth1 host 1.2.3.4 and port 5678

您可以在只有 SSH 或调制解调器访问权限的远程 Unix 机器上运行它到,例如。将 stuff-to-analyze.pcap 文件发送回您的桌面工作站,您可以在 Wireshark 中加载该文件进行分析。

Hacking away the hex representation in a text editor is a stone knives and bearskins way to go about it. Instead, use Wireshark's Follow TCP Stream feature. It's on the Analyze menu. It's also on the context menu you get by right-clicking a line in the packet list.

This feature not only presents you with the plain text representation of the captured stream — which is what you wanted with your hex dump hackery — it interleaves both halves of the conversation in different colors so you can see each reply in context with the sent message that caused it. You can instead make it show you just the sending half or just the receiving half. It even does some rudimentary formatting, like interpreting newlines, very helpful with protocols like HTTP.

It isn't always convenient to use the Wireshark GUI. For those times you must use tshark or tcpdump to make the capture, you can use capture files:

$ tshark -w stuff-to-analyze.pcap -i eth1 host 1.2.3.4 and port 5678

You can run that on a remote Unix box you only have SSH or modem access to, for example. Send the stuff-to-analyze.pcap file back to your desktop workstation where you can load it up in Wireshark to analyze it.

地狱即天堂 2024-10-01 20:50:31

Gvim 有一个菜单项 tools->convert to hex,可以与块选择 (CTRL-Q) 和其他替换一起使用。不过,我强烈建议使用 Wireshark 进行处理或使用 Wireshark 的导出功能在文本文件中获取格式良好的数据包。

Gvim has a menu item tools->convert to hex that can be used with blockwise select (CTRL-Q) and your other substitutions. However, I highly recommend either processing with Wireshark or using Wireshark's export function to get nicely formatted packets in a text file.

云淡月浅 2024-10-01 20:50:31

Geany(适用于 Linux)与 Notepadd++(适用于 Windows)几乎完全相同。

Geany (for Linux) is almost the exact same thing as Notepadd++ (for Windows).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文