Skip to main content
rule CX Codex

hex_analysis — Claude Code rule: hex signatures and compiler flags

hex_analysis — a rule file that explains YARA hex signatures for AdaptixC2: which instruction produced each one and which compiler flag moves those bytes.

MIT ★ 336 updated 2026-04-09

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/hex_analysis.md
Open on GitHub

What hex_analysis does

The rule goes through hex patterns from two Elastic rules (Windows_Trojan_Adaptix_2779784c, Windows_Trojan_Adaptix_b2cda978) and from the CAPE AdaptixBeacon set. Each signature gets four notes: the kind of code it is, what the bytes decode to, the source construct behind it, and the flag that shifts it. A prologue that reserves 424 bytes of stack (sub rsp, 0x1A8) is traced to heavy locals or struct initialisation.

Half of the file is a Makefile diff. EVASION_FLAGS gains -fno-inline-functions-small, -fno-inline-functions-called-once, -fno-expensive-optimizations plus three switches that drop vectorisation: -fno-tree-loop-vectorize, -fno-tree-slp-vectorize, -fno-tree-vect-loop-version. -fno-exceptions stays in OPTIMIZATION_FLAGS. A table lines up every flag with the change it causes in the emitted code.

Flags do not cover everything. The $wininet_1–$wininet_2 patterns hunt for the stack string wininet.dll assembled one character at a time, and the beacon already builds it through HdChrA() in ConnectorHTTP.cpp:62-74. Optimisation can still produce matching bytes. For the XOR-like $a5, the analysis states that flags may not be enough and the source needs a rewrite.

What it helps with

  • decode what a YARA byte sequence actually means
  • trace a stack-allocation prologue back to the function behind it
  • choose compiler flags that shift one specific signature
  • rewrite EVASION_FLAGS and OPTIMIZATION_FLAGS in the beacon Makefile
  • tell which patterns need a code change rather than a flag

Example prompts for the agent

  • Walk me through pattern $a2 in Windows_Trojan_Adaptix_2779784c: where the sub rsp, 0x58 prologue comes from and which flag changes it.
  • Add the flags that break the prologue patterns to EVASION_FLAGS and show the Makefile diff.
  • Check $wininet_1 and $wininet_2: does another optimisation level help, or do I have to touch HdChrA()?

How to install hex_analysis

Manually: put the files in place

.claude/rules/hex_analysis.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about hex_analysis

How do I install hex_analysis in Claude Code?

Copy the rule file into your project at .claude/rules/hex_analysis.md. That path is the whole install.

What does hex_analysis do?

It annotates AdaptixC2 YARA signatures with the code that produced them, then lists Makefile flag changes that alter the generated bytes.

Will compiler flags defeat every pattern?

No. The analysis says the XOR-like $a5 pattern may survive flag changes and call for a source rewrite.

Source text

hex_analysis.md · MIT
## Hex Pattern Analysis for AdaptixC2

### Elastic Security Rules (Windows_Trojan_Adaptix)

#### Rule: Windows_Trojan_Adaptix_2779784c

**Pattern $a1:**
```
48 81 EC A8 01 00 00 48 8B 84 24 C0 01 00 00 48 C7 00 00 00 00 00 ...
```
- **Type:** Function prologue with large stack allocation
- **Meaning:** `sub rsp, 0x1A8` (424 bytes) + memory operations
- **Source Cause:** Function with large local variables or struct initialization
- **Evasion Method:** Compiler flags change stack allocation and instruction ordering

**Pattern $a2:**
```
48 83 EC 58 48 8B 4C 24 70 E8 ?? ?? ?? ?? 89 44 24 38 ...
```
- **Type:** Function prologue with moderate stack allocation
- **Meaning:** `sub rsp, 0x58` (88 bytes) + function calls
- **Source Cause:** Medium-sized function with local variables
- **Evasion Method:** Compiler flags change optimization and stack layout

#### Rule: Windows_Trojan_Adaptix_b2cda978

**Pattern $a1:**
```
48 89 03 8B 45 EC 48 98 48 8D 14 C5 00 00 00 00 ...
```
- **Type:** Memory operations with conditional logic
- **Evasion Method:** Compiler flags

**Pattern $a2:**
```
48 89 45 D0 48 8B 4D 10 E8 4C 9F 00 00 ...
```
- **Type:** Stack variable storage with function calls
- **Evasion Method:** Compiler flags

**Pattern $a3:**
```
8B 53 54 48 89 C6 31 C0 48 39 C2 74 0B ...
```
- **Type:** Memory copy/set loop
- **Evasion Method:** Compiler flags

**Pattern $a4:**
```
48 89 45 E0 48 83 7D E0 00 75 17 ...
```
- **Type:** Error handling path
- **Evasion Method:** Compiler flags

