ineedcodes 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/package.json +2 -1
  2. package/skills/401-403-bypass-techniques/SKILL.md +348 -0
  3. package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
  4. package/skills/active-directory-acl-abuse/SKILL.md +295 -0
  5. package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
  6. package/skills/active-directory-certificate-services/SKILL.md +303 -0
  7. package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
  8. package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
  9. package/skills/ai-ml-security/SKILL.md +425 -0
  10. package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
  11. package/skills/android-pentesting-tricks/SKILL.md +369 -0
  12. package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
  13. package/skills/anti-debugging-techniques/SKILL.md +407 -0
  14. package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
  15. package/skills/api-authorization-and-bola/SKILL.md +48 -0
  16. package/skills/api-recon-and-docs/SKILL.md +61 -0
  17. package/skills/api-sec/SKILL.md +49 -0
  18. package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
  19. package/skills/auth-sec/SKILL.md +41 -0
  20. package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
  21. package/skills/bba-ad-attacker/SKILL.md +420 -0
  22. package/skills/bba-api-security/SKILL.md +95 -0
  23. package/skills/bba-attack-planner/SKILL.md +186 -0
  24. package/skills/bba-binary-exploit/SKILL.md +65 -0
  25. package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
  26. package/skills/bba-bug-bounty/SKILL.md +245 -0
  27. package/skills/bba-cicd-redteam/SKILL.md +515 -0
  28. package/skills/bba-cloud-security/SKILL.md +97 -0
  29. package/skills/bba-container-escape/SKILL.md +161 -0
  30. package/skills/bba-credential-tester/SKILL.md +346 -0
  31. package/skills/bba-crypto-analyst/SKILL.md +54 -0
  32. package/skills/bba-ctf-solver/SKILL.md +166 -0
  33. package/skills/bba-detection-engineer/SKILL.md +93 -0
  34. package/skills/bba-engagement-planner/SKILL.md +68 -0
  35. package/skills/bba-exploit-chainer/SKILL.md +280 -0
  36. package/skills/bba-exploit-guide/SKILL.md +96 -0
  37. package/skills/bba-forensics-analyst/SKILL.md +512 -0
  38. package/skills/bba-graphql-hunter/SKILL.md +145 -0
  39. package/skills/bba-hardware-hacker/SKILL.md +57 -0
  40. package/skills/bba-jwt-cracker/SKILL.md +133 -0
  41. package/skills/bba-llm-redteam/SKILL.md +149 -0
  42. package/skills/bba-malware-analyst/SKILL.md +305 -0
  43. package/skills/bba-mobile-pentester/SKILL.md +350 -0
  44. package/skills/bba-osint-collector/SKILL.md +645 -0
  45. package/skills/bba-payload-crafter/SKILL.md +347 -0
  46. package/skills/bba-phishing-operator/SKILL.md +516 -0
  47. package/skills/bba-poc-validator/SKILL.md +249 -0
  48. package/skills/bba-privesc-advisor/SKILL.md +98 -0
  49. package/skills/bba-purple-team/SKILL.md +56 -0
  50. package/skills/bba-recon-advisor/SKILL.md +215 -0
  51. package/skills/bba-red-team-operator/SKILL.md +61 -0
  52. package/skills/bba-report-generator/SKILL.md +145 -0
  53. package/skills/bba-reverse-engineer/SKILL.md +298 -0
  54. package/skills/bba-social-engineer/SKILL.md +341 -0
  55. package/skills/bba-ssrf-hunter/SKILL.md +120 -0
  56. package/skills/bba-stig-analyst/SKILL.md +108 -0
  57. package/skills/bba-subdomain-takeover/SKILL.md +141 -0
  58. package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
  59. package/skills/bba-threat-modeler/SKILL.md +574 -0
  60. package/skills/bba-vuln-scanner/SKILL.md +305 -0
  61. package/skills/bba-web-hunter/SKILL.md +285 -0
  62. package/skills/bba-wireless-pentester/SKILL.md +539 -0
  63. package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
  64. package/skills/binary-protection-bypass/SKILL.md +295 -0
  65. package/skills/browser-exploitation-v8/SKILL.md +334 -0
  66. package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
  67. package/skills/business-logic-vuln/SKILL.md +33 -0
  68. package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
  69. package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
  70. package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
  71. package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
  72. package/skills/classical-cipher-analysis/SKILL.md +663 -0
  73. package/skills/clickjacking/SKILL.md +163 -0
  74. package/skills/cmdi-command-injection/SKILL.md +687 -0
  75. package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
  76. package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
  77. package/skills/container-escape-techniques/SKILL.md +339 -0
  78. package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
  79. package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
  80. package/skills/crlf-injection/SKILL.md +179 -0
  81. package/skills/csp-bypass-advanced/SKILL.md +259 -0
  82. package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
  83. package/skills/csv-formula-injection/SKILL.md +144 -0
  84. package/skills/dangling-markup-injection/SKILL.md +321 -0
  85. package/skills/defi-attack-patterns/SKILL.md +355 -0
  86. package/skills/dependency-confusion/SKILL.md +178 -0
  87. package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
  88. package/skills/deserialization-insecure/SKILL.md +725 -0
  89. package/skills/dns-rebinding-attacks/SKILL.md +337 -0
  90. package/skills/email-header-injection/SKILL.md +349 -0
  91. package/skills/expression-language-injection/SKILL.md +243 -0
  92. package/skills/file-access-vuln/SKILL.md +33 -0
  93. package/skills/format-string-exploitation/SKILL.md +312 -0
  94. package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
  95. package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
  96. package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
  97. package/skills/hack/SKILL.md +162 -0
  98. package/skills/hash-attack-techniques/SKILL.md +491 -0
  99. package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
  100. package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
  101. package/skills/heap-exploitation/SKILL.md +217 -0
  102. package/skills/http-host-header-attacks/SKILL.md +323 -0
  103. package/skills/http-parameter-pollution/SKILL.md +208 -0
  104. package/skills/http2-specific-attacks/SKILL.md +350 -0
  105. package/skills/idor-broken-object-authorization/SKILL.md +336 -0
  106. package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
  107. package/skills/injection-checking/SKILL.md +50 -0
  108. package/skills/insecure-source-code-management/SKILL.md +161 -0
  109. package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
  110. package/skills/ios-pentesting-tricks/SKILL.md +418 -0
  111. package/skills/jndi-injection/SKILL.md +265 -0
  112. package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
  113. package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
  114. package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
  115. package/skills/kernel-exploitation/SKILL.md +307 -0
  116. package/skills/kubernetes-pentesting/SKILL.md +348 -0
  117. package/skills/lattice-crypto-attacks/SKILL.md +497 -0
  118. package/skills/linux-lateral-movement/SKILL.md +348 -0
  119. package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
  120. package/skills/linux-privilege-escalation/SKILL.md +346 -0
  121. package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
  122. package/skills/linux-security-bypass/SKILL.md +345 -0
  123. package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
  124. package/skills/llm-prompt-injection/SKILL.md +357 -0
  125. package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
  126. package/skills/macos-process-injection/SKILL.md +384 -0
  127. package/skills/macos-security-bypass/SKILL.md +337 -0
  128. package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
  129. package/skills/memory-forensics-volatility/SKILL.md +323 -0
  130. package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
  131. package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
  132. package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
  133. package/skills/network-protocol-attacks/SKILL.md +330 -0
  134. package/skills/nosql-injection/SKILL.md +341 -0
  135. package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
  136. package/skills/ntlm-relay-coercion/SKILL.md +267 -0
  137. package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
  138. package/skills/open-redirect/SKILL.md +380 -0
  139. package/skills/path-traversal-lfi/SKILL.md +802 -0
  140. package/skills/prototype-pollution/SKILL.md +190 -0
  141. package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
  142. package/skills/prototype-pollution-advanced/SKILL.md +338 -0
  143. package/skills/race-condition/SKILL.md +526 -0
  144. package/skills/recon-and-methodology/SKILL.md +389 -0
  145. package/skills/recon-for-sec/SKILL.md +29 -0
  146. package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
  147. package/skills/request-smuggling/SKILL.md +314 -0
  148. package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
  149. package/skills/reverse-shell-techniques/SKILL.md +290 -0
  150. package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
  151. package/skills/rsa-attack-techniques/SKILL.md +437 -0
  152. package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
  153. package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
  154. package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
  155. package/skills/sandbox-escape-techniques/SKILL.md +250 -0
  156. package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
  157. package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
  158. package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
  159. package/skills/sqli-sql-injection/SKILL.md +489 -0
  160. package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
  161. package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
  162. package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
  163. package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
  164. package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
  165. package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
  166. package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
  167. package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
  168. package/skills/stack-overflow-and-rop/SKILL.md +304 -0
  169. package/skills/steganography-techniques/SKILL.md +348 -0
  170. package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
  171. package/skills/subdomain-takeover/SKILL.md +247 -0
  172. package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
  173. package/skills/symbolic-execution-tools/SKILL.md +419 -0
  174. package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
  175. package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
  176. package/skills/traffic-analysis-pcap/SKILL.md +341 -0
  177. package/skills/tunneling-and-pivoting/SKILL.md +343 -0
  178. package/skills/type-juggling/SKILL.md +291 -0
  179. package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
  180. package/skills/unauthorized-access-common-services/SKILL.md +388 -0
  181. package/skills/upload-insecure-files/SCENARIOS.md +158 -0
  182. package/skills/upload-insecure-files/SKILL.md +543 -0
  183. package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
  184. package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
  185. package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
  186. package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
  187. package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
  188. package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
  189. package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
  190. package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
  191. package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
  192. package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
  193. package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
  194. package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
  195. package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
  196. package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
  197. package/skills/waf-bypass-techniques/SKILL.md +290 -0
  198. package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
  199. package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
  200. package/skills/web-cache-deception/SKILL.md +222 -0
  201. package/skills/websocket-security/SKILL.md +454 -0
  202. package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
  203. package/skills/windows-av-evasion/SKILL.md +342 -0
  204. package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
  205. package/skills/windows-lateral-movement/SKILL.md +335 -0
  206. package/skills/windows-privilege-escalation/SKILL.md +328 -0
  207. package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
  208. package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
  209. package/skills/xslt-injection/SKILL.md +281 -0
  210. package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
  211. package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
  212. package/skills/xss-cross-site-scripting/SKILL.md +379 -0
  213. package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
  214. package/skills/xxe-xml-external-entity/SKILL.md +554 -0
  215. package/src/agent.js +1 -1
  216. package/src/session.js +6 -3
  217. package/src/skills.js +30 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,450 @@
