温馨提示×

linux strings如何显示偏移量

小樊
40
2026-09-02 10:53:00
栏目: 智能运维

在 Linux 下,strings 命令本身可以显示偏移量,通过 -t 选项即可。


一、strings 显示偏移量的方法

1️⃣ 显示十进制偏移量

strings -t d file

示例输出:

    512 This is a string
   1024 Another string

第一列就是字符串在文件中的十进制偏移(offset)


2️⃣ 显示八进制偏移量

strings -t o file

3️⃣ 显示十六进制偏移量(最常用)

strings -t x file

示例输出:

  0x200 This is a string
  0x400 Another string

二、常见组合用法

显示字符串最小长度 + 偏移量

strings -n 6 -t x file

只提取某些段(配合 objdump 等)

strings -t x -e l file

-e l 表示 16-bit little-endian)


三、grep 过滤偏移 + 内容

strings -t x file | grep "password"

输出示例:

0x1a34 password=123456

四、如果你想要“更精确”的偏移(节区级别)

strings 只能给文件偏移,如果你想要:

  • 虚拟地址(VA)
  • 节区偏移
  • 符号附近字符串

可以配合:

objdump -s -j .rodata file

readelf -x .rodata file

五、总结

需求 命令
十进制偏移 strings -t d
八进制偏移 strings -t o
十六进制偏移 strings -t x
最小长度 -n
过滤内容 grep

如果你是用于 二进制分析 / CTF / 逆向,可以告诉我具体场景,我可以给你更针对性的命令。

0