strings 命令在 Linux 中用于顯示二進制文件中的可打印字符串。以下是一些常用的 strings 命令參數:
-a 或 --all
-n <number> 或 --bytes=<number>
strings 顯示至少連續 4 個可打印字符的字符串。通過指定 -n 參數,可以更改這個最小長度。-t <radix> 或 --radix=<radix>
-e <encoding> 或 --encoding=<encoding>
ascii, ibm866, utf8 等。這有助于正確解釋非 ASCII 字符。-f <filename> 或 --file=<filename>
-o <offset> 或 --offset=<offset>
-s <separator> 或 --separator=<separator>
-w 或 --wide
-v 或 --version
strings 命令的版本信息。-h 或 --help
-T <type> 或 --type=<type>
elf, pe, mach-o 等,這有助于 strings 更準確地解析特定格式的二進制文件。-I <directory> 或 --include-dir=<directory>
-L <directory> 或 --library-path=<directory>
-m <mask> 或 --mask=<mask>
-z 或 --null-terminated
# 顯示文件中的所有可打印字符串
strings example.bin
# 限制顯示長度為 6 個字符的字符串
strings -n 6 example.bin
# 指定輸出為十六進制格式
strings -t x example.bin
# 顯示寬字符字符串
strings -w example.bin
# 顯示特定文件類型中的字符串(如 ELF 格式)
strings -T elf example.bin
通過組合使用這些參數,你可以更靈活地控制 strings 命令的輸出,以滿足不同的需求。