Repository navigation
Home
Nightmare Obfuscator is a defensive IP-protection tool for controlled collaboration. It helps a project owner share a working obfuscated copy of a Rust project while keeping the original source private and retaining provenance metadata for the shared artifact.
The project is not a malware-evasion tool, not a DRM system, and not a source recovery system. V1 is intentionally narrow: it focuses on build-preserving Rust obfuscation and artifact integrity.
Nightmare creates a copied project directory and transforms selected Rust source files inside that copy. Build files, tests, assets, docs, and unselected files are preserved so the recipient can run the project without needing a runtime key.
Each obfuscated output includes a metadata vault:
.nightmare/manifest.json
.nightmare/signature
The manifest records:
- tool version and session ID
- creation timestamp
- owner and project metadata
- selected paths and ignored patterns
- checksums before and after obfuscation
- which files were obfuscated
- an obfuscation configuration hash
The signature and checksums are used by nightmare verify to detect tampering.
They are for provenance and integrity, not for unlocking or restoring the
original source.
Supported in v1:
- Rust source files
- full-project copy behavior
- selected-path obfuscation with
--select - default sibling output named
<project>-obfs - ignored directories such as
.git,target, dependency folders, and.nightmare - build-preserving local identifier obfuscation
- build-safe dead-code insertion
- metadata vault creation
- artifact verification
Not supported in v1:
- general support for every language
- deobfuscation
- encrypted original-source recovery
- runtime key enforcement
- build-preserving string encryption
- strong asymmetric signing
Other languages are roadmap work. They should not be advertised as supported until each language has syntax-aware transforms, fixture projects, and original-versus-obfuscated build tests.
Build the CLI:
cargo build --releaseObfuscate an entire Rust project:
nightmare obfuscate ./my-rust-projectThis creates:
./my-rust-project-obfs
Obfuscate only selected paths while copying the rest of the project unchanged:
nightmare obfuscate ./my-rust-project --select src/core --select src/engine.rsWrite to an explicit output directory:
nightmare obfuscate ./my-rust-project --output ./partner-dropVerify a delivered artifact:
nightmare verify ./partner-dropInspect the metadata vault:
nightmare vault ./partner-dropObfuscating only source files is not enough for practical collaboration. A recipient usually needs build configuration, tests, feature flags, assets, schemas, examples, and documentation. Nightmare copies the whole project first, then obfuscates only the supported Rust files that are in scope.
When --select is omitted, all supported Rust source files under the input are
obfuscated. When --select is present, selected Rust files or directories are
obfuscated and unselected files are copied byte-for-byte.
The owner keeps the original repository. The shared output is a working, obfuscated copy.
The .nightmare metadata vault helps answer:
- Was this artifact produced by Nightmare?
- Which files were obfuscated?
- Were files changed after the artifact was created?
- What configuration hash and tool version produced it?
- Which owner/project metadata was embedded?
The vault does not answer:
- How do I recover the original source?
- How do I decrypt hidden source code?
- How do I restrict runtime execution?
Those are outside v1.
The current v1 implementation has been validated with:
cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspaceIt was also smoke-tested against a real open-source Rust crate:
- crate:
hex v0.4.3 - original
cargo test: passed - obfuscated
cargo test: passed -
nightmare verify: passed
The current Rust obfuscator is conservative by design. It avoids renaming public APIs, imports, macros, derives, attributes, field accesses, and strings in ways that would commonly break builds. This means the output is not maximally obfuscated yet, but it is more suitable for a v1 collaboration tool.
String encryption is disabled because the previous approach was not build-preserving. It should return only after it can be proven across fixtures and real projects without hidden runtime dependencies.
The current manifest signature detects tampering, but it is not yet a real asymmetric owner signature. Replacing it with Ed25519 or another appropriate asymmetric scheme is tracked as follow-up work.
Follow-up work is tracked in GitHub Issues:
- real asymmetric metadata signatures
- post-v1 language support
- build-preserving string encryption
- stable config file schema
- automated real-project smoke-test matrix
- branch protection and release workflow
Nightmare Obfuscator is open source under the repository license. main is the
stable/release branch and dev is active integration. Contributions should keep
the product aligned with defensive IP sharing and build-preserving behavior.