linux命令之strings


strings 命令是在对象文件或二进制文件中查找可打印的字符串。字符串是4个或者更多可打印字符串的任意序列,以换行符或者空字符结束。

strings语法
strings [options] file_name

options:
-a / -all : 扫描整个文件而不是只扫描目标文件初始化和装载段。
-f / -print-file-name:在显示字符串前显示文件名
-n / -bytes=[number]:找到并且输出说有NULL终止符序列
- num :设置显示的最少字符数(num是一个数字),默认是4个字符
-t {o,d,x}/-radix={o,d,x} :输出字符的位置,基于八进制,十进制或者十六进制。
-o :类似-radix=o
-T /-target= : 指定二进制文件格式
@:从文件中读取选项

示例:

$ gcc hello.c -o hello
$ strings hello
/lib/ld-linux.so.2
__gmon_start__
libc.so.6
_IO_stdin_used
printf
__libc_start_main
GLIBC_2.0
PTRh
UWVS
[^_]
;*2$"

$ cat test 
-f
-t d
$  strings @test hello
hello:     340 /lib/ld-linux.so.2
hello:     541 __gmon_start__
hello:     556 libc.so.6
hello:     566 _IO_stdin_used
hello:     581 printf
hello:     588 __libc_start_main
hello:     606 GLIBC_2.0
hello:     824 PTRh
hello:    1040 UWVS
hello:    1132 [^_]
hello:    1359 ;*2$"

相关内容