在 Linux 下,strings 命令本身可以显示偏移量,通过 -t 选项即可。
strings 显示偏移量的方法strings -t d file
示例输出:
512 This is a string
1024 Another string
第一列就是字符串在文件中的十进制偏移(offset)。
strings -t o file
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)
strings -t x file | grep "password"
输出示例:
0x1a34 password=123456
strings 只能给文件偏移,如果你想要:
可以配合:
objdump -s -j .rodata file
或
readelf -x .rodata file
| 需求 | 命令 |
|---|---|
| 十进制偏移 | strings -t d |
| 八进制偏移 | strings -t o |
| 十六进制偏移 | strings -t x |
| 最小长度 | -n |
| 过滤内容 | grep |
如果你是用于 二进制分析 / CTF / 逆向,可以告诉我具体场景,我可以给你更针对性的命令。