温馨提示×

ubuntu strings参数怎么选

小樊
43
2026-09-03 09:56:54
栏目: 智能运维

在 Ubuntu(以及其他 Linux 发行版)中,strings 命令用于从二进制文件、核心转储或任意文件中提取可打印的字符串。它通常来自 binutils 包。

下面按常用场景给你讲怎么选参数。


一、最常用参数

1. 基本用法

strings file

提取文件中长度 ≥ 4 的可打印字符串(默认最小长度)。


2. 指定最小字符串长度 -n

strings -n 6 file

只显示长度 ≥ 6 的字符串,过滤掉短噪声。


3. 显示字符串在文件中的偏移量 -t

常见格式:

strings -t x file   # 十六进制偏移
strings -t d file   # 十进制偏移
strings -t o file   # 八进制偏移

示例输出:

00001234 main
00001240 printf

4. 只扫描某个区间 -e / -n 配合

strings -n 8 binary

二、字符编码相关(很重要)

5. 指定字符编码 -e

strings -e s file   # 7-bit ASCII(默认)
strings -e S file   # 8-bit ASCII
strings -e b file   # 16-bit BE
strings -e l file   # 16-bit LE
strings -e B file   # 32-bit BE
strings -e L file   # 32-bit LE

常用于:

  • Windows / UTF-16 字符串:strings -e l
  • 固件、嵌入式设备分析

三、高级用法

6. 从特定偏移开始扫描

strings -n 4 --radix=x file

7. 从 stdin 读取

cat file | strings

8. 配合 grep 使用(非常常见)

strings binary | grep -i password
strings -e l binary | grep -i config

9. 查看帮助

strings --help
man strings

四、实战示例

分析 ELF 程序里的字符串

strings -n 6 /bin/ls

分析 Windows exe(UTF-16)

strings -e l win.exe

查找可疑字符串

strings -t x binary | grep -i "http"

五、参数选择速查表

需求 参数
最小长度 -n
偏移地址 -t x/d/o
UTF-16 -e l
过滤噪音 -n 8
配合分析 grep

如果你有具体场景(比如逆向、取证、固件、ELF、exe),我可以给你更精确的命令。

0