automatic_exploit_generation is the module of OpenCRS that deals with automatically generating exploits.
- ELF format
- x86 architecture
With the input streams, mitigations, and vulnerabilities for the executable to exploit, the module will iterate through the implemented submodules and recommend the ones that may produce a workable exploit. In the case of Zeratool, which is currently the only module accessible, a new Docker container is built with which gRPC communication occurs. The submodule decides which configuration to use for Zeratool based on the available information (both input and extracted).
-
Make sure you have set up the repositories and Python environment according to the top-level instructions. That is:
-
Docker is installed and is properly running. Check using:
docker version docker ps -a docker run --rm hello-world
These commands should run without errors.
-
The current module repository and all other module repositories (particularly the
zeratool_librepository and thecommonsrepository) are cloned in the same directory. -
You are running all commands inside a Python virtual environment. There should be
(.venv)prefix to your prompt. -
You have installed Poetry in the virtual environment. If you run:
which poetryyou should get a path ending with
.venv/bin/poetry.
-
-
Disable the Python Keyring:
export PYTHON_KEYRING_BACKEND=keyring.backends.null.KeyringThis is a problem that may occur in certain situations, preventing Poetry from getting packages.
-
Install the required packages with Poetry (based on
pyprojects.toml):poetry install --only main -
Build the Docker image:
docker build --tag zeratool_lib -f docker/Dockerfile.zeratool_lib . -
Ensure the Docker API is accessible by:
- Running the module as
root; or - Changing the Docker socket permissions (unsecure approach) via
sudo chmod 777 /var/run/docker.sock.
- Running the module as
-
Build the arguments' adapter via
cd others/argv_adapter && make.
If you make modifications to the Protobuf definition, please regenerate the Python sources with
console poetry run python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./automatic_exploit_generation/exploiters/zeratool/protobuf/exploit.proto
β poetry run automatic_exploit_generation recommend --elf=key-manager.elf --stream=STDIN --mitigation=NX --weakness=STACK_OUT_OF_BOUND_WRITE
Exploiters that can be used considering the context are:
- ZERATOOLβ poetry run automatic_exploit_generation exploit --exploiter=ZERATOOL --elf=key-manager.elf --stream=STDIN --mitigation=NX --weakness=STACK_OUT_OF_BOUND_WRITE
The exploiter could generate an exploit with the outcome of DENIAL_OF_SERVICE and the following payloads:
- For STDIN:
00000000: 61 61 61 61 61 61 61 61 aaaaaaaa
- For ARGUMENTS:
00000000: 61 61 61 61 61 61 61 61 aaaaaaaaβ poetry run automatic_exploit_generation
Usage: automatic_exploit_generation [OPTIONS] COMMAND [ARGS]...
Exploits vulnerabilities in executables.
Options:
--help Show this message and exit.
Commands:
exploit Exploits vulnerabilities.
recommend Get suitable exploiters for a binary.from automatic_exploit_generation.exploiter_generator import (
Exploiters,
create_exploiter_by_name,
get_suitable_exploiters,
)
from commons.input_streams import InputStreams
from commons.weaknesses import Weaknesses
elf = "key-manager.elf"
input_streams = InputStreams.STDIN
weakness_enum = Weaknesses
for exploiter in get_suitable_exploiters(
elf, InputStreams.STDIN, None, Weaknesses.STACK_OUT_OF_BOUND_WRITE
):
generated_exploit = exploiter.exploit()