strings

テキスト処理

書き方

strings [file]

バイナリから文字らしく見える部分を抜き出します。文字に見えれば何でも拾うので、多くは意味ではなく偶然です。

よく使うオプション

オプション意味
-nReport only runs of at least N characters; the default is 4
-tPrint the offset in the file, as d, o or x
-aScan the whole file, not only the loaded sections
-oBSD and macOS: prefix each hit with its decimal offset
-eGNU: set the encoding, such as l for 16-bit little-endian

strings app.bin | grep -i version

Finds a version string inside a binary.

strings -n 8 core.dump

Only sequences of eight characters or more.

パイプでつないで使うのが本来の形です。ひとつで全部やるより、三つつないだ方が短くなります。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. strings は何をしますか。

バイナリから文字らしく見える部分を抜き出します。文字に見えれば何でも拾うので、多くは意味ではなく偶然です。

Q. どう打ちますか。

strings [file] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは5個です。全部は man strings にあります。このコマンドはテキスト処理の仲間です。

関連するコマンド

man ページ: man strings