Explore Strings in Binary Files
In this step, you will learn how to use the strings
command to explore the contents of binary files, including executable files, libraries, and other types of binary data.
Let's start by examining the contents of a common executable file, such as the ls
command:
strings /bin/ls
Example output:
/lib64/ld-linux-x86-64.so.2
libc.so.6
__stack_chk_fail
__cxa_finalize
setlocale
bindtextdomain
textdomain
_ITM_deregisterTMCloneTable
__gmon_start__
_ITM_registerTMCloneTable
...
As you can see, the strings
command extracts all the printable character sequences from the binary file, which can reveal useful information about the file's contents, such as library dependencies, version information, and other embedded data.
You can also use the strings
command to explore the contents of other types of binary files, such as libraries or compressed archives. For example, let's examine the contents of the libc.so.6
library:
strings /lib/x86_64-linux-gnu/libc.so.6
Example output:
GNU C Library (GNU libc) stable release version 2.35.
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 11.2.0.
Compiled on a Linux 5.15 system on 2022-04-28.
Available extensions:
crypt add-on version 2.35 by Andreas Jaeger
GNU Libc C99 math library version 2.35 by Ulrich Drepper et al.
bsd-compatible malloc by Doug Lea version 2.8.6
TLS support
NSS modules support
...
This output provides information about the library, including the version, copyright, and available extensions.
Exploring the contents of binary files can be a useful skill for tasks such as reverse engineering, software analysis, and troubleshooting. The strings
command is a simple but powerful tool that can help you quickly extract and analyze the textual contents of binary files.