`

Linux命令学习---Strings(原创)

阅读更多

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

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics