بصير (Baseer) is a modular, extensible binary analysis framework written in C. It allows developers to inspect, disassemble, debug, and decompile binary files using a flexible callback system. Baseer identifies file formats using magic numbers and executes corresponding handlers dynamically.
⚠️ Note: This project is still under development and may change frequently.
The Core handles the essential operations:
Extensions add advanced capabilities:
Baseer is designed around a callback tree. Each file format (e.g., ELF, TAR, etc.) is represented by a branch that defines its own callbacks. Callbacks can perform operations such as reading metadata, disassembling, debugging, or decompiling.
bparser
— the main parser structure that holds file information.bmagic
— defines a magic number, the file type name, and the function callback used for parsing.inputs
— holds runtime arguments and a hashmap for communication between callbacks.bparser_apply()
— dispatches the execution of a callback for a given format.bx_<format>
) — per-format handler (e.g., bx_elf
, bx_tar
) that interprets command-line flags.b_<tool>
) — actions executed by callbacks, such as b_debugger
, b_disasm
, b_elf_metadata
, etc.Each branch in the diagram represents a callback path from the main function → Baseer callback → format handler → specific tools.
udis86: Used for disassembling x86 and x64 architecture binaries.
GitHub Repository
RetDec: Used as the decompiler for translating binaries into a higher-level representation.
GitHub Repository
Baseer uses a standard Makefile for compilation.
git clone https://github.com/thxa/baseer.git
cd baseer
cmake CMakeLists.txt
make
./build/baseer <target-file> -m
cmake CMakeLists.txt && make && ./build/baseer examples/64bit_x86_64 -m | less -r
cmake CMakeLists.txt && make && ./build/baseer examples/32bit_x86 -m | less -r
You can install Baseer from the AUR using an AUR helper like yay
:
yay -S baseer
Make sure you have an AUR helper installed (e.g.,
yay
,paru
) before running the command.
To remove Baseer, use:
pacman -Rs baseer
To install Baseer from source:
cmake CMakeLists.txt && make install
To uninstall:
cmake CMakeLists.txt && make uninstall
Analyze a file using one of the following modes:
baseer <file> -m
baseer <file> -a
baseer <file> -d
baseer -i
When you run Baseer with a target file, it:
bmagic
array for a match.bx_<format>
) to handle the file.b_<tool>
) depending on command-line flags (e.g., -m
for metadata, -a
for disassembly, -d
for debugging).bmagic magics[] = {
{"ELF", ELF_MAGIC, reverse_bytes(ELF_MAGIC), bx_elf, 0},
{"TAR", TAR_MAGIC, reverse_bytes(TAR_MAGIC), bx_tar, 257},
// {"PDF", PDF_MAGIC, reverse_bytes(PDF_MAGIC), NULL, 0},
// {"PNG", PNG_MAGIC, reverse_bytes(PNG_MAGIC), NULL, 0},
// {"ZIP", ZIP_MAGIC, reverse_bytes(ZIP_MAGIC), NULL, 0},
// {"Mach-o", MACHO_MAGIC, reverse_bytes(MACHO_MAGIC), NULL, 0},
};
Below is an example of an already built extension for ELF .
bool bx_elf(bparser* parser, void *arg)
{
int argc = *((inputs*)arg)->argc;
char** args = ((inputs*)arg)->args;
for (int i = 2; i < argc; i++) {
if (strcmp("-m", args[i]) == 0)
bparser_apply(parser, print_meta_data, arg);
else if (strcmp("-a", args[i]) == 0)
bparser_apply(parser, print_elf_disasm, arg);
else if (strcmp("-d", args[i]) == 0)
bparser_apply(parser, b_debugger, arg);
else if (strcmp("-c", args[i]) == 0)
bparser_apply(parser, decompile_elf, arg);
else
fprintf(stderr, "[!] Unsupported flag: %s\n", args[i]);
}
return true;
}
Baseer is built to be easily extended. To add a new format (e.g., PDF, PNG, ZIP):
modules/<format>/bx_<format>.c
.bx_<format>
).b_<tool1>
, b_<tool2>
).bmagic
array.See CONTRIBUTING.md for a detailed guide.
Use this checklist to see which file types Baseer can currently handle:
7F 45 4C 46
(Executable and Linkable Format)75 73 74 61 72
(TAR archive)25 50 44 46
(Portable Document Format)89 50 4E 47 0D 0A 1A 0A
(Portable Network Graphics)FF D8 FF
(JPEG image)47 49 46 38
(Graphics Interchange Format)50 4B 03 04
(ZIP archive)52 61 72 21 1A 07 00
(RAR archive)37 7A BC AF 27 1C
(7-Zip archive)4D 5A
(Windows executable)CF FA ED FE
(Mac OS X executable)49 49 2A 00
/ 4D 4D 00 2A
(Tagged Image File Format)49 44 33
(MP3 audio)52 49 46 46
(Waveform Audio File)42 4D
(Bitmap image)43 44 30 30 31
(ISO 9660 CD-ROM image)1F 8B
(GZIP compressed)66 4C 61 43
(Free Lossless Audio Codec)4D 54 68 64
(MIDI sound file)D0 CF 11 E0 A1 B1 1A E1
(Word, Excel, PowerPoint)50 4B 03 04
(ZIP-based APK archive)4B 44 4D
(Virtual Machine Disk)00 61 73 6D
(WASM binary)53 51 4C 69 74 65 20 66 69 6C 65
(SQLite database)FD 37 7A 58 5A 00
(XZ compressed)4D 53 43 46
(Microsoft Cabinet file)04 22 4D 18
(LZ4 Frame Format)This checklist is based on the Wikipedia list of file signatures. You can extend Baseer to support more types in the future.