温馨提示×

怎样批量跑debian strings

小樊
47
2026-10-12 21:42:39
栏目: 智能运维

在 Debian(或一般 Linux)环境下,批量对一批文件跑 strings 通常有几种常见做法,取决于你的使用场景(目录、递归、文件类型等)。


一、最简单:对目录下所有文件

strings *

或递归整个目录:

find . -type f -exec strings {} \;

二、批量保存结果(推荐)

1️⃣ 每个文件一个输出

mkdir strings_out
for f in *; do
    [ -f "$f" ] && strings "$f" > "strings_out/$f.txt"
done

2️⃣ 所有文件合并到一个文件

find . -type f -exec strings {} \; > all_strings.txt

三、只处理某种文件(如 ELF / 二进制)

只处理 ELF 文件

find . -type f -exec sh -c '
    file "$1" | grep -q ELF && strings "$1"
' _ {} \; > elf_strings.txt

四、提高性能(大文件 / 多核)

使用 xargs 并行

find . -type f -print0 | xargs -0 -P 4 -I {} sh -c 'strings "{}" > "{}.str"'
  • -P 4:4 个并行进程
  • 每个文件生成 .str 文件

五、结合 grep 批量提取关键字

find . -type f -exec strings {} \; | grep -i "password\|token\|key"

六、Debian 安装 strings

如果系统没有:

sudo apt update
sudo apt install binutils

七、常见实用参数

strings -n 6 file        # 最小长度 6
strings -e l file        # 16-bit little endian
strings -a file          # 扫描整个文件

如果你能说明:

  • 是 二进制 / 固件 / 日志 / 源码?
  • 是否要 递归 / 并行 / 输出格式?

我可以给你更精确的批量脚本。

0 踩