linux string命令

strings命令

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

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= : 指定二进制文件格式
@:从文件中读取选项

-e: --encoding={s,S,b,l,B,L}选择字符大小和字节顺序:s = 7位,S = 8位,{b,l} = 16位,{B,L} = 32位

实例:

列出ls中所有的ASCII文本:

[root@linux265 ~]# strings /bin/ls 

列出ls中所有的ASCII文本:

[root@linux265 ~]# cat /bin/ls strings 

查找ls中包含libc的字符串,不区分大小写:

[root@linux265 ~]# strings /bin/ls | grep -i libc

在显示字符串前先显示文件名:

[root@linux265 ~]# strings -f /bin/ls | grep libc 

输出字符的位置:

[root@linux265 ~]# strings -t /bin/ls | grep libc 

详细查看

https://blog.csdn.net/stpeace/article/details/46641069

https://blog.csdn.net/stpeace/article/details/50077677

原文地址:https://www.cnblogs.com/dork/p/13811036.html