1
+ ---
2
+ name: vm-and-bytecode-reverse
3
+ description: >-
4
+ Custom VM and bytecode reverse engineering playbook. Use when CTF challenges
5
+ or protected software implement custom virtual machines with proprietary
6
+ bytecode, dispatcher loops, or maze-style challenges.gated: true
7
+ ---
8
+
9
+ # SKILL: VM & Bytecode Reverse Engineering — Expert Analysis Playbook
10
+
11
+ > **AI LOAD INSTRUCTION**: Expert techniques for reversing custom virtual machines and bytecode interpreters. Covers dispatcher identification, opcode mapping, custom ISA reconstruction, disassembler/decompiler writing, maze challenges, and real-world VM protector analysis. Base models often fail to recognize the fetch-decode-execute pattern or attempt to analyze VM bytecode as native code.
12
+
13
+ ## 0. RELATED ROUTING
14
+
15
+ - [code-obfuscation-deobfuscation](../code-obfuscation-deobfuscation/SKILL.md) when the VM is a commercial protector (VMProtect/Themida)
16
+ - [symbolic-execution-tools](../symbolic-execution-tools/SKILL.md) when using angr to solve VM-based challenges
17
+ - [anti-debugging-techniques](../anti-debugging-techniques/SKILL.md) when the VM includes anti-debug checks
18
+
19
+ ### Quick identification
20
+
21
+ | Binary Pattern | Likely VM Type | Start With |
22
+ |---|---|---|
23
+ | `while(1) { switch(bytecode[pc]) }` | Switch-based dispatcher | Map each case to an operation |
24
+ | Indirect jump via table `jmp [table + opcode*8]` | Table-based dispatcher | Dump jump table, analyze handlers |
25
+ | Nested if-else chain on byte value | If-chain dispatcher | Same as switch, just different syntax |
26
+ | Stack push/pop dominant operations | Stack-based VM | Identify push, pop, arithmetic ops |
27
+ | `reg[X] = ...` array operations | Register-based VM | Map register indices to operations |
28
+ | 2D grid + direction input | Maze challenge | Extract grid, apply BFS/DFS |
29
+
30
+ ---
31
+
32
+ ## 1. CUSTOM VM IDENTIFICATION
33
+
34
+ ### 1.1 Structural Indicators
35
+
36
+ ```
37
+ VM Architecture Components:
38
+ ┌─────────────────────────────────┐
39
+ │ Bytecode Program (data section)│
40
+ ├─────────────────────────────────┤
41
+ │ Program Counter (pc/ip) │
42
+ │ Register File / Stack │
43
+ │ Memory / Data Area │
44
+ ├─────────────────────────────────┤
45
+ │ Dispatcher Loop │
46
+ │ ├─ Fetch: opcode = code[pc] │
47
+ │ ├─ Decode: lookup handler │
48
+ │ └─ Execute: run handler │
49
+ └─────────────────────────────────┘
50
+ ```
51
+
52
+ ### 1.2 IDA/Ghidra Signatures
53
+
54
+ **Switch dispatcher** (most common in CTF):
55
+ ```c
56
+ while (running) {
57
+ unsigned char op = bytecode[pc++];
58
+ switch (op) {
59
+ case 0x00: /* nop */ break;
60
+ case 0x01: /* push imm */ stack[sp++] = bytecode[pc++]; break;
61
+ case 0x02: /* add */ stack[sp-2] += stack[sp-1]; sp--; break;
62
+ // ...
63
+ case 0xFF: /* halt */ running = 0; break;
64
+ }
65
+ }
66
+ ```
67
+
68
+ **Table dispatcher** (more optimized):
69
+ ```c
70
+ typedef void (*handler_t)(vm_ctx_t*);
71
+ handler_t handlers[256] = { handle_nop, handle_push, handle_add, ... };
72
+
73
+ while (running) {
74
+ handlers[bytecode[pc++]](&ctx);
75
+ }
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 2. ANALYSIS METHODOLOGY
81
+
82
+ ### Step 1: Find the Dispatcher
83
+
84
+ Look for:
85
+ - Large switch statement (many cases) in a loop
86
+ - Array of function pointers indexed by a byte from a data buffer
87
+ - Single function with high cyclomatic complexity
88
+ - Cross-references to a data buffer read byte-by-byte
89
+
90
+ ### Step 2: Map Opcodes to Operations
91
+
92
+ For each case/handler, determine:
93
+
94
+ | Property | How to Identify |
95
+ |---|---|
96
+ | Opcode value | Case number or table index |
97
+ | Operation type | Register/stack modifications |
98
+ | Operand count | How many bytes consumed after opcode |
99
+ | Operand type | Immediate value, register index, or memory address |
100
+ | Side effects | Output, memory write, flag modification |
101
+
102
+ ### Step 3: Extract Bytecode Program
103
+
104
+ ```python
105
+ # Typical extraction from binary
106
+ import struct
107
+
108
+ with open('challenge', 'rb') as f:
109
+ f.seek(bytecode_offset)
110
+ bytecode = f.read(bytecode_length)
111
+
112
+ # Or from IDA:
113
+ # bytecode = idc.get_bytes(bytecode_addr, bytecode_len)
114
+ ```
115
+
116
+ ### Step 4: Write Custom Disassembler
117
+
118
+ ```python
119
+ OPCODES = {
120
+ 0x00: ("nop", 0), # (mnemonic, operand_bytes)
121
+ 0x01: ("push", 1), # push immediate byte
122
+ 0x02: ("pop", 0),
123
+ 0x03: ("add", 0),
124
+ 0x04: ("sub", 0),
125
+ 0x05: ("xor", 0),
126
+ 0x06: ("cmp", 0),
127
+ 0x07: ("jmp", 2), # jump to 16-bit address
128
+ 0x08: ("je", 2),
129
+ 0x09: ("jne", 2),
130
+ 0x0A: ("mov", 2), # mov reg, imm
131
+ 0x0B: ("load", 1), # load from memory[operand]
132
+ 0x0C: ("store",1), # store to memory[operand]
133
+ 0x0D: ("print",0),
134
+ 0x0E: ("read", 0), # read input
135
+ 0xFF: ("halt", 0),
136
+ }
137
+
138
+ def disassemble(bytecode):
139
+ pc = 0
140
+ while pc < len(bytecode):
141
+ op = bytecode[pc]
142
+ if op not in OPCODES:
143
+ print(f" {pc:04x}: UNKNOWN {op:#04x}")
144
+ pc += 1
145
+ continue
146
+
147
+ mnemonic, operand_size = OPCODES[op]
148
+ operands = bytecode[pc+1:pc+1+operand_size]
149
+ operand_str = ' '.join(f'{b:#04x}' for b in operands)
150
+ print(f" {pc:04x}: {mnemonic:8s} {operand_str}")
151
+ pc += 1 + operand_size
152
+
153
+ disassemble(bytecode)
154
+ ```
155
+
156
+ ### Step 5: Analyze Disassembled Program
157
+
158
+ With the custom disassembly, apply standard reverse engineering:
159
+ - Identify input reading (read opcode)
160
+ - Trace data flow from input to comparison
161
+ - Determine success/failure conditions
162
+ - Extract the check logic (often XOR/ADD transformations of input compared against constants)
163
+
164
+ ---
165
+
166
+ ## 3. COMMON VM PATTERNS IN CTF
167
+
168
+ ### 3.1 Stack-Based VM
169
+
170
+ Operations work on a stack (like JVM or Python bytecode).
171
+
172
+ | Opcode | Operation | Stack Effect |
173
+ |---|---|---|
174
+ | PUSH imm | Push immediate value | [...] → [..., imm] |
175
+ | POP | Discard top | [..., a] → [...] |
176
+ | ADD | Add top two | [..., a, b] → [..., a+b] |
177
+ | SUB | Subtract | [..., a, b] → [..., a-b] |
178
+ | MUL | Multiply | [..., a, b] → [..., a*b] |
179
+ | XOR | Bitwise XOR | [..., a, b] → [..., a^b] |
180
+ | CMP | Compare | [..., a, b] → [..., (a==b)] |
181
+ | JMP addr | Unconditional jump | no change |
182
+ | JZ addr | Jump if top is zero | [..., a] → [...] |
183
+ | PRINT | Output top as char | [..., a] → [...] |
184
+ | READ | Read char to stack | [...] → [..., input] |
185
+ | HALT | Stop execution | - |
186
+
187
+ ### 3.2 Register-Based VM
188
+
189
+ Operations use register indices (like x86, ARM).
190
+
191
+ | Opcode | Format | Operation |
192
+ |---|---|---|
193
+ | MOV r, imm | `0x01 RR II II` | reg[R] = imm16 |
194
+ | MOV r1, r2 | `0x02 R1 R2` | reg[R1] = reg[R2] |
195
+ | ADD r1, r2 | `0x03 R1 R2` | reg[R1] += reg[R2] |
196
+ | SUB r1, r2 | `0x04 R1 R2` | reg[R1] -= reg[R2] |
197
+ | XOR r1, r2 | `0x05 R1 R2` | reg[R1] ^= reg[R2] |
198
+ | CMP r1, r2 | `0x06 R1 R2` | flags = compare(r1, r2) |
199
+ | JMP addr | `0x07 AA AA` | pc = addr |
200
+ | JE addr | `0x08 AA AA` | if equal: pc = addr |
201
+ | LOAD r, [addr] | `0x09 RR AA` | reg[R] = mem[addr] |
202
+ | STORE [addr], r | `0x0A AA RR` | mem[addr] = reg[R] |
203
+ | SYSCALL | `0x0B` | I/O operation based on reg[0] |
204
+ | HALT | `0xFF` | stop |
205
+
206
+ ### 3.3 Brainfuck-like / Esoteric VMs
207
+
208
+ | BF Command | VM Equivalent | Description |
209
+ |---|---|---|
210
+ | `>` | INC ptr | Move data pointer right |
211
+ | `<` | DEC ptr | Move data pointer left |
212
+ | `+` | INC [ptr] | Increment byte at pointer |
213
+ | `-` | DEC [ptr] | Decrement byte at pointer |
214
+ | `.` | OUTPUT [ptr] | Output byte at pointer |
215
+ | `,` | INPUT [ptr] | Input byte to pointer |
216
+ | `[` | JZ forward | Jump past `]` if byte is zero |
217
+ | `]` | JNZ back | Jump back to `[` if byte is nonzero |
218
+
219
+ ---
220
+
221
+ ## 4. MAZE CHALLENGES
222
+
223
+ ### 4.1 Identification
224
+
225
+ - Binary reads directional input (WASD, arrow keys, UDLR)
226
+ - 2D array in data section (walls, paths, start, end)
227
+ - Position tracking with x,y coordinates
228
+ - Win condition at specific coordinates
229
+
230
+ ### 4.2 Map Extraction
231
+
232
+ ```python
233
+ # Extract maze grid from binary data section
234
+ MAZE_ADDR = 0x601060
235
+ WIDTH = 20
236
+ HEIGHT = 15
237
+
238
+ # From binary dump:
239
+ maze = []
240
+ for row in range(HEIGHT):
241
+ line = ""
242
+ for col in range(WIDTH):
243
+ cell = bytecode[MAZE_ADDR + row * WIDTH + col - base_addr]
244
+ if cell == 0: line += "." # path
245
+ elif cell == 1: line += "#" # wall
246
+ elif cell == 2: line += "S" # start
247
+ elif cell == 3: line += "E" # end
248
+ else: line += "?"
249
+ maze.append(line)
250
+ print(line)
251
+ ```
252
+
253
+ ### 4.3 Automated Solving
254
+
255
+ ```python
256
+ from collections import deque
257
+
258
+ def solve_maze(maze, start, end):
259
+ """BFS solver returns direction string."""
260
+ rows, cols = len(maze), len(maze[0])
261
+ directions = {'U': (-1, 0), 'D': (1, 0), 'L': (0, -1), 'R': (0, 1)}
262
+ queue = deque([(start, "")])
263
+ visited = {start}
264
+
265
+ while queue:
266
+ (r, c), path = queue.popleft()
267
+ if (r, c) == end:
268
+ return path
269
+
270
+ for name, (dr, dc) in directions.items():
271
+ nr, nc = r + dr, c + dc
272
+ if (0 <= nr < rows and 0 <= nc < cols and
273
+ maze[nr][nc] != '#' and (nr, nc) not in visited):
274
+ visited.add((nr, nc))
275
+ queue.append(((nr, nc), path + name))
276
+
277
+ return None
278
+
279
+ # Find start and end positions
280
+ for r, row in enumerate(maze):
281
+ for c, cell in enumerate(row):
282
+ if cell == 'S': start = (r, c)
283
+ if cell == 'E': end = (r, c)
284
+
285
+ solution = solve_maze(maze, start, end)
286
+ print(f"Path: {solution}")
287
+ ```
288
+
289
+ ### 4.4 Direction Encoding
290
+
291
+ Different challenges encode directions differently:
292
+
293
+ | Encoding | Up | Down | Left | Right |
294
+ |---|---|---|---|---|
295
+ | WASD | W | S | A | D |
296
+ | UDLR | U | D | L | R |
297
+ | Arrow keys | ↑ (0x48) | ↓ (0x50) | ← (0x4B) | → (0x4D) |
298
+ | Numbers | 1 | 2 | 3 | 4 |
299
+ | Hex opcodes | 0x01 | 0x02 | 0x03 | 0x04 |
300
+
301
+ ---
302
+
303
+ ## 5. REAL-WORLD VM PROTECTORS
304
+
305
+ ### 5.1 VMProtect Analysis Approach
306
+
307
+ ```
308
+ 1. Find VM entry: search for pushad/pushfd sequence
309
+ 2. Identify VM context structure (registers, flags, bytecode pointer)
310
+ 3. Locate handler table (often obfuscated with opaque predicates)
311
+ 4. For each handler:
312
+ a. Remove junk code / opaque predicates
313
+ b. Identify the core operation
314
+ c. Document handler semantics
315
+ 5. Trace bytecode execution (instruction-level trace)
316
+ 6. Reconstruct original code from trace
317
+ ```
318
+
319
+ ### 5.2 Tigress Obfuscator
320
+
321
+ Academic VM obfuscator with configurable protection layers.
322
+
323
+ | Feature | Approach |
324
+ |---|---|
325
+ | Single-dispatch VM | Standard handler extraction |
326
+ | Split handlers | Handlers spread across multiple functions |
327
+ | Nested VMs | Outer VM handler invokes inner VM |
328
+ | Encrypted bytecode | Dynamic decryption before each fetch |
329
+ | Polymorphic handlers | Different code for same operation on each build |
330
+
331
+ ### 5.3 Common VM Protector Patterns
332
+
333
+ | Protector | Dispatcher Style | Difficulty |
334
+ |---|---|---|
335
+ | VMProtect | Table + opaque predicates | High |
336
+ | Themida (Code Virtualizer) | CISC-like, large handler set | High |
337
+ | Tigress | Configurable, academic | Medium-High |
338
+ | Custom CTF VM | Simple switch | Low-Medium |
339
+ | Movfuscator | All-mov computation | Medium |
340
+
341
+ ---
342
+
343
+ ## 6. TOOLS
344
+
345
+ | Tool | Purpose | Usage |
346
+ |---|---|---|
347
+ | IDA Pro | Identify dispatcher, reverse handlers | F5 decompile, xref analysis |
348
+ | Ghidra | Free alternative with Sleigh processor modules | Write custom processor for VM ISA |
349
+ | angr | Symbolic execution through VM | Treat entire VM as constraint system |
350
+ | Pin / DynamoRIO | Dynamic instrumentation for tracing | Record opcode handler execution sequence |
351
+ | REVEN | Full-system trace recording | Replay and analyze VM execution |
352
+ | Unicorn | Emulate VM execution | Fast handler emulation |
353
+ | Miasm | IR-based analysis | Lift VM handlers to IR for analysis |
354
+ | Custom Python | Write disassembler/decompiler | Per-challenge custom tooling |
355
+
356
+ ### Ghidra Sleigh Processor Module
357
+
358
+ For recurring VM architectures, write a Sleigh processor specification:
359
+
360
+ ```
361
+ define space ram type=ram_space size=2 default;
362
+ define space register type=register_space size=1;
363
+
364
+ define register offset=0 size=1 [ R0 R1 R2 R3 FLAGS PC SP ];
365
+
366
+ define token opcode(8)
367
+ op = (0,7)
368
+ ;
369
+
370
+ :NOP is op=0x00 { }
371
+ :PUSH imm is op=0x01; imm { SP = SP - 1; *[ram]:1 SP = imm; }
372
+ :POP is op=0x02 { SP = SP + 1; }
373
+ :ADD is op=0x03 { local a = *[ram]:1 (SP+1); *[ram]:1 (SP+1) = a + *[ram]:1 SP; SP = SP + 1; }
374
+ ```
375
+
376
+ ---
377
+
378
+ ## 7. DECISION TREE
379
+
380
+ ```
381
+ Binary contains custom bytecode interpreter?
382
+
383
+ ├─ Can you identify the dispatcher?
384
+ │ ├─ Yes (switch/table/if-chain)
385
+ │ │ ├─ Few opcodes (< 20) → Simple CTF VM
386
+ │ │ │ ├─ Stack-based → map push/pop/arithmetic ops
387
+ │ │ │ ├─ Register-based → map mov/add/cmp ops
388
+ │ │ │ └─ Write disassembler → analyze program → solve
389
+ │ │ │
390
+ │ │ └─ Many opcodes (50+) → Commercial protector
391
+ │ │ ├─ Known protector → use specific deprotection tools
392
+ │ │ └─ Custom → trace execution, pattern-match handlers
393
+ │ │
394
+ │ └─ No clear dispatcher
395
+ │ ├─ All-mov instructions → movfuscator
396
+ │ ├─ Encrypted bytecode → find decryption, dump after decode
397
+ │ └─ Split/distributed handlers → trace execution to find them
398
+
399
+ ├─ Is it a maze challenge?
400
+ │ ├─ Extract grid from data section
401
+ │ ├─ Identify direction encoding
402
+ │ ├─ BFS/DFS to find shortest path
403
+ │ └─ Convert path to expected input format
404
+
405
+ ├─ Is there input validation in VM?
406
+ │ ├─ Small input space → brute-force via Unicorn emulation
407
+ │ ├─ Known format → constrained angr solve
408
+ │ └─ Complex check → write disassembler, analyze check logic
409
+
410
+ └─ Multiple VM layers (VM in VM)?
411
+ ├─ Analyze outer VM first
412
+ ├─ Extract inner bytecode
413
+ ├─ Repeat analysis for inner VM
414
+ └─ Consider: symbolic execution may handle nested VMs directly
415
+ ```
416
+
417
+ ---
418
+
419
+ ## 8. CTF SOLVING WORKFLOW
420
+
421
+ ```
422
+ 1. Run the binary — understand I/O behavior
423
+ └─ What input does it expect? What output on success/failure?
424
+
425
+ 2. Open in IDA/Ghidra — find the main loop
426
+ └─ Look for while/for loop with switch or indirect jump
427
+
428
+ 3. Identify VM components:
429
+ ├─ Bytecode location (where is the program data?)
430
+ ├─ PC/IP variable (how is current position tracked?)
431
+ ├─ Registers/stack (where is VM state stored?)
432
+ └─ I/O handlers (which opcodes read input / write output?)
433
+
434
+ 4. Map all opcodes (create the ISA specification)
435
+ └─ For each case/handler: opcode number, operation, operands
436
+
437
+ 5. Write disassembler in Python
438
+ └─ Output readable assembly for the bytecode
439
+
440
+ 6. Analyze the disassembled program:
441
+ ├─ Find input reading
442
+ ├─ Trace transformations applied to input
443
+ ├─ Find comparison against expected values
444
+ └─ Reverse the transformation to find valid input
445
+
446
+ 7. Solve:
447
+ ├─ If simple transforms (XOR, ADD) → reverse manually
448
+ ├─ If complex → feed to Z3 as constraints
449
+ └─ If maze → extract grid, run pathfinding
450
+ ```
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: vr-cheatsheet-authentication_bypass
3
+ description: >-
4
+ Vulnerability research reference: authentication_bypassgated: true
5
+ ---
6
+ # 🔐 Authentication & Identity (JWT, OAuth, SAML) Cheatsheet
7
+
8
+ ---
9
+
10
+ ## 🎟️ 1. JWT (JSON Web Tokens) Attacks
11
+
12
+ *JWTs are base64-url encoded strings divided into three parts: `Header.Payload.Signature`. Always decode them (e.g., at jwt.io) to inspect the claims.*
13
+
14
+ ### The `alg=none` Bypass
15
+
16
+ *Many libraries fail to verify the signature if the header explicitly tells them not to.*
17
+
18
+ 1. Decode the Header.
19
+ 2. Change `"alg": "HS256"` (or RS256) to `"alg": "none"` (also try `"None"`, `"NONE"`).
20
+ 3. Modify the Payload (e.g., `"role": "admin"`).
21
+ 4. Remove the signature but **leave the trailing dot**.
22
+
23
+ * **Payload:** `eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VyIjoiaGFja2VyIiwicm9sZSI6ImFkbWluIn0.`
24
+
25
+ ### Key Confusion (Algorithm Swap: RS256 -> HS256)
26
+
27
+ *If the server expects an RSA public key (RS256) but you force it to use HMAC (HS256), the server might verify the token using its own public key as the HMAC secret.*
28
+
29
+ 1. Obtain the server's public key (often at `/.well-known/jwks.json`).
30
+ 2. Change the header algorithm to `HS256`.
31
+ 3. Sign your forged token using the **public key string** as the HMAC secret.
32
+
33
+ ### JWK (JSON Web Key) Injection
34
+
35
+ *If the token header accepts a `jwk` parameter, you can inject your own public key and sign the token with your matching private key.*
36
+
37
+ ```json
38
+ // Malicious Header
39
+ {
40
+ "alg": "RS256",
41
+ "jwk": {
42
+ "kty": "RSA",
43
+ "e": "AQAB",
44
+ "n": "vOUR_MALICIOUS_PUBLIC_KEY_MODULUS..."
45
+ }
46
+ }
47
+
48
+ ```
49
+
50
+ ### Offline Cracking
51
+
52
+ *If the JWT uses HS256 (symmetric key), extract it and attempt to crack the secret offline.*
53
+
54
+ ```bash
55
+ hashcat -a 0 -m 16500 jwt.txt rockyou.txt
56
+
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 🤝 2. OAuth 2.0 & OpenID Connect (OIDC)
62
+
63
+ *OAuth is an authorization framework; OIDC adds an identity layer on top. Vulnerabilities usually stem from bad implementation, not the protocol itself.*
64
+
65
+ ### Redirect URI Manipulation (Token Stealing)
66
+
67
+ *The `redirect_uri` parameter controls where the OAuth provider sends the authorization code or token. If this is not strictly whitelisted, you can steal the token.*
68
+
69
+ * **Target:** `https://provider.com/auth?client_id=123&redirect_uri=https://attacker.com`
70
+ * **Bypasses:**
71
+ * `https://client.com.attacker.com` (Subdomain bypass)
72
+ * `https://client.com/callback?redirect=https://attacker.com` (Open redirect chaining)
73
+ * `https://client.com%2Eattacker.com` (URL encoding)
74
+ * `https://client.com@attacker.com` (Credentials syntax)
75
+
76
+
77
+
78
+ ### CSRF via Missing `state` Parameter
79
+
80
+ *If the initial authorization request lacks a `state` parameter (or the server doesn't validate it), you can force a victim to log into your account.*
81
+
82
+ 1. Attacker initiates a login with the provider but intercepts the response containing the authorization `code`.
83
+ 2. Attacker drops the request and sends the callback URL (with the `code`) to the victim.
84
+ 3. The victim clicks the link, tying their local session to the attacker's third-party account (useful for capturing sensitive info saved to the account).
85
+
86
+ ### Pre-Account Takeover (Implicit Trust)
87
+
88
+ *If an application allows email/password registration AND OAuth login (e.g., "Log in with Google"), check if it verifies emails.*
89
+
90
+ 1. Attacker registers an account using `victim@company.com` and a password they control.
91
+ 2. Victim later logs in using "Log in with Google".
92
+ 3. If the application merges the accounts without verifying the initial email, the attacker still has access via the password.
93
+
94
+ ---
95
+
96
+ ## 🏢 3. SAML (Security Assertion Markup Language)
97
+
98
+ *SAML uses XML to pass identity assertions between an Identity Provider (IdP) and a Service Provider (SP).*
99
+
100
+ ### XML Signature Wrapping (XSW)
101
+
102
+ *SAML messages are signed to prevent tampering. XSW involves injecting a fake assertion while keeping the original, validly signed assertion intact to trick the parser.*
103
+
104
+ 1. Intercept the SAML Response (base64 decoded).
105
+ 2. Clone the `<Assertion>` block.
106
+ 3. Modify the cloned assertion (e.g., change the `<NameID>` to `admin@corp.com`).
107
+ 4. Place the cloned assertion in a way that the signature validation logic checks the *original*, but the application logic reads the *fake* one (e.g., moving the original assertion into a wrapper element).
108
+
109
+ * **Tool:** Use the **SAML Raider** extension in Burp Suite to automate XSW attacks.
110
+
111
+ ### Signature Stripping
112
+
113
+ *Some poorly configured SPs only validate the signature if it exists.*
114
+
115
+ 1. Intercept the SAML response.
116
+ 2. Completely delete the `<ds:Signature>` block.
117
+ 3. Modify the assertion and forward it.
118
+
119
+ ### XML Comment Injection
120
+
121
+ *Tricking the parser's username extraction logic by breaking the string with XML comments.*
122
+
123
+ * **Target Account:** `admin@corp.com`
124
+ * **Registered Malicious Account:** `admin@corp.com.evil.com`
125
+ * If the parser strips comments before checking the database, it evaluates to `admin@corp.com.evil.com`. If it strips comments *after* string evaluation, it might truncate or bypass filters to match `admin@corp.com`.
126
+
127
+ ---
128
+
129
+ ## 🚪 4. General Authentication & MFA Flaws
130
+
131
+ ### MFA Response Manipulation
132
+
133
+ *Sometimes the server sends the MFA success/fail status to the client to make routing decisions.*
134
+
135
+ * Intercept the HTTP response from a failed MFA attempt:
136
+ ```http
137
+ HTTP/1.1 401 Unauthorized
138
+ {"success": false, "message": "Invalid Code"}
139
+
140
+ ```
141
+
142
+
143
+ * Modify it to simulate success before it hits the browser:
144
+ ```http
145
+ HTTP/1.1 200 OK
146
+ {"success": true, "message": "Authenticated"}
147
+
148
+ ```
149
+
150
+
151
+
152
+ ### Password Reset Host Header Poisoning
153
+
154
+ *If the server uses the HTTP `Host` header to generate the password reset link, you can steal the token.*
155
+
156
+ ```http
157
+ POST /api/reset-password HTTP/1.1
158
+ Host: evil-server.com
159
+ Content-Type: application/json
160
+
161
+ {"email": "admin@target.com"}
162
+
163
+ ```
164
+
165
+ *If vulnerable, the server emails the victim a link like: `https://evil-server.com/reset?token=123xyz`. When the victim clicks, the attacker captures the token.*
166
+
167
+ ---
168
+
169
+ ## Takeaways
170
+
171
+ ### Offensive Perspective
172
+
173
+ * **The "Trust but Don't Verify" Paradigm:** Applications often assume that because a token *looks* like it came from a trusted provider (Google, Okta, Auth0), it is safe. Always test what happens when you strip the signature (`alg=none`) or alter the cryptographic algorithm (e.g., swapping RS256 for HS256). If the backend dynamically trusts the `alg` header without enforcing a strict whitelist, the door is wide open.
174
+ * **Exploit the Translation Gap (SAML/OAuth):** In enterprise SSO, vulnerabilities almost always live in the parsing differences between the Identity Provider (IdP) and the Service Provider (SP). For example, in SAML XML Signature Wrapping (XSW), the goal is to find out if the SP's signature validator looks at one part of the document while the actual application logic reads another. Find the desync, find the bug.
175
+ * **State and Context Loss:** Look for missing `state` or `nonce` parameters in OAuth flows. Developers frequently implement the "happy path" for user login but completely forget to protect against an attacker forcing a victim into a specific session (Login CSRF) or intercepting the authorization code via open redirects.
176
+
177
+ ### Defensive Perspective
178
+
179
+ * **Never Roll Your Own Crypto or Parsers:** Whether it's JWT validation or parsing SAML XML, strictly use established, heavily audited libraries. The vast majority of identity-related CVEs over the last decade stem from developers trying to manually parse claims or verify signatures using custom string manipulation or regex.
180
+ * **Enforce Strict Cryptographic Expectations:** Do not let the client dictate the cryptographic algorithm. If your application expects an RSA-signed token (RS256), configure the backend to explicitly *reject* HS256, `none`, or any other algorithm. Never blindly trust the `alg` header provided by the user's token.
181
+ * **Modernize OAuth Implementations:** Always mandate the `state` parameter to tie the authorization request to the user's specific browser session, preventing CSRF. Furthermore, implement PKCE (Proof Key for Code Exchange) by default—even for confidential backend web clients—to comprehensively protect against authorization code interception.
182
+ * **Harden XML Parsers (SAML):** Before a SAML signature is even verified, the underlying XML parser must be locked down. Explicitly disable XML External Entities (XXE) and Document Type Definitions (DTDs) to prevent entity expansion attacks. Ensure the parser enforces strict schema validation so cloned or wrapper assertions (XSW) cause the transaction to fail safely.
183
+
184
+ > Source: skraft9/vulnerability-research. Authorized security work only. Gated skill: needs the developer keyword.