Binary File Information Gathering Tools

By Vesper Vei
9 minutes read

Table of Contents

  1. Binary File Information Gathering Tools
  2. Overview
  3. Tool List
    1. nm
    2. ldd
    3. strings
    4. readelf

Binary File Information Gathering Tools

Overview

To do a good job, one must first sharpen one’s tools. In the process of binary code analysis, it is necessary to use some tools to collect information about binary code. This article is used to record some command-line tools for inspecting binary file information. It will include: nm , ldd , strings , ps , strace , ltrace , ROPgadget , objdump , readelf, mainly documenting some potentially useful parameters and explanations of their output.

Tool List

nm

nm is used to inspect the symbol table in a binary file, including functions, global variables, undefined symbols, and so on. In exploit development and reverse engineering, it can be used to find function addresses, determine whether symbols have been stripped, analyze linking, and more.

Common Parameters

Common Symbol Type Descriptions

The second column in nm output is the symbol type (section type), and the common meanings are as follows: image.png|579

LetterMeaning
T / tSymbol in the Text section (code section) (T = global, t = local)
D / dSymbol in the Data section
B / bBSS section (uninitialized data) symbol
R / rRead-only data section symbol
UUndefined symbol (requires an external library to resolve)
W / wWeak symbol
AAbsolute symbol (address does not change during linking)
V / vWeak object

In PWN, the most commonly used ones are:
T/t: find function locations
U: determine linking dependencies
B/D: analyze global variables and GOT/data structure locations

ldd

ldd is used to inspect which shared libraries an ELF executable will load at runtime, as well as the actual resolved path and base address (load address) of each library. In exploit development, it is used to determine the libc version, check whether a custom loader is used, and identify whether there is a controllable library hijacking scenario.

Common Parameters

⚠️ Note: In some cases, ldd <file> may actually “execute” the ELF file’s initialization logic, so caution is required when using it on malicious samples.
Recommended usage: `LD_TRACE_LOADED_OBJECTS=1 ./executable

Output Example and Explanation

Terminal window
$ ldd ./pwn
linux-vdso.so.1 (0x00007fffffffe000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7a0d000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffff7dd0000)

Field meanings:

Common Uses in PWN

Common Error Messages

  1. not found libmylib.so => not found This indicates that the system cannot resolve the library, usually due to a path issue.

  2. statically linked not a dynamic executable This indicates that the ELF uses static linking (such as musl builds), so dependencies cannot be inspected with ldd.

strings

strings is used to extract printable strings (ASCII/UTF-8) from binary files, including program string literals, logs, commands, paths, format strings, and so on. In exploit development, it is often used to quickly locate key function names, debug information, sensitive paths, and flag clues.

Common Parameters

Common Output Type Descriptions

The information that strings can extract includes but is not limited to:

String TypeExampleUse
Debug information"Enter password:"Quickly locate logic points
Path"/bin/sh"Clues for RCE / system exploitation
Format string"%p %s %n"Identify format string vulnerabilities
Error / log"invalid length"Cross-reference with the reversing process
Linked library name"GLIBC_2.31"Identify libc version
Compiler information"GCC: (Ubuntu 9.4.0-1)"Determine the competition environment

Example Output Explanation

Terminal window
$ strings ./pwn
/bin/sh
Enter your input:
Correct!
GLIBC_2.31
puts
system

Analysis:

Common Uses in PWN

readelf

readelf is one of the most comprehensive and professional tools for reading ELF format information. It parses ELF structures directly without depending on the system environment. Compared with objdump, readelf is more focused on data presentation, produces more precise output, and is better suited for binary analysis.

It is commonly used to inspect: program headers, section headers, dynamic information, symbol tables, relocation tables, program headers, interpreters (loaders), and more.


Common Parameters


Output Content Explanation (Key Fields)

1. ELF header (-h)
Entry point address: 0x401080
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Type: DYN → PIE 开启
Type: EXEC → PIE 关闭

2. Program Headers (-l)
LOAD 0x000000 0x400000 0x400000 0x2000 ...
INTERP /lib64/ld-linux-x86-64.so.2
DYNAMIC 0x401dd0 ...
GNU_RELRO 0x401000 ...

Key fields:

3. Section Headers (-S)

Mainly used to locate key sections:

.text 可执行代码区域
.data 可写数据
.bss 未初始化变量
.plt Procedure Linkage Table
.got Global Offset Table
.got.plt 延迟绑定 GOT
.init_array 程序启动时调用(构造函数)
.fini_array 程序退出时调用(析构函数)

In PWN:

4. Symbol Table (-s)

Example:

0000000000401030 system@plt
0000000000401040 puts@plt
0000000000404020 __libc_start_main

Uses:

Statically linked files will show a large number of symbols here.

5. Dynamic Segment (-d)

Example:

(NEEDED) Shared library: [libc.so.6]
(RPATH) Library rpath: [/home/pwn/lib]
(INTERP) Program interpreter: ./ld-2.31.so

Uses in PWN:

6. Relocation Table (-r)
000000404018 R_X86_64_JUMP_SLOT puts@GLIBC_2.2.5

Uses in PWN:

Common Uses in PWN (Summary)


Relationship Graph

Loading graph...