This project explores how small valid C programs can be. It generates random code snippets within n bytes, tests if they compile, and saves successful programs.
- Creates random C code of a specific size.
- Allows custom character sets.
- Tests compilability using GCC.
- Uses multiple CPU cores for faster testing.
- Saves compiled programs as
.cfiles.
Run with default settings (5-byte code):
python random_c_tester.py
Test a specific byte size (e.g., 10 bytes):
python random_c_tester.py 10
Run unlimited tests:
python random_c_tester.py --tasks -1
Use custom characters:
python random_c_tester.py --charset "abc123+="
- Generates random code using specified characters.
- Inserts the code into a C program template.
- Compiles the program with GCC.
- Saves successful compilations as
.cfiles.
Successful programs are saved as .c files:
[PID]_[UUID].c
Testing all combinations is impractical for large sizes due to exponential growth. Instead, the tool samples randomly.
Console output for successful compilations:
Compilation successful! Saved as 1234_a1b2c3d4.c
Progress: 200 attempts, 2 successes (1.00%)
MIT License