在 Debian(或任何 Linux)系统中,strings 命令常用于从二进制文件中提取可打印字符串。如果你想要批量处理多个文件,常见做法有下面几种。
for 循环for f in /path/to/files/*; do
echo "=== $f ==="
strings "$f"
done
如果只处理某种类型(如 .bin):
for f in /path/to/files/*.bin; do
strings "$f"
done
findfind /path/to/dir -type f -exec strings {} \;
为每个文件加文件名:
find /path/to/dir -type f -exec sh -c 'echo "=== $1 ==="; strings "$1"' _ {} \;
find /path/to/dir -type f -exec strings {} \; > all_strings.txt
for f in /path/to/files/*; do
strings "$f" > "$f.txt"
done
strings 对文本文件意义不大,可配合 file 过滤:
find /path/to/dir -type f -exec sh -c '
if file -b "$1" | grep -q "executable\|ELF\|shared object"; then
strings "$1"
fi
' _ {} \;
xargs -Pfind /path/to/dir -type f | xargs -P 4 -I {} sh -c 'echo "=== {} ==="; strings "{}"'
strings binary_file | grep -i "error\|password"
批量:
find /path/to/dir -type f -exec sh -c 'strings "$1" | grep -i "password"' _ {} \;
如果你能说明:
我可以给你更精确的命令。