温馨提示×

如何用linux strings取证

小樊
34
2026-09-05 14:01:11
栏目: 智能运维

在 Linux 下进行strings 取证,通常是指从二进制文件、内存镜像、磁盘镜像或日志中提取可读字符串,以发现痕迹、口令、路径、URL、命令、恶意特征等。下面按“思路 + 用法 + 实战技巧”来说明。


一、strings 是什么

strings 用于从文件中提取可打印字符序列(默认长度 ≥ 4)。

基本语法:

strings [选项] 文件

二、常见取证场景

1️⃣ 对可疑二进制文件取证

strings suspicious.bin

关注:

  • /bin/sh
  • wget / curl
  • IP、域名
  • 密码、token
  • 编译路径(/home/xxx/

2️⃣ 指定最小字符串长度(更精准)

strings -n 6 file

减少噪声,适合大文件。


3️⃣ 显示字符串偏移(非常重要)

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

可用于:

  • 配合 xxd / hexdump 定位
  • 写报告时标注证据位置

4️⃣ 内存镜像 / 磁盘镜像取证

strings -n 8 memory.img > strings.txt
grep -i "password\|token\|http" strings.txt

常用组合:

strings -n 6 -t x disk.img | grep -i "ssh"

5️⃣ 查找 IP / 域名 / URL

strings file | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}"
strings file | grep -E "https?://"

6️⃣ 查找用户名 / 路径

strings file | grep -E "/home/|/etc/|/var/"

7️⃣ 编码与字符集问题

如果看到乱码:

strings -e l file   # 16-bit little endian
strings -e b file   # 16-bit big endian
strings -e s file   # 7-bit

三、结合其他工具(取证更强)

strings + grep

strings -n 6 bin | grep -i "pass"

strings + xxd

strings -t x bin
xxd -s 0x1234 bin

strings + binwalk(固件取证)

binwalk firmware.bin
strings firmware.bin | less

strings + volatility(内存取证)

vol.py strings -f mem.vmem

四、真实取证例子

发现隐藏命令

strings malware | grep -i "rm -rf"

发现 C2 地址

strings malware | grep -E "https?://[a-z0-9.]+"

发现编译者信息

strings malware | grep "/home/"

五、取证注意事项(很重要)

✅ 保留原始文件哈希

sha256sum file

✅ 只读挂载磁盘镜像
✅ strings 只是初步线索,不是结论
✅ 报告中写清:文件、偏移、字符串内容


六、最小化实战模板

strings -n 6 -t x suspect.bin > out.txt
grep -iE "pass|token|http|/home|wget|curl" out.txt

如果你愿意,可以告诉我:

  • 磁盘 / 内存 / 二进制 / 日志 取证?
  • 是否用于 CTF / 真实案件 / 安全分析

我可以直接给你针对性命令或分析思路

0