strings 指令
用途
在對象檔案或二進制檔案中查找可列印的字元串。
文法
strings [ -a ] [ - ] [ -o ] [ -t format ] [ -n number ] [ -number ] [ file ... ]
描述
strings 指令在 對象檔案或二進制檔案 中查找可列印的字元串。字元串是 4 個或更多可列印字元的任意序列,以換行符或空字元結束。 strings 指令對識别随機對象檔案很有用。
标志
-a 或 - 搜尋整個檔案,而不僅僅是資料段,以尋找可列印的字元串。如果省略這個标志,則 strings 指令隻在對象檔案的初始化資料空間内尋找。
-n number 指定最小的字元串長度(除了預設的 4 個字元以外)。字元串長度的最大值是 4096。這個标志與 -number 标志相同。
-o 列出檔案中每個跟随在其八進制偏移量之後的字元串。這個标志與 -t o 标志相同。
-t format 列出從檔案最開始起,每個跟随在其偏移量之後的字元串。該格式取決于用作 format 變量的字元。
d
以十進制寫下偏移量。
o
以八進制寫下偏移量。
x
以十六進制寫下偏移量。
注:當 -o 和 -t format 标志在一個指令行上多次定義,則最後指定的标志控制 strings 指令的行為。
-number 指定最小的字元串長度(除了預設的 4 個字元以外)。字元串長度的最大值是 4096。這個标志與 -n number 标志相同。
file 要搜尋的二進制檔案或對象檔案。
退出狀态
該指令傳回以下退出值:
0 表示指令成功運作。
>0 表示出錯。
strings 指令顯示:
以十六進制寫下偏移量,列印文本檔案中最小字元串長度大于40的
[czmmiao@czmmiao ~]$ strings -t x -40 /etc/profile
10 # system wide environment and startup programs, for login setup
50 # functions and aliases go in /etc/bashrc
7b # it's not good idea to change this file unless you know what you
bd # are doing. much better way is to create custom.sh shell script in
101 # /etc/profile.d/ to make custom changes to environment. this will
144 # prevent need for merging in future updates.
1c6 if [ "$2" = "after" ] ; then
436 if [ "$histcontrol" = "ignorespace" ] ;
4b0 then export path user logname mail hostname histsize histcontrol
以八進制寫下偏移量,列印二進制檔案2010_12_02.jpg中不少于10個的字元串
[czmmiao@czmmiao ~]$ strings -t o -n 10 2010_12_02.jpg
26324 pd2n`g09d3
43705 ksqey<)iu4'
47750 @(sx9!lf7z
53461 @(sx9!lf7z
參考至:http://blog.csdn.net/lvhongya/archive/2010/10/27/5970364.aspx
本文原創,轉載請注明出處、作者
如有錯誤,歡迎指正
作者:czmmiao 原文位址:http://czmmiao.iteye.com/blog/911108