如何在wireshark中仅导出可打印文本(或任何其他数据包属性)

发布于 2024-10-10 00:04:28 字数 292 浏览 5 评论 0原文

长话短说 - 我正在使用 Wireshark 将 SQL 从供应商工具捕获到 Oracle 数据库。它已经有 TNS 协议的解码器(这很棒),我可以通过以下方式访问 SQL 文本。

Right Click->Copy->Bytes(Printable Text Only). 

问题是有大量数据包,右键单击每个数据包可能需要很长时间。我想知道是否有任何方法可以直接从 Wireshark 导出“仅可打印文本”。理想情况下,我想要一个包含语句的文本文件。

任何帮助将不胜感激。

Long story short - I'm capturing SQLs from vendor tool to Oracle database by using Wireshark. It already has decoder for TNS protocol (which is great) and I can access text of SQL by

Right Click->Copy->Bytes(Printable Text Only). 

The problem is that there are tons of packets and doing right-click on each of them could take ages. I was wondering if there any way to export 'Printable Text Only' right from Wireshark. Ideally I want to have a text file with statements.

Any help will be highly appreciated.

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

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

发布评论

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

评论(3

俏︾媚 2024-10-17 00:04:29

终于找到办法做到这一点。首先,使用 tshark 捕获 tns 数据包:

tshark -R tcp.port==1521 -T fields -e data.data -d tcp.port==1521,tns > input.txt

然后您可以使用下面的 homebrew Ruby 脚本将字节转换为文本:

file = ARGV[0]
print_all = ARGV[1]

File.open(file, "r").each {|line|
  line.gsub(",", ":").split(':').each {|byte|
    chr = Integer('0x' + byte).chr
    print chr if ((' '..'~').include?(chr) or chr == "\n") or (print_all.downcase == 'all' if print_all)
  } if !line.chomp.empty?
}

示例如下:

encode.rb input.txt > output.txt

将仅从输入导出可打印文本到输出

encode.rb input.txt  all > output.txt

将导出从输入到输出的所有文本

Finally found away to do this. First, use tshark capturing tns packets:

tshark -R tcp.port==1521 -T fields -e data.data -d tcp.port==1521,tns > input.txt

Then you could use home brew Ruby script below to transform from bytes to text:

file = ARGV[0]
print_all = ARGV[1]

File.open(file, "r").each {|line|
  line.gsub(",", ":").split(':').each {|byte|
    chr = Integer('0x' + byte).chr
    print chr if ((' '..'~').include?(chr) or chr == "\n") or (print_all.downcase == 'all' if print_all)
  } if !line.chomp.empty?
}

Examples are:

encode.rb input.txt > output.txt

will export printable text only from input to output

encode.rb input.txt  all > output.txt

will export all text from input to output

み青杉依旧 2024-10-17 00:04:29

查看对我有用的所有内容的一种简单方法就是右键单击 ->遵循 TCP 流。

注意:不可打印的字符显示为 .。如果您想要提取的所有文本之间散布着一堆这样的内容(就像我一样),请将其切换为 ASCII,保存并在您最喜欢的文本编辑器(对我来说是 vim)中打开它),然后运行搜索并替换,类似于 /\.//g

An easy way of looking at them all that has worked for me is just Right Click -> Follow TCP Stream.

A note: unprintable characters are displayed as .s. If there are a bunch of these interspersed between all the text you want to extract (as there was for me), switch it to ASCII, save it and open it in your favourite text editor (vim for me), then run a search and replace similar to /\.//g.

无悔心 2024-10-17 00:04:29

我不知道如何用 TNS 做到这一点。但是您可以使用 tshark 执行类似的操作,例如查看 http 请求。

tshark -T fields -e http.request.uri

因此,如果您可以查看 TNS 解码器中的选项,您应该能够获取该字段并将输出重定向到文件。

I don't know how to do it with TNS. but you can do something like this using tshark, for example to look at http requests.

tshark -T fields -e http.request.uri

So if you can look at the options in the TNS decoder, you should be able to grab that field and redirect the output to a file.

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