decomp.me Documentation
repository·main·Indexed 20 days ago
https://github.com/decompme/decomp.meA collaborative platform for decompilation and reverse engineering featuring a Next.js frontend and a Django backend. The project includes guides for local development via Docker, integrating new compilers, managing PostgreSQL databases, and production deployment using a blue/green strategy.
What's inside decomp.me
- decomp.me is a collaborative platform designed for decompilation and reverse engineering. The project is built using a modern web stack consisting of a Next.js frontend and a Django backend.
Understand the Color and Symbol Guide for code comparisons
mainIn the
Compilationsandbox, decomp.me uses specific colors and symbols to denote differences betweenTargetandCurrentassembly code:- Branches (
~>): Color-coded to form "from" and "to" pairs. - Registers: Registers used in the same context are equivalently color-coded between
TargetandCurrentto help spot usage.
Difference Indicators
Symbol Color Description (none) White Match: Lines are the same (up to constant naming) <Red Deletion: Line is in Targetbut not inCurrent>Green Insertion: Line is in Currentbut not inTarget|Blue Change: Line is a different instruction in TargetandCurrentiBlue Immediate difference: Instruction matches, but numerical constants differ or are relocated rGold Register Swap: At least one register used in this line does not match sYellow Stack Difference: Memory allocation does not match - Branches (
Run decomp.me locally using Docker
mainTo set up a local development or running instance of the decomp.me platform, refer to theDOCKER.mdguide for instructions on containerization and local environment configuration.Use keyboard shortcuts for cursor movement and selection
mainThe decomp.me editor supports standard keyboard shortcuts for navigating code and selecting text:
Cursor Movement
Home: Move to beginning of current lineEnd: Move to end of current linePgUp/PgDn: Move cursor one screen up/downCtrl+Home: Move to beginning of fileCtrl+End: Move to end of fileCtrl+Shift+\: Move cursor to matching bracket
Selection
Shift+←/→: Select backward/forward one characterCtrl+←/→: Select backward/forward one 'word'Ctrl+L: Select current lineCtrl+A: Select all/entire file
Configure VS Code to use the backend virtual environment
mainTo improve the backend development experience (IntelliSense, linting, etc.), configure VS Code to use the Python interpreter managed by
uvwithin thebackend/directory.- Navigate to the
backend/directory in your terminal. - Run
uv run which pythonand copy the resulting absolute path. - In VS Code, open the Command Palette (
Ctrl+Shift+Pon Windows/Linux,Cmd+Shift+Pon macOS). - Search for and select
Python: Select Interpreter. - Select
Enter interpreter path.... - Paste the path you copied in step 2 and press Enter.
cd backend uv run which python- Navigate to the
Enable the Sandbox jail using nsjail
mainThe project supports running subprocesses within a secure jail using
nsjail. This is controlled viaSANDBOXsettings. By default, sandboxing is disabled in the development.envfile, but it is enabled within thebackendDocker container. To enable it for local development outside of Docker, you must installnsjaillocally, configure kernel unprivileged user namespaces, and update your environment configuration.### 1. Install nsjail (Ubuntu example) ```bash apt-get install autoconf bison flex gcc g++ git libprotobuf-dev libnl-route-3-dev libtool make pkg-config protobuf-compiler git clone --recursive --branch=3.0 https://github.com/google/nsjail cd nsjail && make2. Enable unprivileged_userns_clone
Temporary:
sudo sysctl -w kernel.unprivileged_userns_clone=1
Permanent:
echo 'kernel.unprivileged_userns_clone=1' | sudo tee -a /etc/sysctl.d/00-local-userns.conf && sudo service procps restart
3. Configure .env.local
Set USE_SANDBOX_JAIL to 'on'
Set SANDBOX_NSJAIL_BIN_PATH to the absolute path of your nsjail binary
Add a new compiler to decomp.me
mainIf you have developed a compiler and wish to integrate it into the decomp.me platform, follow the instructions provided inCOMPILER.mdto ensure compatibility with the existing architecture.Prerequisites for decomp.me development
mainAdd a new compiler to decomp.me
mainTo add a new compiler to the decomp.me ecosystem, you must register it across the compilers repository, the backend, and the frontend. Ensure the compiler key is consistent across the backend definition, the downloaded compiler configuration, and the frontend display name.
Checklist for adding a compiler:
- Compiler Package: Raise a PR to add the compiler package to the
decompme/compilersrepository. - Backend Installation: Add an entry to
backend/compilers/compilers.linux.yamlso the backend can download and install the compiler. - Backend Definition: Add the compiler definition to
backend/coreapp/compilers.py:- Provide the command used to run the compiler.
- Add the compiler to the
_all_compilerslist.
- Frontend Localization: Add a user-friendly compiler name to
frontend/src/lib/i18n/locales/en/compilers.json. - Flags (Optional): If the compiler requires new flags, add them to
backend/coreapp/flags.py. - Verification: Test the integration to ensure it works as expected.
- Compiler Package: Raise a PR to add the compiler package to the
Update the backend database after model changes
mainIf you modify any Django database models in
models.py, you must generate and apply new migrations to update the database schema.uv run python manage.py makemigrations uv run python manage.py migrateRestore a PostgreSQL database backup locally
mainTo work with real production data for testing migrations or debugging, you can spin up a local copy of the database using Docker.
Prerequisites
- Fresh Data Directory: The restore process requires an empty local Postgres data directory. In this repository, that directory is
./postgres. If it already exists, move it out of the way before starting. - Backup Files: You need two specific files (typically obtained from the decomp.me Discord):
- A main anonymized database dump (e.g.,
decompme_public_*.backup). - An anonymized user CSV (e.g.,
coreapp_user_*.csv) to satisfy foreign keys.
- A main anonymized database dump (e.g.,
- Placement: Place both files in the
./pgdumpdirectory at the base of the repository. This directory is mounted to/pgdumpinside the container.
Restore Steps
- Start the Postgres container:
docker compose up -d postgres - Enter the container and switch to the
postgresuser:docker compose exec -ti postgres bash su - postgres - Restore the main dump using
pg_restore. You can increase--jobsto match your CPU cores to speed up the process:pg_restore -U decompme -d decompme --verbose --jobs=4 /pgdump/decompme_public_*.backup - Restore the
auth_usertable from the CSV file:psql -U decompme -d decompme \ -c "\copy auth_user (id, password, last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined) \ FROM '/pgdump/coreapp_user_*.csv' WITH CSV HEADER" - Reset the
auth_userID sequence to prevent primary key collisions when creating new local users:psql -U decompme -d decompme \ -c "SELECT setval(pg_get_serial_sequence('auth_user', 'id'), COALESCE(MAX(id), 1)) FROM auth_user;" - (Optional) Start the rest of the stack:
docker compose up -d
# Summary of the restore sequence docker compose up -d postgres docker compose exec -ti postgres bash su - postgres pg_restore -U decompme -d decompme --verbose --jobs=4 /pgdump/decompme_public_*.backup psql -U decompme -d decompme -c "\copy auth_user (...) FROM '/pgdump/coreapp_user_*.csv' WITH CSV HEADER" psql -U decompme -d decompme -c "SELECT setval(pg_get_serial_sequence('auth_user', 'id'), COALESCE(MAX(id), 1)) FROM auth_user;"- Fresh Data Directory: The restore process requires an empty local Postgres data directory. In this repository, that directory is
Use keyboard shortcuts for search and replace
mainNavigate and manipulate text using search tools:
Ctrl+G: Go to line...Ctrl+F: Open search and replace panelEsc: Close search and replace panelAlt+Enter: Select matchesCtrl+Alt+Enter: Replace allCtrl+D: Select next occurrenceCtrl+Shift+L: Select all matches with current selection (multi edit)