subscout 1.0.0__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.
- subscout-1.0.0/LICENSE +21 -0
- subscout-1.0.0/PKG-INFO +142 -0
- subscout-1.0.0/README.md +109 -0
- subscout-1.0.0/pyproject.toml +58 -0
- subscout-1.0.0/setup.cfg +4 -0
- subscout-1.0.0/src/subscout/__init__.py +3 -0
- subscout-1.0.0/src/subscout/__main__.py +3 -0
- subscout-1.0.0/src/subscout/cli.py +233 -0
- subscout-1.0.0/src/subscout/data/top1000subdomains.txt +1000 -0
- subscout-1.0.0/src/subscout/dns.py +22 -0
- subscout-1.0.0/src/subscout/engine.py +65 -0
- subscout-1.0.0/src/subscout/fileio.py +169 -0
- subscout-1.0.0/src/subscout/ipinfo.py +48 -0
- subscout-1.0.0/src/subscout/livecheck.py +40 -0
- subscout-1.0.0/src/subscout/models.py +18 -0
- subscout-1.0.0/src/subscout/py.typed +0 -0
- subscout-1.0.0/src/subscout/shodan_lookup.py +41 -0
- subscout-1.0.0/src/subscout/sources/__init__.py +1 -0
- subscout-1.0.0/src/subscout/sources/brute.py +33 -0
- subscout-1.0.0/src/subscout/sources/certspotter.py +52 -0
- subscout-1.0.0/src/subscout/sources/virustotal.py +29 -0
- subscout-1.0.0/src/subscout/ui.py +58 -0
- subscout-1.0.0/src/subscout.egg-info/PKG-INFO +142 -0
- subscout-1.0.0/src/subscout.egg-info/SOURCES.txt +27 -0
- subscout-1.0.0/src/subscout.egg-info/dependency_links.txt +1 -0
- subscout-1.0.0/src/subscout.egg-info/entry_points.txt +2 -0
- subscout-1.0.0/src/subscout.egg-info/requires.txt +11 -0
- subscout-1.0.0/src/subscout.egg-info/top_level.txt +1 -0
- subscout-1.0.0/tests/test_core.py +230 -0
subscout-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Waqas Ikram
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
subscout-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: subscout
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Subdomain recon pipeline: discover, check liveness, analyse IPs and query Shodan from one CLI.
|
|
5
|
+
Author: Waqas Ikram
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: subdomain,enumeration,recon,osint,security,dns,shodan,bug-bounty
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Information Technology
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Security
|
|
19
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests>=2.28
|
|
24
|
+
Requires-Dist: tqdm>=4.60
|
|
25
|
+
Requires-Dist: colorama>=0.4
|
|
26
|
+
Requires-Dist: pyfiglet>=0.8
|
|
27
|
+
Provides-Extra: shodan
|
|
28
|
+
Requires-Dist: shodan>=1.28; extra == "shodan"
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.4; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# subscout
|
|
35
|
+
|
|
36
|
+
**Subdomain recon in one pipeline:** discover → check what's live → analyse IPs → look up exposure on Shodan.
|
|
37
|
+
Use it as a single command, as individual steps, or as a Python library. Output is CSV or JSON, so it slots into
|
|
38
|
+
`jq`, `httpx`, cron jobs and CI.
|
|
39
|
+
|
|
40
|
+
> **Use responsibly.** subscout actively probes DNS and HTTP. Only scan domains you own or are authorised to test.
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
$ subscout scan -d example.com -O out/
|
|
44
|
+
[*] Brute-forcing 1000 names against example.com...
|
|
45
|
+
[+] www.example.com 93.184.216.34 [brute,certspotter]
|
|
46
|
+
[+] api.example.com 93.184.216.35 [certspotter]
|
|
47
|
+
[*] Checking 2 subdomain(s) for liveness...
|
|
48
|
+
[✔] 2 live subdomain(s) saved to out/live_subdomains.txt
|
|
49
|
+
[✔] IP results saved to out/ip_results.csv
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Why subscout
|
|
53
|
+
|
|
54
|
+
- **Multiple sources, merged** – wordlist brute-force, CertSpotter (no key), VirusTotal; results de-duplicated, each tagged with the source(s) that found it.
|
|
55
|
+
- **Accurate** – wildcard-DNS detection removes catch-all noise; CertSpotter results are matched on real domain boundaries.
|
|
56
|
+
- **Pipeline-friendly** – `-i -` / `-o -` for stdin/stdout, `csv`/`json`/`jsonl` output (all readable back as input), status output on stderr, documented exit codes.
|
|
57
|
+
- **Useful analysis** – live check, Public/Private IP classification (IPv4 + IPv6), shared-origin detection, Shodan ports & CVEs.
|
|
58
|
+
- **Easy to run anywhere** – `pip`, Docker, GitHub Actions; Python 3.9+; works offline-tested.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install subscout # core
|
|
64
|
+
pip install "subscout[shodan]" # + Shodan support
|
|
65
|
+
# or from source
|
|
66
|
+
pip install .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Docker: `docker build -t subscout . && docker run --rm -v "$PWD:/data" subscout scan -d example.com`
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
subscout enum discover subdomains
|
|
75
|
+
subscout live keep only subdomains that answer over HTTP/HTTPS
|
|
76
|
+
subscout resolve resolve IPs, classify them, find shared origins
|
|
77
|
+
subscout shodan look up public IPs on Shodan
|
|
78
|
+
subscout scan run the full pipeline
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
subscout enum -d example.com # brute-force + CertSpotter (default)
|
|
83
|
+
subscout enum -d example.com -m all -k "$VT_API_KEY" # + VirusTotal
|
|
84
|
+
subscout enum -d example.com -m brute -w words.txt -t 50 # custom wordlist, 50 threads
|
|
85
|
+
|
|
86
|
+
subscout live -i output/results.csv # step by step...
|
|
87
|
+
subscout resolve -i output/live_subdomains.txt
|
|
88
|
+
subscout shodan -i output/ip_results.csv
|
|
89
|
+
|
|
90
|
+
subscout scan -d example.com -O out/ -f json # ...or all at once, as JSON
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run `subscout <command> -h` for every option. More recipes (piping, monitoring for new subdomains, CI, Docker,
|
|
94
|
+
library use) are in **[docs/workflows.md](docs/workflows.md)**.
|
|
95
|
+
|
|
96
|
+
### API keys
|
|
97
|
+
|
|
98
|
+
Set environment variables rather than passing `-k`, so keys stay out of shell history:
|
|
99
|
+
|
|
100
|
+
| Service | Variable |
|
|
101
|
+
|------------|------------------|
|
|
102
|
+
| VirusTotal | `VT_API_KEY` |
|
|
103
|
+
| Shodan | `SHODAN_API_KEY` |
|
|
104
|
+
|
|
105
|
+
### Output
|
|
106
|
+
|
|
107
|
+
Default location is `output/`. Choose a format with `-f csv|json|jsonl` (or by `-o` extension); `-o -` writes to stdout.
|
|
108
|
+
|
|
109
|
+
| Step | File | Fields |
|
|
110
|
+
|-----------|-----------------------|-----------------------------------------------------------|
|
|
111
|
+
| `enum` | `results.<fmt>` | `subdomain`, `ip`, `sources` |
|
|
112
|
+
| `live` | `live_subdomains.txt` | one subdomain per line (`.json`/`.jsonl` with `-f`) |
|
|
113
|
+
| `resolve` | `ip_results.<fmt>` | `subdomain`, `ip`, `type` (Public/Private), `shared_with` |
|
|
114
|
+
| `shodan` | `shodan_results.<fmt>`| `ip`, `open_ports`, `cves` |
|
|
115
|
+
|
|
116
|
+
In CSV, multi-value fields are `;`-separated; in JSON they are real arrays.
|
|
117
|
+
|
|
118
|
+
## Project layout
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
src/subscout/
|
|
122
|
+
cli.py commands and argument parsing
|
|
123
|
+
engine.py runs sources and merges results
|
|
124
|
+
sources/ brute · certspotter · virustotal (add new sources here)
|
|
125
|
+
livecheck.py HTTP/HTTPS liveness
|
|
126
|
+
ipinfo.py IP classification, shared-origin analysis
|
|
127
|
+
shodan_lookup.py Shodan integration
|
|
128
|
+
dns.py · fileio.py · models.py · ui.py
|
|
129
|
+
data/ bundled top-1000 wordlist
|
|
130
|
+
tests/ offline unit tests (DNS and HTTP mocked)
|
|
131
|
+
docs/workflows.md recipes
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Contributing
|
|
135
|
+
|
|
136
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: [SECURITY.md](SECURITY.md). History: [CHANGELOG.md](CHANGELOG.md).
|
|
137
|
+
|
|
138
|
+
## Author
|
|
139
|
+
|
|
140
|
+
Created and maintained by **Waqas Ikram**.
|
|
141
|
+
|
|
142
|
+
Licensed under the [MIT License](LICENSE).
|
subscout-1.0.0/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# subscout
|
|
2
|
+
|
|
3
|
+
**Subdomain recon in one pipeline:** discover → check what's live → analyse IPs → look up exposure on Shodan.
|
|
4
|
+
Use it as a single command, as individual steps, or as a Python library. Output is CSV or JSON, so it slots into
|
|
5
|
+
`jq`, `httpx`, cron jobs and CI.
|
|
6
|
+
|
|
7
|
+
> **Use responsibly.** subscout actively probes DNS and HTTP. Only scan domains you own or are authorised to test.
|
|
8
|
+
|
|
9
|
+
```console
|
|
10
|
+
$ subscout scan -d example.com -O out/
|
|
11
|
+
[*] Brute-forcing 1000 names against example.com...
|
|
12
|
+
[+] www.example.com 93.184.216.34 [brute,certspotter]
|
|
13
|
+
[+] api.example.com 93.184.216.35 [certspotter]
|
|
14
|
+
[*] Checking 2 subdomain(s) for liveness...
|
|
15
|
+
[✔] 2 live subdomain(s) saved to out/live_subdomains.txt
|
|
16
|
+
[✔] IP results saved to out/ip_results.csv
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Why subscout
|
|
20
|
+
|
|
21
|
+
- **Multiple sources, merged** – wordlist brute-force, CertSpotter (no key), VirusTotal; results de-duplicated, each tagged with the source(s) that found it.
|
|
22
|
+
- **Accurate** – wildcard-DNS detection removes catch-all noise; CertSpotter results are matched on real domain boundaries.
|
|
23
|
+
- **Pipeline-friendly** – `-i -` / `-o -` for stdin/stdout, `csv`/`json`/`jsonl` output (all readable back as input), status output on stderr, documented exit codes.
|
|
24
|
+
- **Useful analysis** – live check, Public/Private IP classification (IPv4 + IPv6), shared-origin detection, Shodan ports & CVEs.
|
|
25
|
+
- **Easy to run anywhere** – `pip`, Docker, GitHub Actions; Python 3.9+; works offline-tested.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install subscout # core
|
|
31
|
+
pip install "subscout[shodan]" # + Shodan support
|
|
32
|
+
# or from source
|
|
33
|
+
pip install .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Docker: `docker build -t subscout . && docker run --rm -v "$PWD:/data" subscout scan -d example.com`
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
subscout enum discover subdomains
|
|
42
|
+
subscout live keep only subdomains that answer over HTTP/HTTPS
|
|
43
|
+
subscout resolve resolve IPs, classify them, find shared origins
|
|
44
|
+
subscout shodan look up public IPs on Shodan
|
|
45
|
+
subscout scan run the full pipeline
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
subscout enum -d example.com # brute-force + CertSpotter (default)
|
|
50
|
+
subscout enum -d example.com -m all -k "$VT_API_KEY" # + VirusTotal
|
|
51
|
+
subscout enum -d example.com -m brute -w words.txt -t 50 # custom wordlist, 50 threads
|
|
52
|
+
|
|
53
|
+
subscout live -i output/results.csv # step by step...
|
|
54
|
+
subscout resolve -i output/live_subdomains.txt
|
|
55
|
+
subscout shodan -i output/ip_results.csv
|
|
56
|
+
|
|
57
|
+
subscout scan -d example.com -O out/ -f json # ...or all at once, as JSON
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Run `subscout <command> -h` for every option. More recipes (piping, monitoring for new subdomains, CI, Docker,
|
|
61
|
+
library use) are in **[docs/workflows.md](docs/workflows.md)**.
|
|
62
|
+
|
|
63
|
+
### API keys
|
|
64
|
+
|
|
65
|
+
Set environment variables rather than passing `-k`, so keys stay out of shell history:
|
|
66
|
+
|
|
67
|
+
| Service | Variable |
|
|
68
|
+
|------------|------------------|
|
|
69
|
+
| VirusTotal | `VT_API_KEY` |
|
|
70
|
+
| Shodan | `SHODAN_API_KEY` |
|
|
71
|
+
|
|
72
|
+
### Output
|
|
73
|
+
|
|
74
|
+
Default location is `output/`. Choose a format with `-f csv|json|jsonl` (or by `-o` extension); `-o -` writes to stdout.
|
|
75
|
+
|
|
76
|
+
| Step | File | Fields |
|
|
77
|
+
|-----------|-----------------------|-----------------------------------------------------------|
|
|
78
|
+
| `enum` | `results.<fmt>` | `subdomain`, `ip`, `sources` |
|
|
79
|
+
| `live` | `live_subdomains.txt` | one subdomain per line (`.json`/`.jsonl` with `-f`) |
|
|
80
|
+
| `resolve` | `ip_results.<fmt>` | `subdomain`, `ip`, `type` (Public/Private), `shared_with` |
|
|
81
|
+
| `shodan` | `shodan_results.<fmt>`| `ip`, `open_ports`, `cves` |
|
|
82
|
+
|
|
83
|
+
In CSV, multi-value fields are `;`-separated; in JSON they are real arrays.
|
|
84
|
+
|
|
85
|
+
## Project layout
|
|
86
|
+
|
|
87
|
+
```text
|
|
88
|
+
src/subscout/
|
|
89
|
+
cli.py commands and argument parsing
|
|
90
|
+
engine.py runs sources and merges results
|
|
91
|
+
sources/ brute · certspotter · virustotal (add new sources here)
|
|
92
|
+
livecheck.py HTTP/HTTPS liveness
|
|
93
|
+
ipinfo.py IP classification, shared-origin analysis
|
|
94
|
+
shodan_lookup.py Shodan integration
|
|
95
|
+
dns.py · fileio.py · models.py · ui.py
|
|
96
|
+
data/ bundled top-1000 wordlist
|
|
97
|
+
tests/ offline unit tests (DNS and HTTP mocked)
|
|
98
|
+
docs/workflows.md recipes
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: [SECURITY.md](SECURITY.md). History: [CHANGELOG.md](CHANGELOG.md).
|
|
104
|
+
|
|
105
|
+
## Author
|
|
106
|
+
|
|
107
|
+
Created and maintained by **Waqas Ikram**.
|
|
108
|
+
|
|
109
|
+
Licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "subscout"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Subdomain recon pipeline: discover, check liveness, analyse IPs and query Shodan from one CLI."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Waqas Ikram" }]
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
keywords = ["subdomain", "enumeration", "recon", "osint", "security", "dns", "shodan", "bug-bounty"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Information Technology",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Security",
|
|
27
|
+
"Topic :: Internet :: Name Service (DNS)",
|
|
28
|
+
]
|
|
29
|
+
dependencies = ["requests>=2.28", "tqdm>=4.60", "colorama>=0.4", "pyfiglet>=0.8"]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
shodan = ["shodan>=1.28"]
|
|
33
|
+
dev = ["pytest>=7", "ruff>=0.4"]
|
|
34
|
+
|
|
35
|
+
# Add once the repo is public:
|
|
36
|
+
# [project.urls]
|
|
37
|
+
# Homepage = "https://github.com/<your-username>/subscout"
|
|
38
|
+
# Issues = "https://github.com/<your-username>/subscout/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
subscout = "subscout.cli:main"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["src"]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.package-data]
|
|
47
|
+
subscout = ["data/*.txt", "py.typed"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
line-length = 110
|
|
54
|
+
src = ["src"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
58
|
+
ignore = ["E501"]
|
subscout-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"""Command-line interface: ``subscout {enum,live,resolve,shodan,scan}``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
from importlib import resources
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from subscout import __version__, fileio, ipinfo, livecheck, shodan_lookup, ui
|
|
13
|
+
from subscout.engine import METHODS, enumerate_domain
|
|
14
|
+
from subscout.models import SourceError
|
|
15
|
+
|
|
16
|
+
DEFAULT_OUT = Path("output")
|
|
17
|
+
EXT = {"csv": "csv", "json": "json", "jsonl": "jsonl"}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def default_wordlist() -> Path:
|
|
21
|
+
return Path(str(resources.files("subscout") / "data" / "top1000subdomains.txt"))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _common(p: argparse.ArgumentParser) -> None:
|
|
25
|
+
p.add_argument("-t", "--threads", type=int, default=20, help="worker threads (default: 20)")
|
|
26
|
+
p.add_argument("-v", "--verbose", action="store_true", help="also show failed attempts")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _fmt(p: argparse.ArgumentParser) -> None:
|
|
30
|
+
p.add_argument("-f", "--format", choices=fileio.FORMATS,
|
|
31
|
+
help="output format (default: from the -o extension, else csv)")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
35
|
+
parser = argparse.ArgumentParser(
|
|
36
|
+
prog="subscout",
|
|
37
|
+
description="Subdomain recon pipeline: discover -> live check -> IP analysis -> Shodan. "
|
|
38
|
+
"Only scan domains you own or are authorised to test.",
|
|
39
|
+
epilog="Use '-' as the input/output path to read stdin / write stdout. "
|
|
40
|
+
"Status messages always go to stderr, so pipes stay clean.",
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument("-V", "--version", action="version", version=f"%(prog)s {__version__}")
|
|
43
|
+
# Global flags are accepted both before and after the subcommand.
|
|
44
|
+
glob = argparse.ArgumentParser(add_help=False)
|
|
45
|
+
for target, default in ((parser, False), (glob, argparse.SUPPRESS)):
|
|
46
|
+
target.add_argument("--no-banner", action="store_true", default=default,
|
|
47
|
+
help="don't print the banner")
|
|
48
|
+
target.add_argument("--no-color", action="store_true", default=default,
|
|
49
|
+
help="disable coloured output")
|
|
50
|
+
target.add_argument("-q", "--quiet", action="store_true", default=default,
|
|
51
|
+
help="only print results and errors")
|
|
52
|
+
sub = parser.add_subparsers(dest="command", required=True, metavar="command")
|
|
53
|
+
|
|
54
|
+
p = sub.add_parser("enum", parents=[glob], help="discover subdomains (brute-force / CertSpotter / VirusTotal)")
|
|
55
|
+
p.add_argument("-d", "--domain", required=True, help="target domain, e.g. example.com")
|
|
56
|
+
p.add_argument("-m", "--method", choices=METHODS, default="both",
|
|
57
|
+
help="brute | certspotter | virustotal | both (brute+certspotter, default) | all")
|
|
58
|
+
p.add_argument("-w", "--wordlist", type=Path, help="wordlist for brute-force (default: bundled top-1000)")
|
|
59
|
+
p.add_argument("-o", "--output", type=Path, help="output file or '-' (default: output/results.<fmt>)")
|
|
60
|
+
p.add_argument("-k", "--apikey", default=os.environ.get("VT_API_KEY"),
|
|
61
|
+
help="VirusTotal API key (or set VT_API_KEY)")
|
|
62
|
+
p.add_argument("--no-wildcard-filter", action="store_true", help="keep wildcard-DNS results")
|
|
63
|
+
_fmt(p)
|
|
64
|
+
_common(p)
|
|
65
|
+
p.set_defaults(func=cmd_enum)
|
|
66
|
+
|
|
67
|
+
p = sub.add_parser("live", parents=[glob], help="keep only subdomains that answer over HTTP/HTTPS")
|
|
68
|
+
p.add_argument("-i", "--input", required=True, type=Path, help="subdomain list / results file / '-' for stdin")
|
|
69
|
+
p.add_argument("-o", "--output", type=Path, help="output file or '-' (default: output/live_subdomains.txt)")
|
|
70
|
+
p.add_argument("--timeout", type=float, default=3, help="request timeout in seconds (default: 3)")
|
|
71
|
+
_fmt(p)
|
|
72
|
+
_common(p)
|
|
73
|
+
p.set_defaults(func=cmd_live)
|
|
74
|
+
|
|
75
|
+
p = sub.add_parser("resolve", parents=[glob], help="resolve IPs, classify Public/Private, find shared origins")
|
|
76
|
+
p.add_argument("-i", "--input", required=True, type=Path, help="subdomain list / results file / '-' for stdin")
|
|
77
|
+
p.add_argument("-o", "--output", type=Path, help="output file or '-' (default: output/ip_results.<fmt>)")
|
|
78
|
+
_fmt(p)
|
|
79
|
+
p.set_defaults(func=cmd_resolve)
|
|
80
|
+
|
|
81
|
+
p = sub.add_parser("shodan", parents=[glob], help="look up public IPs on Shodan (open ports, CVEs)")
|
|
82
|
+
p.add_argument("-i", "--input", required=True, type=Path, help="output of 'resolve' / '-' for stdin")
|
|
83
|
+
p.add_argument("-o", "--output", type=Path, help="output file or '-' (default: output/shodan_results.<fmt>)")
|
|
84
|
+
p.add_argument("-k", "--apikey", default=os.environ.get("SHODAN_API_KEY"),
|
|
85
|
+
help="Shodan API key (or set SHODAN_API_KEY)")
|
|
86
|
+
_fmt(p)
|
|
87
|
+
p.set_defaults(func=cmd_shodan)
|
|
88
|
+
|
|
89
|
+
p = sub.add_parser("scan", parents=[glob], help="run the full pipeline: enum -> live -> resolve [-> shodan]")
|
|
90
|
+
p.add_argument("-d", "--domain", required=True)
|
|
91
|
+
p.add_argument("-m", "--method", choices=METHODS, default="both")
|
|
92
|
+
p.add_argument("-w", "--wordlist", type=Path)
|
|
93
|
+
p.add_argument("-O", "--outdir", type=Path, default=DEFAULT_OUT, help="output directory (default: output/)")
|
|
94
|
+
p.add_argument("-k", "--apikey", default=os.environ.get("VT_API_KEY"), help="VirusTotal API key")
|
|
95
|
+
p.add_argument("--shodan-key", default=os.environ.get("SHODAN_API_KEY"),
|
|
96
|
+
help="Shodan API key; enables the Shodan step")
|
|
97
|
+
p.add_argument("--timeout", type=float, default=3)
|
|
98
|
+
p.add_argument("--no-wildcard-filter", action="store_true")
|
|
99
|
+
_fmt(p)
|
|
100
|
+
_common(p)
|
|
101
|
+
p.set_defaults(func=cmd_scan)
|
|
102
|
+
return parser
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# ------------------------------------------------------------------ helpers
|
|
106
|
+
def _target(output: Path | None, default_name: str, fmt: str | None) -> tuple[Path, str]:
|
|
107
|
+
"""Resolve (path, format) for an output; ``default_name`` is like 'results' (extension added)."""
|
|
108
|
+
f = fileio.detect_format(output, fmt)
|
|
109
|
+
return (output if output else DEFAULT_OUT / f"{default_name}.{EXT[f]}"), f
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _saved(what: str, path: Path) -> None:
|
|
113
|
+
if str(path) != fileio.STDIO:
|
|
114
|
+
ui.done(f"{what} saved to {path}")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _live_name(fmt: str) -> str:
|
|
118
|
+
return "live_subdomains.txt" if fmt == "csv" else f"live_subdomains.{EXT[fmt]}"
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _live_target(output: Path | None, fmt: str | None) -> tuple[Path, str]:
|
|
122
|
+
f = fileio.detect_format(output, fmt)
|
|
123
|
+
return (output if output else DEFAULT_OUT / _live_name(f)), f
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# ----------------------------------------------------------------- commands
|
|
127
|
+
def _enum(args: argparse.Namespace, output: Path, fmt: str):
|
|
128
|
+
wl = args.wordlist or default_wordlist()
|
|
129
|
+
words = fileio.read_wordlist(wl) if args.method in ("brute", "both", "all") else []
|
|
130
|
+
findings = enumerate_domain(
|
|
131
|
+
args.domain, args.method, words, threads=args.threads, verbose=args.verbose,
|
|
132
|
+
api_key=args.apikey, filter_wildcard=not args.no_wildcard_filter,
|
|
133
|
+
)
|
|
134
|
+
for f in findings:
|
|
135
|
+
ui.found(f"{f.subdomain:<45} {f.ip or '(unresolved)':<39} [{','.join(sorted(f.sources))}]")
|
|
136
|
+
fileio.write_findings(findings, output, fmt)
|
|
137
|
+
_saved(f"{len(findings)} subdomain(s)", output)
|
|
138
|
+
return findings
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def cmd_enum(args: argparse.Namespace) -> int:
|
|
142
|
+
out, fmt = _target(args.output, "results", args.format)
|
|
143
|
+
_enum(args, out, fmt)
|
|
144
|
+
return 0
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _live(subs: list[str], args: argparse.Namespace, output: Path, fmt: str) -> list[str]:
|
|
148
|
+
ui.info(f"Checking {len(subs)} subdomain(s) for liveness...")
|
|
149
|
+
live = livecheck.filter_live(subs, args.threads, args.timeout, args.verbose)
|
|
150
|
+
fileio.write_lines(live, output, fmt)
|
|
151
|
+
_saved(f"{len(live)} live subdomain(s)", output)
|
|
152
|
+
return live
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def cmd_live(args: argparse.Namespace) -> int:
|
|
156
|
+
out, fmt = _live_target(args.output, args.format)
|
|
157
|
+
_live(fileio.read_subdomains(args.input), args, out, fmt)
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _resolve(subs: list[str], output: Path, fmt: str) -> None:
|
|
162
|
+
rows, by_ip = ipinfo.extract_ips(subs)
|
|
163
|
+
fileio.write_table(fileio.IP_HEADER, ipinfo.shared_rows(rows, by_ip), output, fmt,
|
|
164
|
+
list_cols=["Shared_With"])
|
|
165
|
+
_saved("IP results", output)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def cmd_resolve(args: argparse.Namespace) -> int:
|
|
169
|
+
out, fmt = _target(args.output, "ip_results", args.format)
|
|
170
|
+
_resolve(fileio.read_subdomains(args.input), out, fmt)
|
|
171
|
+
return 0
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def _shodan(ip_file: Path, key: str | None, output: Path, fmt: str) -> int:
|
|
175
|
+
if not key:
|
|
176
|
+
ui.error("Shodan needs an API key (-k/--apikey or SHODAN_API_KEY).")
|
|
177
|
+
return 1
|
|
178
|
+
ips = fileio.read_public_ips(ip_file)
|
|
179
|
+
if not ips:
|
|
180
|
+
ui.warn("No public IPs to look up.")
|
|
181
|
+
return 0
|
|
182
|
+
results = shodan_lookup.lookup(ips, key)
|
|
183
|
+
fileio.write_table(fileio.SHODAN_HEADER, shodan_lookup.to_rows(results), output, fmt,
|
|
184
|
+
list_cols=["Open Ports", "CVEs"])
|
|
185
|
+
_saved("Shodan results", output)
|
|
186
|
+
return 0
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def cmd_shodan(args: argparse.Namespace) -> int:
|
|
190
|
+
out, fmt = _target(args.output, "shodan_results", args.format)
|
|
191
|
+
return _shodan(args.input, args.apikey, out, fmt)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def cmd_scan(args: argparse.Namespace) -> int:
|
|
195
|
+
d: Path = args.outdir
|
|
196
|
+
fmt = args.format or "csv"
|
|
197
|
+
findings = _enum(args, d / f"results.{EXT[fmt]}", fmt)
|
|
198
|
+
if not findings:
|
|
199
|
+
ui.warn("Nothing found; stopping.")
|
|
200
|
+
return 0
|
|
201
|
+
live = _live([f.subdomain for f in findings], args, d / _live_name(fmt), fmt)
|
|
202
|
+
if not live:
|
|
203
|
+
ui.warn("No live subdomains; stopping.")
|
|
204
|
+
return 0
|
|
205
|
+
ip_path = d / f"ip_results.{EXT[fmt]}"
|
|
206
|
+
_resolve(live, ip_path, fmt)
|
|
207
|
+
if args.shodan_key:
|
|
208
|
+
return _shodan(ip_path, args.shodan_key, d / f"shodan_results.{EXT[fmt]}", fmt)
|
|
209
|
+
return 0
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
# --------------------------------------------------------------------- main
|
|
213
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
214
|
+
"""Exit codes: 0 ok, 1 runtime error (bad input, API failure), 2 usage error, 130 interrupted."""
|
|
215
|
+
args = build_parser().parse_args(argv)
|
|
216
|
+
ui.setup(no_color=args.no_color, quiet=args.quiet)
|
|
217
|
+
if not args.no_banner and sys.stderr.isatty():
|
|
218
|
+
ui.banner()
|
|
219
|
+
try:
|
|
220
|
+
return args.func(args)
|
|
221
|
+
except FileNotFoundError as exc:
|
|
222
|
+
ui.error(f"File not found: {exc.filename}")
|
|
223
|
+
return 1
|
|
224
|
+
except (SourceError, ValueError) as exc:
|
|
225
|
+
ui.error(str(exc))
|
|
226
|
+
return 1
|
|
227
|
+
except KeyboardInterrupt:
|
|
228
|
+
ui.error("Interrupted.")
|
|
229
|
+
return 130
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
if __name__ == "__main__":
|
|
233
|
+
sys.exit(main())
|