天天看点

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

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

如有错误,欢迎指正

邮箱:[email protected]

作者:czmmiao 原文地址:http://czmmiao.iteye.com/blog/911108

继续阅读