Nuitka NBC -> Python Source
Rebuild Python source from a Nuitka .nbc file with maximum fidelity to the
original module. Treat the .nbc as forensic evidence, not as a normal Python
bytecode listing. Nuitka may have removed comments, formatting, some local
names, and may have inlined or optimized logic; never promise exact 1:1 output
when the evidence is incomplete.
If the user needs to generate inputs first, prefer:
python nuitka_decompiler.py --source target.exe --output OUT --only app,app.* --nbc-only
Output Contract
Emit one Python code block per module:
# MODULE: <module.dotted.name>
# CONFIDENCE: <percent>% evidence-backed reconstruction
# UNCERTAIN SPANS: <count>
<imports>
<globals>
<classes>
<functions>
No prose outside the code block unless the user explicitly asks for
explanation. If a required .nbc section is missing, ask for the missing data
instead of fabricating code.
Non-Negotiable Rules
- Do not invent logic. Every emitted statement must be supported by
@OPS,
@ASM, @CONSTS, @IMPORTS, @CODE_OBJECTS, or @FORENSICS.
- Preserve every literal exactly as shown in
@CONSTS: strings, URLs,
numbers, dict keys, format strings, escapes, and casing.
- Preserve imported names exactly when they are evidenced. Do not add imports
for convenience.
- Mark uncertain code with
# UNCERTAIN: <specific reason>.
- Prefer a short uncertain body over a plausible but unsupported body.
- Do not add comments, docstrings, logging, exception handling, async, crypto
primitives, decorators, or helper functions unless the
.nbc supports them.
- Do not collapse an evidenced sequence into
.... If @OPS and @ASM
show imports, attribute chains, calls, branches, or returns, reconstruct the
smallest Python statement sequence that matches that evidence and mark only
the missing operand or receiver as uncertain.
NBC/2 Sections
@NBC 2: format marker.
@MOD: module name.
@VER: CPython target version.
@ENTRY: native VA of the module entry function.
@MODULE_TABLE: loader-table metadata; func_ptr confirms the module entry.
@RAW_CHUNK: base64 of the original Nuitka constants chunk. Use it only to
verify or re-parse evidence; do not decode it by hand unless necessary.
@CONSTS <count> mode=full_repr: authoritative mod_consts table.
@IMPORTS: analyzer-suggested import statements.
@FUNCS_DETECTED: inferred function signatures.
@CODE_OBJECTS: code-object metadata where Nuitka preserved it.
@BLOCKS: summary of disassembled native blocks.
@OPS <va> # <qualname>: virtual operations derived from native code.
@ASM <va>: source-relevant annotated native assembly. Low-signal native
moves may be omitted by the emitter; use this to resolve ambiguous @OPS,
arithmetic, comparisons, attribute names, and C-API calls.
@FORENSICS and @NO_OPS <qualname>: evidence for functions without a
reachable @OPS body.
- Bare
@NO_OPS: the whole module lacks disassembly; emit only signatures and
constants-backed globals with uncertainty markers.
Translation Workflow
- Parse
@MOD, @VER, @ENTRY, @MODULE_TABLE, and @CONSTS.
- Build a literal map from every
@CONSTS row: c[N] -> exact repr.
- Build function declarations from
@FUNCS_DETECTED and @CODE_OBJECTS.
- Build a block map from every
@OPS <va> and matching @ASM <va>.
- Map
@OPS blocks to functions using the # qualname annotation first.
If no annotation exists, use nearby string constants that look like
qualnames. If still ambiguous, mark the body uncertain.
- Resolve
C fn@0xVA by looking up the matching @OPS 0xVA block before
deciding whether it is a helper call, nested function, or local method.
- Translate the
@ENTRY block into imports, global assignments, class/function
registration, and top-level calls only when the sequence is clear.
- Translate each function block. Use
@ASM comments to confirm attribute
names, C-API calls, call targets, and constants.
- Treat
C helper_* as a known runtime-helper call with weaker semantics than
C r#N; consult AI_READY_NBC/context/NUITKA_RUNTIME_HELPERS.txt when
available before assigning Python meaning.
- For functions listed in
@FUNCS_DETECTED but missing @OPS, inspect the
matching @FORENSICS block. Emit logic only when adjacent constants or
mentions plainly support it; otherwise emit ... with an uncertainty reason.
- Run the anti-hallucination checklist before final output.
Virtual Ops
L c[N]: load mod_consts[N].
C r#N: call a ranked Nuitka runtime helper.
C helper_*: call a less common runtime helper.
C fn@0xVA: call another native block in this same module; resolve to
@OPS 0xVA when present.
C module_code_<name>: call another module entry. Usually import/init logic.
C capi:<name>: call a Python C-API function.
J_EQ c[N] Lx / J_NE c[N] Lx: conditional branch against a constant.
J_EQ ? Lx: conditional branch with unresolved comparator.
J Lx: unconditional branch.
:Lx: label.
RET: return.
Runtime Helper Hints
Treat ranks as build-local hints, not universal truth. Use
AI_READY_NBC/context/NUITKA_RUNTIME_HELPERS.txt when available.
Common rank meanings:
r#0: attribute lookup (obj.attr)
r#1: no-arg call (f())
r#2: one-arg call (f(a))
r#3: two-arg call (f(a, b))
r#4: three-arg call (f(a, b, c))
r#5: positional/variadic call
r#6 to r#8: globals or string-dict lookup/update
r#9 to r#13: imports or method calls
r#14 and above: function creation, class creation, globals update, or
helper-specific operations depending on the build
C-API Hints
PyImport_ImportModule: import X
PyImport_ImportModuleLevel*: relative/from import logic
PyObject_GetAttrString: obj.name
PyObject_SetAttrString: obj.name = value
PyObject_Call*: obj(...)
PyObject_IsTrue: truthiness check
PyDict_GetItem, PyDict_SetItem, PyDict_DelItem: dict access/update
PyUnicode_GetLength, PyUnicode_Find, PyUnicode_Substring: string ops
PyErr_*: exception path evidence
PyGen_*, PyCoro_*: generator/coroutine evidence
Anti-Hallucination Checklist
Before emitting code, verify:
- Every string literal appears verbatim in
@CONSTS.
- Every numeric literal above 10 appears in
@CONSTS.
- Every import is supported by
@IMPORTS, @OPS, or @ASM.
- Every call target is supported by
@OPS, @ASM, or a known C-API pattern.
- No exception handling appears without
PyErr_* or branch evidence.
- No crypto logic appears without visible crypto imports, attributes, constants,
or C-API evidence.
- No async/generator syntax appears without coroutine/generator evidence.
If a line fails, replace that line with # UNCERTAIN: <failed check>.
Reconstruction Bias
Be evidence-maximal, not stub-maximal. A body with five supported operations
and one unknown receiver should become four or five Python lines plus one
# UNCERTAIN marker, not a full ... body. Preserve uncertainty locally.
Confidence
Compute confidence qualitatively:
- 90-100%: almost every nontrivial line comes from
@OPS/@ASM.
- 70-89%: core control flow is evidenced, with small uncertain spans.
- 40-69%: signatures and literals are strong, bodies partly inferred.
- Below 40%: emit mostly signatures/globals with uncertainty markers.
Use the header value to communicate evidence quality, not optimism.
Source: DimaReverse/nuitka-static-unpacker — distributed by TomeVault.
1---2name: nuitka-nbc-rebuilder3description: Maximum-fidelity Python source reconstruction from Nuitka `.nbc` / `NBC/2` files produced by `nuitka_decompiler.py`. Use when the user pastes or references a `.nbc` file, an `AI_READY_NBC` bundle, sections such as `@MOD`, `@CONSTS`, `@RAW_CHUNK`, `@OPS`, `@ASM`, `@FORENSICS`, `module_code_*`, `mod_consts[N]`, or asks to rebuild Python source from a Nuitka C-compiled module. The goal is evidence-backed reconstruction, not guaranteed perfect 1:1 recovery; uncertain spans must be marked. Use when this capability is needed.4---56# Nuitka NBC -> Python Source78Rebuild Python source from a Nuitka `.nbc` file with maximum fidelity to the9original module. Treat the `.nbc` as forensic evidence, not as a normal Python10bytecode listing. Nuitka may have removed comments, formatting, some local11names, and may have inlined or optimized logic; never promise exact 1:1 output12when the evidence is incomplete.1314If the user needs to generate inputs first, prefer:1516```bash17python nuitka_decompiler.py --source target.exe --output OUT --only app,app.* --nbc-only18```1920## Output Contract2122Emit one Python code block per module:2324```python25# MODULE: <module.dotted.name>26# CONFIDENCE: <percent>% evidence-backed reconstruction27# UNCERTAIN SPANS: <count>2829<imports>30<globals>31<classes>32<functions>33```3435No prose outside the code block unless the user explicitly asks for36explanation. If a required `.nbc` section is missing, ask for the missing data37instead of fabricating code.3839## Non-Negotiable Rules40411. Do not invent logic. Every emitted statement must be supported by `@OPS`,42 `@ASM`, `@CONSTS`, `@IMPORTS`, `@CODE_OBJECTS`, or `@FORENSICS`.432. Preserve every literal exactly as shown in `@CONSTS`: strings, URLs,44 numbers, dict keys, format strings, escapes, and casing.453. Preserve imported names exactly when they are evidenced. Do not add imports46 for convenience.474. Mark uncertain code with `# UNCERTAIN: <specific reason>`.485. Prefer a short uncertain body over a plausible but unsupported body.496. Do not add comments, docstrings, logging, exception handling, async, crypto50 primitives, decorators, or helper functions unless the `.nbc` supports them.517. Do not collapse an evidenced sequence into `...`. If `@OPS` and `@ASM`52 show imports, attribute chains, calls, branches, or returns, reconstruct the53 smallest Python statement sequence that matches that evidence and mark only54 the missing operand or receiver as uncertain.5556## NBC/2 Sections5758- `@NBC 2`: format marker.59- `@MOD`: module name.60- `@VER`: CPython target version.61- `@ENTRY`: native VA of the module entry function.62- `@MODULE_TABLE`: loader-table metadata; `func_ptr` confirms the module entry.63- `@RAW_CHUNK`: base64 of the original Nuitka constants chunk. Use it only to64 verify or re-parse evidence; do not decode it by hand unless necessary.65- `@CONSTS <count> mode=full_repr`: authoritative `mod_consts` table.66- `@IMPORTS`: analyzer-suggested import statements.67- `@FUNCS_DETECTED`: inferred function signatures.68- `@CODE_OBJECTS`: code-object metadata where Nuitka preserved it.69- `@BLOCKS`: summary of disassembled native blocks.70- `@OPS <va> # <qualname>`: virtual operations derived from native code.71- `@ASM <va>`: source-relevant annotated native assembly. Low-signal native72 moves may be omitted by the emitter; use this to resolve ambiguous `@OPS`,73 arithmetic, comparisons, attribute names, and C-API calls.74- `@FORENSICS` and `@NO_OPS <qualname>`: evidence for functions without a75 reachable `@OPS` body.76- Bare `@NO_OPS`: the whole module lacks disassembly; emit only signatures and77 constants-backed globals with uncertainty markers.7879## Translation Workflow80811. Parse `@MOD`, `@VER`, `@ENTRY`, `@MODULE_TABLE`, and `@CONSTS`.822. Build a literal map from every `@CONSTS` row: `c[N] -> exact repr`.833. Build function declarations from `@FUNCS_DETECTED` and `@CODE_OBJECTS`.844. Build a block map from every `@OPS <va>` and matching `@ASM <va>`.855. Map `@OPS` blocks to functions using the `# qualname` annotation first.86 If no annotation exists, use nearby string constants that look like87 qualnames. If still ambiguous, mark the body uncertain.886. Resolve `C fn@0xVA` by looking up the matching `@OPS 0xVA` block before89 deciding whether it is a helper call, nested function, or local method.907. Translate the `@ENTRY` block into imports, global assignments, class/function91 registration, and top-level calls only when the sequence is clear.928. Translate each function block. Use `@ASM` comments to confirm attribute93 names, C-API calls, call targets, and constants.949. Treat `C helper_*` as a known runtime-helper call with weaker semantics than95 `C r#N`; consult `AI_READY_NBC/context/NUITKA_RUNTIME_HELPERS.txt` when96 available before assigning Python meaning.9710. For functions listed in `@FUNCS_DETECTED` but missing `@OPS`, inspect the98 matching `@FORENSICS` block. Emit logic only when adjacent constants or99 mentions plainly support it; otherwise emit `...` with an uncertainty reason.10011. Run the anti-hallucination checklist before final output.101102## Virtual Ops103104- `L c[N]`: load `mod_consts[N]`.105- `C r#N`: call a ranked Nuitka runtime helper.106- `C helper_*`: call a less common runtime helper.107- `C fn@0xVA`: call another native block in this same module; resolve to108 `@OPS 0xVA` when present.109- `C module_code_<name>`: call another module entry. Usually import/init logic.110- `C capi:<name>`: call a Python C-API function.111- `J_EQ c[N] Lx` / `J_NE c[N] Lx`: conditional branch against a constant.112- `J_EQ ? Lx`: conditional branch with unresolved comparator.113- `J Lx`: unconditional branch.114- `:Lx`: label.115- `RET`: return.116117## Runtime Helper Hints118119Treat ranks as build-local hints, not universal truth. Use120`AI_READY_NBC/context/NUITKA_RUNTIME_HELPERS.txt` when available.121122Common rank meanings:123124- `r#0`: attribute lookup (`obj.attr`)125- `r#1`: no-arg call (`f()`)126- `r#2`: one-arg call (`f(a)`)127- `r#3`: two-arg call (`f(a, b)`)128- `r#4`: three-arg call (`f(a, b, c)`)129- `r#5`: positional/variadic call130- `r#6` to `r#8`: globals or string-dict lookup/update131- `r#9` to `r#13`: imports or method calls132- `r#14` and above: function creation, class creation, globals update, or133 helper-specific operations depending on the build134135## C-API Hints136137- `PyImport_ImportModule`: `import X`138- `PyImport_ImportModuleLevel*`: relative/from import logic139- `PyObject_GetAttrString`: `obj.name`140- `PyObject_SetAttrString`: `obj.name = value`141- `PyObject_Call*`: `obj(...)`142- `PyObject_IsTrue`: truthiness check143- `PyDict_GetItem`, `PyDict_SetItem`, `PyDict_DelItem`: dict access/update144- `PyUnicode_GetLength`, `PyUnicode_Find`, `PyUnicode_Substring`: string ops145- `PyErr_*`: exception path evidence146- `PyGen_*`, `PyCoro_*`: generator/coroutine evidence147148## Anti-Hallucination Checklist149150Before emitting code, verify:151152- Every string literal appears verbatim in `@CONSTS`.153- Every numeric literal above 10 appears in `@CONSTS`.154- Every import is supported by `@IMPORTS`, `@OPS`, or `@ASM`.155- Every call target is supported by `@OPS`, `@ASM`, or a known C-API pattern.156- No exception handling appears without `PyErr_*` or branch evidence.157- No crypto logic appears without visible crypto imports, attributes, constants,158 or C-API evidence.159- No async/generator syntax appears without coroutine/generator evidence.160161If a line fails, replace that line with `# UNCERTAIN: <failed check>`.162163## Reconstruction Bias164165Be evidence-maximal, not stub-maximal. A body with five supported operations166and one unknown receiver should become four or five Python lines plus one167`# UNCERTAIN` marker, not a full `...` body. Preserve uncertainty locally.168169## Confidence170171Compute confidence qualitatively:172173- 90-100%: almost every nontrivial line comes from `@OPS`/`@ASM`.174- 70-89%: core control flow is evidenced, with small uncertain spans.175- 40-69%: signatures and literals are strong, bodies partly inferred.176- Below 40%: emit mostly signatures/globals with uncertainty markers.177178Use the header value to communicate evidence quality, not optimism.179180---181> Source: [DimaReverse/nuitka-static-unpacker](https://github.com/DimaReverse/nuitka-static-unpacker) — distributed by [TomeVault](https://tomevault.io).182<!-- tomevault:4.0:skill_md:2026-06-24 -->