Skip to content

Commit 981e622

Browse files
committed
risc-y business vm
1 parent ed440d2 commit 981e622

29 files changed

Lines changed: 4548 additions & 107 deletions
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: write-article
3+
description: Write a technical article about a ShiftingCodes pass or related topic
4+
---
5+
6+
Write a technical article about $ARGUMENTS and save it to `articles/` with a descriptive kebab-case filename.
7+
8+
## Workflow
9+
10+
### 1. Read before writing
11+
- Read the actual pass implementation(s) the article covers — never describe what code does from memory
12+
- Read the test files and `tests/conftest.py` helper functions to understand what "before" IR looks like
13+
- If the article covers IR examples, trace the exact instruction sequences the pass emits
14+
15+
### 2. Frontmatter
16+
Every article starts with:
17+
```yaml
18+
---
19+
title: "Title Here"
20+
date: "YYYY-MM-DD"
21+
description: "One sentence describing what the article covers and why it matters"
22+
tags: ["relevant", "tags", "here"]
23+
---
24+
```
25+
26+
### 3. Structure
27+
1. **Hook** — one paragraph on the real-world problem (reverse engineering, protection, etc.)
28+
2. **What is X** — introduce the upstream project(s) with accurate history and maintenance status
29+
3. **The problem** — why the original doesn't work today (version freeze, API churn, etc.)
30+
4. **The solution** — introduce ShiftingCodes and llvm-nanobind; credit authors specifically
31+
5. **Before/after IR** — concrete examples grounded in actual pass output
32+
6. **How to use** — setup, Python driver script, selective obfuscation, UI
33+
7. **Credits** — name individuals, not just projects
34+
35+
### 4. IR example rules
36+
- Add this note at the top of the before/after section:
37+
> *IR samples are lightly simplified for readability — actual output uses random constants and generated names — but the instruction sequences and structure match the Python implementation exactly.*
38+
- **Before IR**: must match what the `conftest.py` helper functions actually build
39+
- **After IR**: must reflect the real algorithm — read the pass source, trace the instruction sequence
40+
- Use `<placeholder>` for random constants (e.g. `<a>`, `<m>`, `<loop_state>`) rather than inventing specific numbers
41+
- Show real variable names from the pass (`bcf.var`, `cff.state`, `sub.ar`, etc.)
42+
- Comments in IR should explain the invariant, not just label blocks
43+
- If a block is dead/unreachable, say so explicitly in a comment
44+
45+
### 5. Tone and accuracy
46+
- No superlatives ("brilliant", "amazing") — describe what things do, not how impressive they are
47+
- State clearly when upstream projects are unmaintained/archived
48+
- Legal disclaimer (end of article):
49+
> *[Project] is provided for legitimate use cases including software protection, security research, CTF challenge authoring, and compiler education. The authors make no representations regarding fitness for any particular purpose and accept no liability for any misuse or damages arising from the use of this software. Use is entirely at your own risk and responsibility.*
50+
- Credit individual contributors by name with GitHub links (e.g. mrexodia for llvm-nanobind)
51+
- Tease future articles for related projects rather than covering them inline
52+
53+
### 6. Scope discipline
54+
- Be precise about what the article covers — if it's about Pluto, don't claim 17 passes when Pluto has 6
55+
- Don't mention Polaris techniques as Pluto techniques
56+
- If an IR example uses a Polaris-era algorithm, describe the algorithm accurately, not the simpler Pluto version
57+
58+
### 7. Verification checklist before finishing
59+
- [ ] All URLs match the canonical list in CLAUDE.md
60+
- [ ] Each "before" IR matches what conftest helpers actually build
61+
- [ ] Each "after" IR matches the actual pass algorithm (read the source)
62+
- [ ] Pass count / feature claims are accurate
63+
- [ ] Maintenance status of upstream projects is stated correctly
64+
- [ ] Article scoped to what it claims to cover
65+
- [ ] Frontmatter complete with today's date
66+
- [ ] Saved to `articles/<descriptive-kebab-name>.md`

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "vendor/riscy-business"]
2+
path = vendor/riscy-business
3+
url = https://github.com/expend20/riscy-business

