subdomainchecker 0.2.2__tar.gz
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.
- subdomainchecker-0.2.2/LICENSE +23 -0
- subdomainchecker-0.2.2/PKG-INFO +182 -0
- subdomainchecker-0.2.2/README.md +171 -0
- subdomainchecker-0.2.2/pyproject.toml +21 -0
- subdomainchecker-0.2.2/setup.cfg +4 -0
- subdomainchecker-0.2.2/subdomainchecker/__init__.py +12 -0
- subdomainchecker-0.2.2/subdomainchecker/__main__.py +218 -0
- subdomainchecker-0.2.2/subdomainchecker/checker.py +385 -0
- subdomainchecker-0.2.2/subdomainchecker/data/fingerprints.json +588 -0
- subdomainchecker-0.2.2/subdomainchecker/data.py +64 -0
- subdomainchecker-0.2.2/subdomainchecker/dns.py +385 -0
- subdomainchecker-0.2.2/subdomainchecker/verify.py +198 -0
- subdomainchecker-0.2.2/subdomainchecker.egg-info/PKG-INFO +182 -0
- subdomainchecker-0.2.2/subdomainchecker.egg-info/SOURCES.txt +19 -0
- subdomainchecker-0.2.2/subdomainchecker.egg-info/dependency_links.txt +1 -0
- subdomainchecker-0.2.2/subdomainchecker.egg-info/entry_points.txt +2 -0
- subdomainchecker-0.2.2/subdomainchecker.egg-info/top_level.txt +1 -0
- subdomainchecker-0.2.2/tests/test_checker.py +240 -0
- subdomainchecker-0.2.2/tests/test_dns.py +500 -0
- subdomainchecker-0.2.2/tests/test_hardening.py +287 -0
- subdomainchecker-0.2.2/tests/test_verify.py +324 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Superstar Telecom LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
20
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
21
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
22
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: subdomainchecker
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Subdomain takeover checker — finds dangling CNAMEs pointing at unclaimed services, using published fingerprints only. Read-only DNS plus at most one benign GET per candidate. Never claims, registers, or provisions anything.
|
|
5
|
+
Author: Superstar Telecom LLC
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# subdomainchecker
|
|
13
|
+
|
|
14
|
+
A subdomain takeover checker: it finds **dangling CNAMEs** —
|
|
15
|
+
subdomains that point at a third-party service (GitHub Pages,
|
|
16
|
+
Heroku, an S3 bucket, …) whose resource has been deleted. Anyone
|
|
17
|
+
can re-register that resource and end up serving content on
|
|
18
|
+
*your* subdomain. subdomainchecker tells you which records are
|
|
19
|
+
exposed, with the evidence, before someone else finds them.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install subdomainchecker
|
|
23
|
+
subdomainchecker check example.com
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## How it works
|
|
27
|
+
|
|
28
|
+
1. **Enumerate.** Subdomains come from certificate transparency
|
|
29
|
+
(crt.sh's public JSON API), or from your own list with
|
|
30
|
+
`--list` — see below.
|
|
31
|
+
2. **Resolve.** Each subdomain's CNAME is resolved with a small
|
|
32
|
+
built-in DNS client. No CNAME, no finding.
|
|
33
|
+
3. **Confirm.** A CNAME at a takeover-capable service is not
|
|
34
|
+
itself a finding — the service might be alive and yours.
|
|
35
|
+
subdomainchecker confirms the resource is *unclaimed* using the
|
|
36
|
+
service's published fingerprint from the
|
|
37
|
+
[can-i-take-over-xyz](https://github.com/EdOverflow/can-i-take-over-xyz)
|
|
38
|
+
dataset: either the CNAME target no longer resolves (NXDOMAIN),
|
|
39
|
+
or one benign GET returns the service's known "not found / not
|
|
40
|
+
configured" page. Usage alone is never reported.
|
|
41
|
+
4. **Verdict, with a fix.** Every non-OK result carries a
|
|
42
|
+
remediation: remove the DNS record, or reclaim the resource
|
|
43
|
+
on the service, before someone else does.
|
|
44
|
+
|
|
45
|
+
## Verdicts and exit codes
|
|
46
|
+
|
|
47
|
+
| Verdict | Meaning |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `VULNERABLE` | CNAME to a takeover-capable service, and the resource is confirmed unclaimed (target NXDOMAIN, or the unclaimed fingerprint was served). |
|
|
50
|
+
| `POSSIBLE` | The CNAME target no longer resolves but the service is unknown, or a known service's fingerprint could not be confirmed from here. A prompt to review the record — not an accusation. |
|
|
51
|
+
| `UNCHECKED` | The subdomain's state could not be determined: the CNAME lookup failed, or the target's resolution failed and the service is unknown. A failed lookup is never reported as OK. |
|
|
52
|
+
| `OK` | No CNAME, the target resolves and is not a known takeover-capable service, or the service resource is claimed and serving. |
|
|
53
|
+
|
|
54
|
+
A target only counts as "gone" on positive evidence:
|
|
55
|
+
NXDOMAIN, or NOERROR with an empty answer and an SOA record
|
|
56
|
+
in the authority section. Resolver errors (SERVFAIL, REFUSED,
|
|
57
|
+
timeouts, truncated answers that fail the TCP retry) prove
|
|
58
|
+
nothing and lead to POSSIBLE or UNCHECKED, never VULNERABLE
|
|
59
|
+
or OK.
|
|
60
|
+
|
|
61
|
+
Exit codes (the scanner-family convention: 0 clean ·
|
|
62
|
+
1 findings · 2 cannot judge · 3 judged under degraded
|
|
63
|
+
evidence): `0` — every subdomain judged OK; `1` — at least
|
|
64
|
+
one VULNERABLE or POSSIBLE and everything was judged; `2` —
|
|
65
|
+
usage error, enumeration failure, or no findings but at
|
|
66
|
+
least one subdomain UNCHECKED; `3` — findings were judged,
|
|
67
|
+
but at least one subdomain was UNCHECKED.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Enumerate via certificate transparency, then check
|
|
73
|
+
subdomainchecker check example.com
|
|
74
|
+
|
|
75
|
+
# Bring your own subdomain list (one name per line).
|
|
76
|
+
# This is the reliable path for serious audits: crt.sh is
|
|
77
|
+
# intermittently unavailable, and CT logs only ever show
|
|
78
|
+
# subdomains that have had certificates issued.
|
|
79
|
+
subdomainchecker check --list subdomains.txt
|
|
80
|
+
|
|
81
|
+
# Machine-readable output
|
|
82
|
+
subdomainchecker check example.com --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Checks run sequentially with a small delay (`--delay`, default
|
|
86
|
+
0.3s). DNS lookups plus at most **one** GET per candidate —
|
|
87
|
+
nothing heavier ever touches the target.
|
|
88
|
+
|
|
89
|
+
## Prove the fix: `--verify`
|
|
90
|
+
|
|
91
|
+
Every finding creates the same follow-up question: *prove
|
|
92
|
+
it's fixed.* Save a scan's JSON, fix the records, then verify
|
|
93
|
+
against the saved report:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
subdomainchecker check example.com --json > report.json
|
|
97
|
+
# …remove the dangling records / reclaim the resources…
|
|
98
|
+
subdomainchecker --verify report.json
|
|
99
|
+
subdomainchecker --verify report.json --json # machine-readable proof
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Verification re-checks **only the prior findings** (the
|
|
103
|
+
VULNERABLE and POSSIBLE entries — OK entries are ignored) and
|
|
104
|
+
classifies each one:
|
|
105
|
+
|
|
106
|
+
| Classification | Meaning |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `FIXED-REMOVED` | The CNAME record is gone. |
|
|
109
|
+
| `FIXED-RECLAIMED` | The record still points at the service, but the unclaimed fingerprint is gone — the resource has been claimed and is serving. |
|
|
110
|
+
| `STILL-VULNERABLE` | Same target, still confirmed unclaimed. |
|
|
111
|
+
| `STILL-POSSIBLE` | Same target, still unresolved — including when the fresh check could not confirm the record's state (an unproven fix is never reported as fixed). |
|
|
112
|
+
| `CHANGED` | The record now points somewhere else; the new target is re-evaluated fresh and its verdict is included, so a repoint to another dangling target can't hide. |
|
|
113
|
+
|
|
114
|
+
The output is a timestamped delta report — a proof record a
|
|
115
|
+
ticket or CI job can gate on. Verify exit codes: `0` — every
|
|
116
|
+
prior finding is FIXED-*; `1` — at least one is not (in
|
|
117
|
+
particular any STILL-VULNERABLE); `2` — the prior report is
|
|
118
|
+
unreadable or not a subdomainchecker report. Verification
|
|
119
|
+
uses the same traffic discipline as a scan: DNS lookups plus
|
|
120
|
+
at most one benign GET per candidate.
|
|
121
|
+
|
|
122
|
+
## What it never does
|
|
123
|
+
|
|
124
|
+
subdomainchecker is a detector, not an exploit. It **never
|
|
125
|
+
attempts to claim, register, or provision** any resource it
|
|
126
|
+
finds, on any service, under any flag. There is no such code
|
|
127
|
+
path. It reports the exposure so the domain's owner can remove
|
|
128
|
+
the record or reclaim the resource first.
|
|
129
|
+
|
|
130
|
+
## Install
|
|
131
|
+
|
|
132
|
+
One line, from PyPI (Python 3.11+, standard library only —
|
|
133
|
+
zero dependencies):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
pip install subdomainchecker
|
|
137
|
+
subdomainchecker check example.com
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
On systems that refuse with "externally-managed-environment"
|
|
141
|
+
(Debian/Ubuntu and Homebrew Pythons), use pipx or install from
|
|
142
|
+
GitHub instead:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python3 -m pip install --user pipx # if you don't have pipx yet
|
|
146
|
+
pipx install subdomainchecker
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
pip install git+https://github.com/PHPatch/subdomainchecker.git
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Data
|
|
154
|
+
|
|
155
|
+
The fingerprint dataset is a vendored snapshot of
|
|
156
|
+
EdOverflow's can-i-take-over-xyz (MIT), covering 50
|
|
157
|
+
takeover-capable services. Snapshot details, the upstream
|
|
158
|
+
commit, and the refresh path (`tools/refresh_fingerprints.py`)
|
|
159
|
+
are in [ATTRIBUTION.md](ATTRIBUTION.md).
|
|
160
|
+
|
|
161
|
+
## Tests
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python -m unittest discover # or: pytest
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
85 tests. Exactly one is environment-dependent:
|
|
168
|
+
`ClientHardeningWireTests.test_ipv6_nameserver_answers`
|
|
169
|
+
binds a fake DNS server to IPv6 loopback (`::1`) and skips
|
|
170
|
+
— with the reason "IPv6 loopback unavailable in this
|
|
171
|
+
environment" — on hosts without IPv6 loopback. Everywhere
|
|
172
|
+
else it runs and passes, so a run reports either
|
|
173
|
+
"85 passed" or "84 passed, 1 skipped".
|
|
174
|
+
|
|
175
|
+
## Security
|
|
176
|
+
|
|
177
|
+
Report vulnerabilities through https://phpatch.com/security or
|
|
178
|
+
security@phpatch.com — see [SECURITY.md](SECURITY.md). Releases
|
|
179
|
+
are PGP-signed with the PHPatch Security key.
|
|
180
|
+
|
|
181
|
+
From [PHPatch](https://phpatch.com) — the team behind
|
|
182
|
+
[phpscan](https://github.com/PHPatch/phpscan).
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# subdomainchecker
|
|
2
|
+
|
|
3
|
+
A subdomain takeover checker: it finds **dangling CNAMEs** —
|
|
4
|
+
subdomains that point at a third-party service (GitHub Pages,
|
|
5
|
+
Heroku, an S3 bucket, …) whose resource has been deleted. Anyone
|
|
6
|
+
can re-register that resource and end up serving content on
|
|
7
|
+
*your* subdomain. subdomainchecker tells you which records are
|
|
8
|
+
exposed, with the evidence, before someone else finds them.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install subdomainchecker
|
|
12
|
+
subdomainchecker check example.com
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## How it works
|
|
16
|
+
|
|
17
|
+
1. **Enumerate.** Subdomains come from certificate transparency
|
|
18
|
+
(crt.sh's public JSON API), or from your own list with
|
|
19
|
+
`--list` — see below.
|
|
20
|
+
2. **Resolve.** Each subdomain's CNAME is resolved with a small
|
|
21
|
+
built-in DNS client. No CNAME, no finding.
|
|
22
|
+
3. **Confirm.** A CNAME at a takeover-capable service is not
|
|
23
|
+
itself a finding — the service might be alive and yours.
|
|
24
|
+
subdomainchecker confirms the resource is *unclaimed* using the
|
|
25
|
+
service's published fingerprint from the
|
|
26
|
+
[can-i-take-over-xyz](https://github.com/EdOverflow/can-i-take-over-xyz)
|
|
27
|
+
dataset: either the CNAME target no longer resolves (NXDOMAIN),
|
|
28
|
+
or one benign GET returns the service's known "not found / not
|
|
29
|
+
configured" page. Usage alone is never reported.
|
|
30
|
+
4. **Verdict, with a fix.** Every non-OK result carries a
|
|
31
|
+
remediation: remove the DNS record, or reclaim the resource
|
|
32
|
+
on the service, before someone else does.
|
|
33
|
+
|
|
34
|
+
## Verdicts and exit codes
|
|
35
|
+
|
|
36
|
+
| Verdict | Meaning |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `VULNERABLE` | CNAME to a takeover-capable service, and the resource is confirmed unclaimed (target NXDOMAIN, or the unclaimed fingerprint was served). |
|
|
39
|
+
| `POSSIBLE` | The CNAME target no longer resolves but the service is unknown, or a known service's fingerprint could not be confirmed from here. A prompt to review the record — not an accusation. |
|
|
40
|
+
| `UNCHECKED` | The subdomain's state could not be determined: the CNAME lookup failed, or the target's resolution failed and the service is unknown. A failed lookup is never reported as OK. |
|
|
41
|
+
| `OK` | No CNAME, the target resolves and is not a known takeover-capable service, or the service resource is claimed and serving. |
|
|
42
|
+
|
|
43
|
+
A target only counts as "gone" on positive evidence:
|
|
44
|
+
NXDOMAIN, or NOERROR with an empty answer and an SOA record
|
|
45
|
+
in the authority section. Resolver errors (SERVFAIL, REFUSED,
|
|
46
|
+
timeouts, truncated answers that fail the TCP retry) prove
|
|
47
|
+
nothing and lead to POSSIBLE or UNCHECKED, never VULNERABLE
|
|
48
|
+
or OK.
|
|
49
|
+
|
|
50
|
+
Exit codes (the scanner-family convention: 0 clean ·
|
|
51
|
+
1 findings · 2 cannot judge · 3 judged under degraded
|
|
52
|
+
evidence): `0` — every subdomain judged OK; `1` — at least
|
|
53
|
+
one VULNERABLE or POSSIBLE and everything was judged; `2` —
|
|
54
|
+
usage error, enumeration failure, or no findings but at
|
|
55
|
+
least one subdomain UNCHECKED; `3` — findings were judged,
|
|
56
|
+
but at least one subdomain was UNCHECKED.
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Enumerate via certificate transparency, then check
|
|
62
|
+
subdomainchecker check example.com
|
|
63
|
+
|
|
64
|
+
# Bring your own subdomain list (one name per line).
|
|
65
|
+
# This is the reliable path for serious audits: crt.sh is
|
|
66
|
+
# intermittently unavailable, and CT logs only ever show
|
|
67
|
+
# subdomains that have had certificates issued.
|
|
68
|
+
subdomainchecker check --list subdomains.txt
|
|
69
|
+
|
|
70
|
+
# Machine-readable output
|
|
71
|
+
subdomainchecker check example.com --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Checks run sequentially with a small delay (`--delay`, default
|
|
75
|
+
0.3s). DNS lookups plus at most **one** GET per candidate —
|
|
76
|
+
nothing heavier ever touches the target.
|
|
77
|
+
|
|
78
|
+
## Prove the fix: `--verify`
|
|
79
|
+
|
|
80
|
+
Every finding creates the same follow-up question: *prove
|
|
81
|
+
it's fixed.* Save a scan's JSON, fix the records, then verify
|
|
82
|
+
against the saved report:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
subdomainchecker check example.com --json > report.json
|
|
86
|
+
# …remove the dangling records / reclaim the resources…
|
|
87
|
+
subdomainchecker --verify report.json
|
|
88
|
+
subdomainchecker --verify report.json --json # machine-readable proof
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Verification re-checks **only the prior findings** (the
|
|
92
|
+
VULNERABLE and POSSIBLE entries — OK entries are ignored) and
|
|
93
|
+
classifies each one:
|
|
94
|
+
|
|
95
|
+
| Classification | Meaning |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| `FIXED-REMOVED` | The CNAME record is gone. |
|
|
98
|
+
| `FIXED-RECLAIMED` | The record still points at the service, but the unclaimed fingerprint is gone — the resource has been claimed and is serving. |
|
|
99
|
+
| `STILL-VULNERABLE` | Same target, still confirmed unclaimed. |
|
|
100
|
+
| `STILL-POSSIBLE` | Same target, still unresolved — including when the fresh check could not confirm the record's state (an unproven fix is never reported as fixed). |
|
|
101
|
+
| `CHANGED` | The record now points somewhere else; the new target is re-evaluated fresh and its verdict is included, so a repoint to another dangling target can't hide. |
|
|
102
|
+
|
|
103
|
+
The output is a timestamped delta report — a proof record a
|
|
104
|
+
ticket or CI job can gate on. Verify exit codes: `0` — every
|
|
105
|
+
prior finding is FIXED-*; `1` — at least one is not (in
|
|
106
|
+
particular any STILL-VULNERABLE); `2` — the prior report is
|
|
107
|
+
unreadable or not a subdomainchecker report. Verification
|
|
108
|
+
uses the same traffic discipline as a scan: DNS lookups plus
|
|
109
|
+
at most one benign GET per candidate.
|
|
110
|
+
|
|
111
|
+
## What it never does
|
|
112
|
+
|
|
113
|
+
subdomainchecker is a detector, not an exploit. It **never
|
|
114
|
+
attempts to claim, register, or provision** any resource it
|
|
115
|
+
finds, on any service, under any flag. There is no such code
|
|
116
|
+
path. It reports the exposure so the domain's owner can remove
|
|
117
|
+
the record or reclaim the resource first.
|
|
118
|
+
|
|
119
|
+
## Install
|
|
120
|
+
|
|
121
|
+
One line, from PyPI (Python 3.11+, standard library only —
|
|
122
|
+
zero dependencies):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install subdomainchecker
|
|
126
|
+
subdomainchecker check example.com
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
On systems that refuse with "externally-managed-environment"
|
|
130
|
+
(Debian/Ubuntu and Homebrew Pythons), use pipx or install from
|
|
131
|
+
GitHub instead:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
python3 -m pip install --user pipx # if you don't have pipx yet
|
|
135
|
+
pipx install subdomainchecker
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pip install git+https://github.com/PHPatch/subdomainchecker.git
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Data
|
|
143
|
+
|
|
144
|
+
The fingerprint dataset is a vendored snapshot of
|
|
145
|
+
EdOverflow's can-i-take-over-xyz (MIT), covering 50
|
|
146
|
+
takeover-capable services. Snapshot details, the upstream
|
|
147
|
+
commit, and the refresh path (`tools/refresh_fingerprints.py`)
|
|
148
|
+
are in [ATTRIBUTION.md](ATTRIBUTION.md).
|
|
149
|
+
|
|
150
|
+
## Tests
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
python -m unittest discover # or: pytest
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
85 tests. Exactly one is environment-dependent:
|
|
157
|
+
`ClientHardeningWireTests.test_ipv6_nameserver_answers`
|
|
158
|
+
binds a fake DNS server to IPv6 loopback (`::1`) and skips
|
|
159
|
+
— with the reason "IPv6 loopback unavailable in this
|
|
160
|
+
environment" — on hosts without IPv6 loopback. Everywhere
|
|
161
|
+
else it runs and passes, so a run reports either
|
|
162
|
+
"85 passed" or "84 passed, 1 skipped".
|
|
163
|
+
|
|
164
|
+
## Security
|
|
165
|
+
|
|
166
|
+
Report vulnerabilities through https://phpatch.com/security or
|
|
167
|
+
security@phpatch.com — see [SECURITY.md](SECURITY.md). Releases
|
|
168
|
+
are PGP-signed with the PHPatch Security key.
|
|
169
|
+
|
|
170
|
+
From [PHPatch](https://phpatch.com) — the team behind
|
|
171
|
+
[phpscan](https://github.com/PHPatch/phpscan).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "subdomainchecker"
|
|
7
|
+
version = "0.2.2"
|
|
8
|
+
description = "Subdomain takeover checker — finds dangling CNAMEs pointing at unclaimed services, using published fingerprints only. Read-only DNS plus at most one benign GET per candidate. Never claims, registers, or provisions anything."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [{ name = "Superstar Telecom LLC" }]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
subdomainchecker = "subdomainchecker.__main__:cli"
|
|
16
|
+
|
|
17
|
+
[tool.setuptools]
|
|
18
|
+
packages = ["subdomainchecker"]
|
|
19
|
+
|
|
20
|
+
[tool.setuptools.package-data]
|
|
21
|
+
subdomainchecker = ["data/*.json"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""subdomainchecker — subdomain takeover checker.
|
|
2
|
+
|
|
3
|
+
Finds subdomains whose CNAME points at a takeover-capable service
|
|
4
|
+
whose resource has been deleted (a "dangling" record), using the
|
|
5
|
+
published fingerprints from the can-i-take-over-xyz dataset.
|
|
6
|
+
|
|
7
|
+
Strictly read-only: DNS lookups plus at most one benign GET per
|
|
8
|
+
candidate subdomain. subdomainchecker never attempts to claim, register,
|
|
9
|
+
or provision any resource.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
__version__ = "0.2.2"
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""Command line: ``subdomainchecker check <domain>``,
|
|
2
|
+
``subdomainchecker check --list subdomains.txt``, or
|
|
3
|
+
``subdomainchecker --verify prior-report.json``.
|
|
4
|
+
|
|
5
|
+
Exit codes, following the scanner-family convention
|
|
6
|
+
(0 clean · 1 findings · 2 cannot judge · 3 judged under
|
|
7
|
+
degraded evidence). For check: 0 = every subdomain judged OK;
|
|
8
|
+
1 = at least one VULNERABLE or POSSIBLE finding and every
|
|
9
|
+
subdomain was judged; 2 = usage or enumeration error, or no
|
|
10
|
+
findings but at least one subdomain UNCHECKED (it could not
|
|
11
|
+
be judged); 3 = findings were judged, but at least one
|
|
12
|
+
subdomain was UNCHECKED, so the judgement rests on degraded
|
|
13
|
+
evidence. For --verify: 0 = every prior finding verified
|
|
14
|
+
FIXED-*, 1 = at least one prior finding is not fixed (in
|
|
15
|
+
particular any STILL-VULNERABLE), 2 = usage error or
|
|
16
|
+
unreadable prior report.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import sys
|
|
24
|
+
from datetime import datetime, timezone
|
|
25
|
+
|
|
26
|
+
from . import __version__
|
|
27
|
+
from .checker import (EnumerationError, fetch_crtsh, load_list,
|
|
28
|
+
run_checks, summarize)
|
|
29
|
+
from .verify import (ReportError, all_fixed, load_prior_report,
|
|
30
|
+
run_verify, summarize_delta)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
34
|
+
parser = argparse.ArgumentParser(
|
|
35
|
+
prog="subdomainchecker",
|
|
36
|
+
description="Subdomain takeover checker — dangling "
|
|
37
|
+
"CNAMEs pointing at unclaimed services, "
|
|
38
|
+
"confirmed with published fingerprints. "
|
|
39
|
+
"Read-only: it never claims anything.")
|
|
40
|
+
parser.add_argument("--version", action="version",
|
|
41
|
+
version=f"subdomainchecker {__version__}")
|
|
42
|
+
parser.add_argument("--verify", dest="verify_path",
|
|
43
|
+
metavar="FILE",
|
|
44
|
+
help="verify fixes against a prior JSON "
|
|
45
|
+
"report: re-check only its findings "
|
|
46
|
+
"and classify each FIXED-REMOVED / "
|
|
47
|
+
"FIXED-RECLAIMED / STILL-VULNERABLE "
|
|
48
|
+
"/ STILL-POSSIBLE / CHANGED")
|
|
49
|
+
parser.add_argument("--json", action="store_true",
|
|
50
|
+
help="with --verify: emit JSON instead "
|
|
51
|
+
"of text")
|
|
52
|
+
parser.add_argument("--delay", type=float, default=0.3,
|
|
53
|
+
help="with --verify: seconds between "
|
|
54
|
+
"candidates (default 0.3)")
|
|
55
|
+
parser.add_argument("--timeout", type=float, default=10.0,
|
|
56
|
+
help="with --verify: per-request timeout "
|
|
57
|
+
"in seconds (default 10)")
|
|
58
|
+
sub = parser.add_subparsers(dest="command")
|
|
59
|
+
check = sub.add_parser(
|
|
60
|
+
"check", help="check a domain's subdomains for dangling "
|
|
61
|
+
"CNAMEs")
|
|
62
|
+
check.add_argument("domain", nargs="?",
|
|
63
|
+
help="apex domain to enumerate via "
|
|
64
|
+
"certificate transparency (crt.sh)")
|
|
65
|
+
check.add_argument("--list", dest="list_path", metavar="FILE",
|
|
66
|
+
help="read subdomain names from FILE (one "
|
|
67
|
+
"per line) instead of enumerating — "
|
|
68
|
+
"the reliable path for serious audits")
|
|
69
|
+
check.add_argument("--json", action="store_true",
|
|
70
|
+
help="emit JSON instead of text")
|
|
71
|
+
check.add_argument("--delay", type=float, default=0.3,
|
|
72
|
+
help="seconds between candidates "
|
|
73
|
+
"(default 0.3)")
|
|
74
|
+
check.add_argument("--timeout", type=float, default=10.0,
|
|
75
|
+
help="per-request timeout in seconds "
|
|
76
|
+
"(default 10)")
|
|
77
|
+
return parser
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def render_text(target: str, results: list[dict]) -> str:
|
|
81
|
+
lines = [f"subdomainchecker check: {target} "
|
|
82
|
+
f"({len(results)} subdomains checked)", ""]
|
|
83
|
+
for result in results:
|
|
84
|
+
lines.append(f"{result['verdict']:<10} "
|
|
85
|
+
f"{result['subdomain']}")
|
|
86
|
+
if result["cname"]:
|
|
87
|
+
lines.append(f"{'':<10} CNAME -> {result['cname']}")
|
|
88
|
+
lines.append(f"{'':<10} {result['evidence']}")
|
|
89
|
+
if result["remediation"]:
|
|
90
|
+
lines.append(f"{'':<10} Fix: {result['remediation']}")
|
|
91
|
+
counts = summarize(results)
|
|
92
|
+
lines.append("")
|
|
93
|
+
summary = (f"Summary: {counts['VULNERABLE']} vulnerable, "
|
|
94
|
+
f"{counts['POSSIBLE']} possible, "
|
|
95
|
+
f"{counts['OK']} ok")
|
|
96
|
+
if counts["UNCHECKED"]:
|
|
97
|
+
summary += f", {counts['UNCHECKED']} unchecked"
|
|
98
|
+
lines.append(summary)
|
|
99
|
+
return "\n".join(lines)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def render_verify_text(prior_path: str, findings_count: int,
|
|
103
|
+
records: list[dict],
|
|
104
|
+
verified_at: str) -> str:
|
|
105
|
+
lines = [f"subdomainchecker verify: {prior_path} "
|
|
106
|
+
f"({findings_count} prior findings, verified "
|
|
107
|
+
f"{verified_at})", ""]
|
|
108
|
+
for record in records:
|
|
109
|
+
prior = record["prior"]
|
|
110
|
+
lines.append(f"{record['classification']:<16} "
|
|
111
|
+
f"{record['subdomain']}")
|
|
112
|
+
was = f"was {prior['verdict']}"
|
|
113
|
+
if prior["cname"]:
|
|
114
|
+
was += f" — CNAME -> {prior['cname']}"
|
|
115
|
+
lines.append(f"{'':<16} {was}")
|
|
116
|
+
lines.append(f"{'':<16} {record['evidence']}")
|
|
117
|
+
counts = summarize_delta(records)
|
|
118
|
+
lines.append("")
|
|
119
|
+
lines.append(
|
|
120
|
+
f"Summary: {counts['FIXED-REMOVED']} fixed-removed, "
|
|
121
|
+
f"{counts['FIXED-RECLAIMED']} fixed-reclaimed, "
|
|
122
|
+
f"{counts['STILL-VULNERABLE']} still-vulnerable, "
|
|
123
|
+
f"{counts['STILL-POSSIBLE']} still-possible, "
|
|
124
|
+
f"{counts['CHANGED']} changed — "
|
|
125
|
+
+ ("ALL FIXED" if all_fixed(records) else "NOT ALL FIXED"))
|
|
126
|
+
return "\n".join(lines)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def main(argv: list[str] | None = None) -> int:
|
|
130
|
+
parser = build_parser()
|
|
131
|
+
args = parser.parse_args(argv)
|
|
132
|
+
if args.verify_path:
|
|
133
|
+
try:
|
|
134
|
+
report, findings = load_prior_report(args.verify_path)
|
|
135
|
+
except ReportError as exc:
|
|
136
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
137
|
+
return 2
|
|
138
|
+
records = run_verify(findings, delay=args.delay,
|
|
139
|
+
timeout=args.timeout)
|
|
140
|
+
verified_at = datetime.now(
|
|
141
|
+
timezone.utc).isoformat(timespec="seconds")
|
|
142
|
+
if args.json:
|
|
143
|
+
print(json.dumps({
|
|
144
|
+
"tool": "subdomainchecker",
|
|
145
|
+
"schema_version": 1,
|
|
146
|
+
"version": __version__,
|
|
147
|
+
"mode": "verify",
|
|
148
|
+
"prior_report": args.verify_path,
|
|
149
|
+
"prior_target": report.get("target"),
|
|
150
|
+
"prior_version": report.get("version"),
|
|
151
|
+
"verified_at": verified_at,
|
|
152
|
+
"prior_findings": len(findings),
|
|
153
|
+
"summary": summarize_delta(records),
|
|
154
|
+
"all_fixed": all_fixed(records),
|
|
155
|
+
"results": records,
|
|
156
|
+
}, indent=2))
|
|
157
|
+
else:
|
|
158
|
+
print(render_verify_text(args.verify_path,
|
|
159
|
+
len(findings), records,
|
|
160
|
+
verified_at))
|
|
161
|
+
return 0 if all_fixed(records) else 1
|
|
162
|
+
if args.command != "check":
|
|
163
|
+
parser.print_help()
|
|
164
|
+
return 2
|
|
165
|
+
if bool(args.domain) == bool(args.list_path):
|
|
166
|
+
print("error: give exactly one of <domain> or --list FILE",
|
|
167
|
+
file=sys.stderr)
|
|
168
|
+
return 2
|
|
169
|
+
|
|
170
|
+
if args.list_path:
|
|
171
|
+
try:
|
|
172
|
+
subdomains = load_list(args.list_path)
|
|
173
|
+
except OSError as exc:
|
|
174
|
+
print(f"error: cannot read list: {exc}",
|
|
175
|
+
file=sys.stderr)
|
|
176
|
+
return 2
|
|
177
|
+
target = f"list:{args.list_path}"
|
|
178
|
+
else:
|
|
179
|
+
domain = args.domain.strip().lower().rstrip(".")
|
|
180
|
+
try:
|
|
181
|
+
subdomains = fetch_crtsh(domain)
|
|
182
|
+
except EnumerationError as exc:
|
|
183
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
184
|
+
return 2
|
|
185
|
+
target = domain
|
|
186
|
+
|
|
187
|
+
results = run_checks(subdomains, delay=args.delay,
|
|
188
|
+
timeout=args.timeout)
|
|
189
|
+
if args.json:
|
|
190
|
+
print(json.dumps({
|
|
191
|
+
"tool": "subdomainchecker",
|
|
192
|
+
"schema_version": 1,
|
|
193
|
+
"version": __version__,
|
|
194
|
+
"target": target,
|
|
195
|
+
"checked": len(results),
|
|
196
|
+
"summary": summarize(results),
|
|
197
|
+
"results": results,
|
|
198
|
+
}, indent=2))
|
|
199
|
+
else:
|
|
200
|
+
print(render_text(target, results))
|
|
201
|
+
counts = summarize(results)
|
|
202
|
+
if counts["VULNERABLE"] or counts["POSSIBLE"]:
|
|
203
|
+
# Findings. If part of the run could not be judged, the
|
|
204
|
+
# findings stand but the evidence base is degraded.
|
|
205
|
+
return 3 if counts["UNCHECKED"] else 1
|
|
206
|
+
if counts["UNCHECKED"]:
|
|
207
|
+
# Nothing found — but not everything could be judged,
|
|
208
|
+
# so this is not a clean pass.
|
|
209
|
+
return 2
|
|
210
|
+
return 0
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def cli() -> None:
|
|
214
|
+
sys.exit(main())
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
cli()
|