strings 是 Linux 下一个常用的命令行工具,用来从文件中提取可打印字符串。你问的“支持哪些格式”,可以从两个层面理解:输入文件格式 和 字符串/编码格式。下面分别说明。
strings 本身不限制文件格式,它可以处理任意二进制或文本文件,常见包括:
.txt、.log、配置文件等.so).img、.bin).zip、.tar、.gzstrings 只能看到压缩后的乱码或少量元信息/dev/sdacore dump 文件✅ 总结:strings 支持“任意格式文件”,但它只认字节流,不解析文件结构
默认情况下(GNU strings):
-e 指定编码格式GNU strings 支持以下编码:
| 参数 | 含义 |
|---|---|
-e s |
7-bit ASCII(默认) |
-e S |
8-bit 单字节字符 |
-e b |
16-bit Big Endian |
-e l |
16-bit Little Endian |
-e B |
32-bit Big Endian |
-e L |
32-bit Little Endian |
示例:
strings -e l file.bin
strings -n 2 file | iconv -f UTF-8 -t UTF-8
strings -e l file.exe
strings -n 6 file # 最少 6 个可打印字符
strings -a file # 扫描整个文件(不限于 .data 段)
strings -t x file # 显示偏移(十六进制)
strings -e l file # little-endian 16-bit
❌ 不支持:
# 从二进制中找路径
strings /bin/ls | grep /etc
# 分析固件
strings firmware.bin | less
# 查找 Windows 程序中的字符串
strings -e l program.exe
如果你是想问 “能不能解析某种具体格式(如 PNG / ELF / PDF)”,可以告诉我具体文件类型,我可以更针对性说明。