Skip to content
systemcoding.dev
Security

Find long printable strings with strings -n 8

Pull readable text out of a binary with strings -n 8 to skip short noise, a first look for keys, URLs and debug messages in a file you did not build.

1 min read
Summarize in AI

strings prints every run of printable characters it finds in a file. The default minimum length is 4, which fills the output with accidents like the bytes Aq@h, so raising it to 8 keeps mostly real text. This is the first thing to run on a suspicious binary or a firmware image, since developers leave hostnames, paths and default passwords as plain constants.

banner.cc
#include <stdio.h>

static const char token[] = "deploy-key: hunter2-hunter2";

int main(void)
{
    puts(token);
    return 0;
}
Shell
gcc banner.c -o banner
strings -n 8 banner | grep deploy
Text
deploy-key: hunter2-hunter2

By default the tool scans only the loaded sections of an ELF file, and -a makes it scan the whole file. UTF-16 text, which Windows binaries use, needs -e l for little-endian wide characters. Add -t x to print the file offset of each hit so you can jump to it in a hex editor. A string that does not appear is not proof of absence, because constants can be obfuscated or built at run time. See the strings manual.

Also inAssembly
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.