WABT (ausgesprochen „wabbit”) ist das Referenz-WebAssembly Binary Toolkit — eine Suite von Kommandozeilenwerkzeugen für die Arbeit mit wasm auf niedriger Ebene. Es konvertiert zwischen dem Binärformat .wasm und dem menschenlesbaren Textformat .wat, disassembliert und dumpt Module, validiert sie, produziert eine C-ähnliche Dekompilierung und interpretiert/führt wasm aus. Es ist die Grundwerkzeugkiste für sowohl wasm-Entwicklung als auch Reverse Engineering.
Installation
| Platform | Command |
|---|
| macOS (Homebrew) | brew install wabt |
| Debian/Ubuntu | sudo apt install wabt |
| Arch Linux | sudo pacman -S wabt |
| npm | npm install -g wabt |
| From source | build with CMake from the WebAssembly/wabt repo |
| Verify | wat2wasm --version |
| Tool | Konvertiert / macht |
|---|
wat2wasm | Text .wat → Binär .wasm |
wasm2wat | Binär .wasm → Text .wat (Disassemble) |
wasm-objdump | Dump Sections, Opcodes, Symbole |
wasm-decompile | Erzeuge lesbaren C-ähnlichen Pseudocode |
wasm-validate | Validiere ein Modul |
wasm-interp | Interpretiere/führe ein Modul aus (Stack Machine) |
wasm2c | Konvertiere wasm → C-Quelle |
wasm-strip | Entferne Sections (z.B. Namen) aus einem Modul |
Text ↔ Binary
# Assemble text to binary
wat2wasm module.wat -o module.wasm
# Disassemble binary to text (the RE starting point)
wasm2wat module.wasm -o module.wat
# Keep debug names / custom sections while disassembling
wasm2wat --generate-names module.wasm
| Option | Effekt |
|---|
-o FILE | Ausgabedatei |
--generate-names | Synthesiere Namen für unbenannte Funcs/Locals |
--enable-FEATURE | Schalte ein wasm-Proposal ein (z.B. --enable-threads) |
-v | Ausführlich |
Inspecting a Module (objdump)
# Full section + disassembly dump
wasm-objdump -x module.wasm # headers/sections
wasm-objdump -d module.wasm # disassemble code
wasm-objdump -s module.wasm # section contents (hex)
| Flag | Zeigt |
|---|
-h | Section Headers |
-x | Details aller Sections |
-d | Disassemblierte Funktionskörper |
-s | Rohes Section-Inhalte |
-j SECTION | Auf eine Section limitieren |
Decompiling (Readable Output)
# C-like decompilation — much easier to read than WAT
wasm-decompile module.wasm -o module.dcmp
wasm-decompile rekonstruiert strukturierten Kontrollfluss und typisierte Locals, was es zu einer schnellen Möglichkeit macht, zu verstehen, was ein Modul tut während der Triage.
Validate & Run
| Command | Zweck |
|---|
wasm-validate module.wasm | Bestätige, dass das Modul wohlgeformt ist |
wasm-interp module.wasm --run-all-exports | Führe exportierte Funktionen aus |
wasm2c module.wasm -o module.c | Emittiere C zum Kompilieren/Analysieren |
Reverse-Engineering Workflow
# 1) Disassemble with names
wasm2wat --generate-names target.wasm -o target.wat
# 2) Dump imports/exports to understand capabilities
wasm-objdump -x target.wasm | grep -E "import|export"
# 3) Get readable pseudocode
wasm-decompile target.wasm -o target.dcmp
# 4) Hunt for strings/URLs in data sections
wasm-objdump -s target.wasm | less
Feature Flags (Proposals)
| Flag | Aktiviert |
|---|
--enable-threads | Threads/Atomare Operationen |
--enable-simd | SIMD |
--enable-bulk-memory | Bulk Memory Operations |
--enable-reference-types | Referenztypen |
--enable-all | Alle unterstützten Proposals |
Verwende diese, wenn ein Modul neuere wasm-Features verwendet und die Standard-Tools es ablehnen.
| Tool | Rolle |
|---|
| WABT | Konvertiere/Inspektiere/Validiere/Dekompiliere wasm |
| diswasm | Higher-Level Pseudocode Decompiler |
| wasm-tools | Rust Low-Level Manipulation |
| Binaryen | Compiler/Optimizer Toolchain (wasm-dis, wasm-opt) |
Resources