**Pattern $a5:**
```
48 83 EC 10 89 4D 10 C7 ?? ?? ?? ?? ?? ?? ...
```
- **Type:** XOR-like operations (possibly encryption)
- **Evasion Method:** Compiler flags may help; source refactoring may be needed

### CAPE Rule (AdaptixBeacon)

#### Config Patterns ($conf_1 to $conf_5)

These patterns detect config initialization code. They are compiler-generated and can be evaded with compiler flag changes.

#### Wininet Patterns ($wininet_1, $wininet_2)

```
B9 77 00 00 00  (mov ecx, 0x77 = 'w')
B9 69 00 00 00  (mov ecx, 0x69 = 'i')
B9 6E 00 00 00  (mov ecx, 0x6E = 'n')
B9 65 00 00 00  (mov ecx, 0x65 = 'e')
```

**Analysis:**
- These patterns detect stack string construction for "wininet.dll"
- The beacon already uses obfuscation via `HdChrA()` function (ConnectorHTTP.cpp:62-74)
- The current code uses character-by-character construction with a macro

**Current Code (already obfuscated):**
```cpp
CHAR wininet_c[12];
wininet_c[0]  = HdChrA('w');
wininet_c[1]  = HdChrA('i');
wininet_c[2]  = HdChrA('n');
// ... etc
```

**Status:** Already partially obfuscated. The YARA patterns may still match due to compiler optimization producing similar byte sequences.

---

## Makefile Changes Applied

### Beacon Makefile (Before):
```makefile
EVASION_FLAGS := -O2 \
                 -fomit-frame-pointer \
                 -fno-ident \
                 -ffunction-sections \
                 -fdata-sections \
                 -fmerge-all-constants

OPTIMIZATION_FLAGS := -fno-exceptions \
                     -fno-unwind-tables \
                     -fno-asynchronous-unwind-tables
```

### Beacon Makefile (After):
```makefile
EVASION_FLAGS := -O2 \
                 -fomit-frame-pointer \
                 -fno-ident \
                 -ffunction-sections \
                 -fdata-sections \
                 -fmerge-all-constants \
                 -fno-inline-functions-small \
                 -fno-inline-functions-called-once \
                 -fno-expensive-optimizations \
                 -fno-tree-loop-vectorize \
                 -fno-tree-slp-vectorize \
                 -fno-tree-vect-loop-version \
                 -fno-unwind-tables \
                 -fno-asynchronous-unwind-tables

OPTIMIZATION_FLAGS := -fno-exceptions
```

### Expected Hex Pattern Changes:

| Flag | Effect |
|------|--------|
| `-fno-inline-functions-small` | Prevents inlining of small functions, changes call patterns |
| `-fno-inline-functions-called-once` | Changes function call structure |
| `-fno-expensive-optimizations` | Uses simpler instruction sequences |
| `-fno-tree-loop-vectorize` | Changes loop code generation |
| `-fno-tree-slp-vectorize` | Changes memory operation patterns |
| `-fno-tree-vect-loop-version` | Alters loop prologue/epilogue |

© JDArmy · MIT · JDArmy/Evasion-SubAgents

Similar IDE rules

All IDE rules for Security →

From the same set22

The whole set →
tool_profile tool_profile — a Claude rule that profiles Stowaway: what the Go multi-hop proxy is built from, how it compiles, and which traces it leaves on a host. CX Codex +1 ★ 336repo stars rule_mapping rule_mapping is a Claude Code rule that analyzes YARA and Sigma signatures for AdaptixC2. It helps assess which signatures are outdated during detection rule reviews. CX Codex +1 ★ 336repo stars tools_evasion The tools_evasion command examines a penetration-testing tool, gathers detection rules, then changes its source code to avoid those rules. It is intended for authorized security work. CX Codex +1 ★ 336repo stars rule_inventory A rule file that gives the agent an inventory of SharpHound detections: three YARA rules, one Sigma rule, pattern tables and a difficulty rating for each. CX Codex +1 ★ 336repo stars lesson_learned The lesson_learned rule explains why string constants must match fixed-width protocol fields. Use it when changing Go code that reads message headers into fixed-size buffers. CX Codex +1 ★ 336repo stars behavior_analysis behavior_analysis — a rule file that tables how SharpHound gives itself away and what the doc suggests changing in the build, the flags and the output files. CX Codex +1 ★ 336repo stars modifications_summary modifications_summary keeps a record of the AdaptixC2 YARA-evasion edits in front of Claude: beacon build flags, renamed Go functions and the commands that verify them. Useful when you pick the repo back up. CX Codex +1 ★ 336repo stars behavior_analysis behavior_analysis — a Claude Code rule that loads a structured behavioral profile of Stowaway into the agent context: CLI flags, protocol constants, build artifacts, and tiered detection indicators. CX Codex +1 ★ 336repo stars

Project sponsors

Companies that keep this analytics open