CLAUDE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,13 @@ Reference XTEA cipher implementation (pure Python) plus an LLVM IR builder that
8989
- ConstantDataArray element access via `get_operand()` crashes — avoid array encryption
9090
- PHI nodes need `inst.add_incoming(value, pred_bb)` when new predecessors are added
9191
- Z3 non-determinism: bound coefficients (`-10 <= X[i] <= 10`) and set `smt.random_seed`
92+
93+
## Canonical URLs
94+
95+
Do not hallucinate these — use exactly as written:
96+
97+
- **ShiftingCodes**: https://github.com/expend20/shifting-codes-python-port
98+
- **Pluto**: https://github.com/bluesadi/Pluto
99+
- **Polaris-Obfuscator** (by za233, NOT bluesadi): https://github.com/za233/Polaris-Obfuscator
100+
- **llvm-nanobind** (NOT github.com/llvm-nanobind/...): https://github.com/LLVMParty/llvm-nanobind
101+
- **RISC-Y Business VM**: https://github.com/thesecretclub/riscy-business

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Upgraded versions of four Pluto passes plus four new passes:
3939
| **String Encryption** | Module | XOR-encrypts string constant globals (`[N x i8]`) with per-function stack-local decryption at runtime |
4040
| **Anti-Disassembly** | Function | Injects crafted x86 inline assembly that desynchronizes linear-sweep disassemblers (IDA, Ghidra, objdump) |
4141

42+
### [riscy-business](https://github.com/expend20/riscy-business) (1 pass)
43+
44+
| Pass | Type | Description |
45+
|------|------|-------------|
46+
| **Virtualization** | Module | Translates functions to RISC-V inspired bytecode and replaces them with an embedded interpreter (Phase 1: integer arithmetic) |
47+
4248
## Prerequisites
4349

4450
- **Python 3.12+**
@@ -143,6 +149,21 @@ pipeline.add(AntiDisassemblyPass(rng=rng, density=0.3)) # density: 0.0-1.0
143149
pipeline.run(mod, ctx)
144150
```
145151

152+
Virtualization pass (riscy-business):
153+
154+
```python
155+
from shifting_codes.passes import PassPipeline
156+
from shifting_codes.passes.virtualization import VirtualizationPass
157+
from shifting_codes.utils.crypto import CryptoRandom
158+
159+
rng = CryptoRandom(seed=42)
160+
161+
pipeline = PassPipeline()
162+
pipeline.add(VirtualizationPass(rng=rng))
163+
164+
pipeline.run(mod, ctx)
165+
```
166+
146167
Passes are registered via `@PassRegistry.register` and can be looked up by name:
147168

148169
```python
@@ -177,9 +198,12 @@ python -m uv run python -m shifting_codes.ui.app
177198

178199
```
179200
src/shifting_codes/
180-
passes/ # Obfuscation passes (base classes, registry, pipeline)
181-
utils/ # Shared utilities (crypto RNG, MBA solver, IR helpers)
182-
xtea/ # XTEA cipher — pure Python reference + LLVM IR builder
183-
ui/ # PyQt6 GUI for visualizing pass transformations
184-
tests/ # pytest test suite
201+
passes/ # Obfuscation passes (base classes, registry, pipeline)
202+
utils/ # Shared utilities (crypto RNG, MBA solver, IR helpers)
203+
riscybusiness_vm/ # RISC-V VM: ISA definition, bytecode compiler, interpreter builder
204+
xtea/ # XTEA cipher — pure Python reference + LLVM IR builder
205+
ui/ # PyQt6 GUI for visualizing pass transformations
206+
vendor/
207+
riscy-business/ # Git submodule — RISC-V VM reference (opcodes, encryption, shuffling)
208+
tests/ # pytest test suite
185209
```

0 commit comments

Comments
 (0)