Magic Extractor is a universal extraction tool for Windows that identifies a file with several detectors and routes it to the right bundled extractor. It aims to cover mainstream compression formats, the installers you actually see today, and a range of less common archivers.
It auto-detects 80+ formats — archives, installers, disk images, forensic
images (EWF/AFF/AD1), disc images, mail stores and modern codecs. See
formats.md for the full list.
Download the latest release, unzip it, and run:
magic-extractor.exe extract mystery.bin
See Examples for identify, list, carve, --recursive and --bruteforce.
src/cli: the command-line tool.bin: bundled detector and extractor binaries.detectors: DIE, Magika, binwalk (TrID's defs are converted todata/signatures.json).extractors: 7-Zip (plus 7-Zip ZS as a fallback), unrar, unace, unshield, lessmsi, dark (WiX), and more.
data: routing data generated from the handlers (see below).formats: one handler module per format family.
src/gui: optional tkinter front-end that wraps the CLI (see GUI).icons: Fluent icons baked into PNGs for light and dark mode.
test: unit tests, the format and engine batteries, and sample files per format.tools: developer tooling —generate_data.py(builds the routing data from the handlers) andgenerate_icons.py(bakes the GUI icons).update: the updater config and scripts that refresh the bundled binaries.docs: supported formats, how to add a handler, third-party notices.
The compiled build keeps bin/, data/ and config.ini external to the exe so
they can be updated with a file swap; cli_paths.py finds them beside the
executable (frozen) or under src/cli/ (dev).
For normal extraction, detectors run in this order with early-exit — the first one that yields a known handler wins (cheapest first, so the ML model is usually skipped):
- puremagic — pure-python, no subprocess; a cheap MIME check for well-formed archives.
- built-in signatures — magic-byte patterns in
data/signatures.json; names archivers the engines miss (bcm, dgca, kgb, uharc, alzip, freearc, ...) with no external process. - DIE (Detect It Easy) — signature engine; the specialist for installers, PE and SFX.
- binwalk — short type keys (cpio, lzma, ...) and embedded content.
- Magika — Google's AI content-type detector, as a catch-all.
Each detector contributes uniquely (they are complementary, not redundant): the signature DB names archivers the engines miss, DIE handles installers/PE, binwalk catches a few types the others miss, puremagic/Magika cover MIME.
PureMagic 2.x also provides content-aware deep scanning when it receives the full
file. Full-file analysis is the default; the optional --fast-check modifier
passes only the first 64 KiB when startup speed matters more than deep inspection.
Each handler declares its own indicators via detection_mimes() /
detection_names() / detection_signatures(); tools/generate_data.py compiles
these into data/handlers.json and data/signatures.json (with an optional
data/extra_detections.json merged on top). TrID is not used.
Note: any format whose signature is missing from puremagic's
magic_data.json(or that puremagic reports only as a genericapplication/octet-stream) must declare a customdetection_signatures()entry in its handler — otherwise it will not be detected by content.
--bruteforcedisables early-exit: every detector runs and each detected handler is tried in turn (useful when the first guess is wrong).- Executables also get the SFX and installer handlers (RAR, ACE, ARC, KGB, UHARC, Inno Setup, BitRock, Clickteam) as fallback candidates; each one rejects files that are not its own, so the chain moves on to the next.
- The
carvesubcommand additionally uses binwalk's offset map to extract archives embedded at arbitrary offsets (e.g. inside firmware images).
The detection → handler routing map lives in data/handlers.json (generated, loaded
at runtime). A key can map to several handlers, tried in order until one succeeds:
e.g. 7-Zip first, then 7-Zip ZS for what mainline 7-Zip cannot open (SquashFS with
LZ4, NSIS with ZSTD). A generic-token blacklist lives in data/detection_blacklist.json.
See formats.md for the full list of formats and their handlers.
To add support for a new format, see docs/adding-a-handler.md — the end-to-end guide (handler class, detection declaration, DIE/TrID lookup, magic signatures, regenerating the routing data, bundling the tool, and testing).
Most users just download the release (see Quick Start). To run from source: Python 3.12 or newer is required.
git clone <repo-url>
cd magic-extractor
pip install -r src/cli/requirements.txtMagic Extractor uses subcommands:
python src/cli/main.py extract <path> [output_dir] [options] # detect and extract
python src/cli/main.py identify <path> # report type + candidate handlers
python src/cli/main.py list <path> # list archive contents
python src/cli/main.py carve <path> [output_dir] [options] # carve embedded archives (binwalk offsets)A bare path with no subcommand defaults to extract (backward compatible), and
options may come before the path or the subcommand:
python src/cli/main.py <path> <output_dir> [options]
python src/cli/main.py --debug <path>
python src/cli/main.py --version--debug and --fast-check work with every subcommand; --password with
extract, list and carve.
<path> can be a folder for every subcommand: its files (not subfolders) are
processed one by one. Each file gets its own output folder: <stem>_extracted
(next to the file, or under output_dir when given), or <name>_extracted when
two files share a stem.
If the output folder already has files, extract writes to a new
<folder>_<YYYYmmdd-HHMMSS> instead of mixing with or overwriting the earlier
result; --merge-output extracts into the existing folder instead, overwriting
files and folders with the same names (the GUI does this when the destination is
locked). The archive being extracted is never overwritten. Each handler attempt
runs in its own temporary folder, so a failed attempt never leaves partial files
behind.
Exit codes: 0 success; 1 failure — nothing could be extracted, a file of a
folder run failed, a folder had no files, or --delete-source could not delete
the source; 2 invalid arguments; 3 extracted with errors — the tool reported a
failure but most of the content was extracted (e.g. symbolic links in a Linux image
cannot be created on Windows), so it is kept in the output folder and the source is
not deleted. With --recursive, nested archives that cannot
be extracted are reported as warnings and do not change the exit code (many
extracted files, e.g. every DLL of an installer, look like candidates).
extract options:
-
--password <password>: password for encrypted archives. -
-r,--recursive: extract archives found inside the output (bounded by--max-depth, default 5). -
-b,--bruteforce: try every handler detected instead of stopping at the first. -
--merge-output: extract into the output folder even if it already has files, overwriting what has the same name. -
--delete-source: delete the source after a successful extraction (Recycle Bin unlessdelete_to_recycle_binis off inconfig.ini). -
--open-output-folder <true|false>: open the output folder when done. -
--check-free-space <true|false>: warn if the output volume may lack room. -
--check-unicode <true|false>: warn about non-ASCII extracted names. -
--fix-file-extensions <true|false>: give extensionless extracted files a content-based extension (never overwrites an existing one). Off by default: guesses can be wrong (Makefile,LICENSEorconfigurebecome.txt). -
--create-log-files <true|false>: write amagic-extractor.logto the output folder.(Each defaults to its
config.inivalue when omitted; combine with--update-defaultsto persist the given value — e.g.--open-output-folder false --update-defaultsturns a previously-saved default off.) -
--fast-check: check only the first 64 KiB instead of running full-file detection. -
--update-defaults: persist the given settings as defaults inconfig.ini.
carve options: --list (print the binwalk fragment table), --fragment N (carve one
fragment by index), --raw (carve every fragment, not only handler-known ones).
In the examples below,
magic-extractoris the built.exe. From source, replace it withpython src/cli/main.py— the arguments are identical.
Extract an archive — you don't need to know its type; it is auto-detected:
magic-extractor extract mystery.bin
# extracts into mystery_extracted/ next to the file
Identify a file without touching it — shows what each detector saw and which handler would run:
magic-extractor identify setup.exe
File: setup.exe
[DIE] detect inno setup installer
Candidate handlers (in order):
- FormatInnoSetupHandler
List an archive's contents (no extraction):
magic-extractor list backup.7z
Recursive — extract archives found inside the output (e.g. a .tar.gz, or an
installer that contains more archives), up to --max-depth levels:
magic-extractor extract app-1.0.tar.gz --recursive
Bruteforce — when detection is unsure, try every handler that matched instead of stopping at the first:
magic-extractor extract weird-archive.dat --bruteforce
Carve — pull archives that are embedded at some offset inside a bigger file (classic for firmware images). Inspect first, then carve:
magic-extractor carve router-firmware.bin --list
IDX OFFSET SIZE NAME DESCRIPTION
0 0x00000000 793,720 pe Windows PE binary
1 0x000c1c78 2,495,983 lzma LZMA compressed data
magic-extractor carve router-firmware.bin # carve + extract the known blobs
magic-extractor carve router-firmware.bin --fragment 1 # carve only fragment #1
An optional tkinter front-end (in src/gui/) wraps the CLI — a Universal-Extractor-style
window with extract, scan and carve modes, drag-and-drop, a batch queue, run
history and a Preferences dialog. Bruteforce is available under Run options. It
shells out to the same main.py, so detection and extraction behave identically.
python src/gui/main.py # launch the window
python src/gui/main.py <file> [outdir] # prefill the source (and destination)
python src/gui/main.py <file> /scan # prefill and start in identify modeDrag-and-drop needs the optional tkinterdnd2 package (pip install -r src/gui/requirements.txt);
without it the window still works, minus drop support. Files can be dropped anywhere on
the window; when several are dropped, the first fills the source and the others go to
the batch queue. It can also register an Explorer context-menu entry (Edit → Add to
Explorer menu).
- Lock the destination to keep one shared output folder: runs then extract into it
(
--merge-output); unlocked, an existing non-empty folder gets a dated sibling. - Options with side effects (deleting the source, Recursive, fixing extensions, ...) have an info icon beside them in Run options and Preferences: hover, focus or click it for the caveat. It turns into an amber warning while the option is on.
- Keyboard: Enter runs OK; Ctrl+O / Ctrl+D pick the source / destination; Ctrl+R Run options; Ctrl+, Preferences; Ctrl+B Batch; Ctrl+L clear the log; Ctrl+T flip light/dark (and keep it); F1 About; Ctrl+Q exit; Escape closes a dialog. F10 enters the menu bar (arrows, Enter, Escape); dialogs are modal and Enter presses the focused button.
- The log keeps the last 5000 lines and always scrolls to new output; right-click (or Shift+F10) it to copy, save or clear. A status line and progress bar show "Extracting 2 of 5: …" during a run and a summary at the end ("4 extracted, 1 failed"); the bar is left full when the run ends. Settings entries are disabled while a run is going.
- Deleting sources is always confirmed with "Keep sources" as the default (Enter and Escape keep them).
- Closing the window during a run asks first, then cancels it and stops every extractor it started.
- The theme follows the Windows light/dark setting while the window is open; pick System, Light or Dark under Preferences → Theme (Light/Dark keep it fixed).
- The released GUI writes errors to
gui.logbeside the exe (or under%LOCALAPPDATA%\magic-extractorwhen that folder is read-only), since it has no console.
The release workflow (.github/workflows/release.yml) builds both executables from
src/cli with PyInstaller, then copies bin/, data/, config.ini, gui.ini,
VERSION and the docs beside them. The version comes from the GitHub release tag
(e.g. 1.4.0). To build locally, run the two pyinstaller commands of that
workflow from src/cli and copy the same files into src/cli/dist/.
python test/run_battery.py --unit-only # unit tests (any OS)
python test/run_battery.py # + format battery: every sample through the CLI (Windows)
python test/run_engine_battery.py # extractor contract, engine by engine (Windows)
python tools/generate_data.py # after changing a handler's detection_* methods
python tools/generate_icons.py # after changing src/gui/icons/catalog.pygenerate_icons.py needs pip install "tkinter-icons[fluent]>=5.1" "pillow>=10"; the
GUI itself only loads the committed PNGs. Project skills for coding agents live in
.claude/skills/ (CLI design, Tkinter UI quality, Windows tooling, change discipline).
MIT — see LICENSE.txt. Note: the bundled third-party extractor/detector
binaries under src/cli/bin/ keep their own licenses (some proprietary freeware)
and are not covered by MIT; verify their redistribution terms before shipping.
- Lead Developer: DSR! — xchwarze@gmail.com
- Thanks to all contributors.