undergraves 0.1.0__py3-none-any.whl
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.
- undergraves/__init__.py +0 -0
- undergraves/cli.py +62 -0
- undergraves/crawler.py +69 -0
- undergraves/exporter.py +17 -0
- undergraves-0.1.0.dist-info/METADATA +104 -0
- undergraves-0.1.0.dist-info/RECORD +10 -0
- undergraves-0.1.0.dist-info/WHEEL +5 -0
- undergraves-0.1.0.dist-info/entry_points.txt +2 -0
- undergraves-0.1.0.dist-info/licenses/LICENSE +19 -0
- undergraves-0.1.0.dist-info/top_level.txt +1 -0
undergraves/__init__.py
ADDED
|
File without changes
|
undergraves/cli.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from urllib.parse import urlparse
|
|
3
|
+
from undergraves.crawler import crawl
|
|
4
|
+
from undergraves.exporter import save_to_json, save_to_csv
|
|
5
|
+
|
|
6
|
+
VALID_LEVELS = ["T1", "T2", "T3", "T4", "T5"]
|
|
7
|
+
|
|
8
|
+
def is_valid_url(url: str) -> bool:
|
|
9
|
+
try:
|
|
10
|
+
parsed = urlparse(url)
|
|
11
|
+
return bool(parsed.netloc and parsed.scheme in ["http", "https"])
|
|
12
|
+
except Exception:
|
|
13
|
+
return False
|
|
14
|
+
|
|
15
|
+
def run():
|
|
16
|
+
if len(sys.argv) < 2:
|
|
17
|
+
print("Usage: undergraves <URL> [LEVEL]")
|
|
18
|
+
print("Example: undergraves https://example.com T2")
|
|
19
|
+
sys.exit(1)
|
|
20
|
+
|
|
21
|
+
target_url = sys.argv[1]
|
|
22
|
+
|
|
23
|
+
if not target_url.startswith("http://") and not target_url.startswith("https://"):
|
|
24
|
+
target_url = "https://" + target_url
|
|
25
|
+
|
|
26
|
+
if not is_valid_url(target_url):
|
|
27
|
+
print(f"[-] Invalid URL: {target_url}")
|
|
28
|
+
sys.exit(1)
|
|
29
|
+
|
|
30
|
+
user_level = "T3"
|
|
31
|
+
|
|
32
|
+
if len(sys.argv) > 2:
|
|
33
|
+
provided_level = sys.argv[2].upper()
|
|
34
|
+
if provided_level not in VALID_LEVELS:
|
|
35
|
+
print(f"[-] Invalid scan level: {sys.argv[2]}. Allowed: {', '.join(VALID_LEVELS)}")
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
user_level = provided_level
|
|
38
|
+
|
|
39
|
+
print(f"[*] Starting Undergraves scan against {target_url} (Level {user_level})")
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
pages = crawl(target_url, level=user_level)
|
|
43
|
+
|
|
44
|
+
if not pages:
|
|
45
|
+
print("[-] No targets mapped or host unreachable.")
|
|
46
|
+
sys.exit(0)
|
|
47
|
+
|
|
48
|
+
save_to_json(pages, "resultado.json")
|
|
49
|
+
save_to_csv(pages, "resultado.csv")
|
|
50
|
+
|
|
51
|
+
print(f"[+] Scan completed. {len(pages)} endpoints mapped.")
|
|
52
|
+
print("[+] Results saved to 'resultado.json' and 'resultado.csv'.")
|
|
53
|
+
|
|
54
|
+
except KeyboardInterrupt:
|
|
55
|
+
print("\n[-] Scan aborted by user.")
|
|
56
|
+
sys.exit(0)
|
|
57
|
+
except Exception as e:
|
|
58
|
+
print(f"\n[-] Fatal error: {e}")
|
|
59
|
+
sys.exit(1)
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
run()
|
undergraves/crawler.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from bs4 import BeautifulSoup
|
|
3
|
+
from urllib.parse import urljoin, urlparse
|
|
4
|
+
|
|
5
|
+
SCAN_LEVELS = {
|
|
6
|
+
"T1": 50,
|
|
7
|
+
"T2": 200,
|
|
8
|
+
"T3": 500,
|
|
9
|
+
"T4": 2000,
|
|
10
|
+
"T5": None
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
def crawl(url: str, level: str = "T3") -> list:
|
|
14
|
+
max_pages = SCAN_LEVELS.get(level.upper(), 500)
|
|
15
|
+
|
|
16
|
+
visited = set()
|
|
17
|
+
to_visit = [url]
|
|
18
|
+
results = []
|
|
19
|
+
|
|
20
|
+
domain_parse = urlparse(url).netloc
|
|
21
|
+
|
|
22
|
+
headers = {
|
|
23
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
while to_visit:
|
|
27
|
+
if max_pages is not None and len(visited) >= max_pages:
|
|
28
|
+
break
|
|
29
|
+
|
|
30
|
+
current_url = to_visit.pop(0)
|
|
31
|
+
|
|
32
|
+
if current_url in visited:
|
|
33
|
+
continue
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
response = requests.get(current_url, headers=headers, timeout=5)
|
|
37
|
+
|
|
38
|
+
if response.status_code != 200:
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
soup = BeautifulSoup(response.text, "html.parser")
|
|
42
|
+
|
|
43
|
+
except Exception:
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
visited.add(current_url)
|
|
47
|
+
|
|
48
|
+
title_text = soup.title.string.strip() if soup.title and soup.title.string else "N/A"
|
|
49
|
+
|
|
50
|
+
print(f"[200] {current_url} | Title: {title_text}")
|
|
51
|
+
|
|
52
|
+
results.append({
|
|
53
|
+
"url": current_url,
|
|
54
|
+
"title": title_text
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
for link in soup.find_all("a"):
|
|
58
|
+
href = link.get("href")
|
|
59
|
+
|
|
60
|
+
if not href:
|
|
61
|
+
continue
|
|
62
|
+
|
|
63
|
+
href = urljoin(current_url, href)
|
|
64
|
+
href_parse = urlparse(href).netloc
|
|
65
|
+
|
|
66
|
+
if href_parse == domain_parse and href not in visited and href not in to_visit:
|
|
67
|
+
to_visit.append(href)
|
|
68
|
+
|
|
69
|
+
return results
|
undergraves/exporter.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import csv
|
|
3
|
+
|
|
4
|
+
def save_to_json(data: list, filename: str = "resultado.json"):
|
|
5
|
+
with open(filename, "w", encoding="utf-8") as f:
|
|
6
|
+
json.dump(data, f, ensure_ascii=False, indent=4)
|
|
7
|
+
|
|
8
|
+
def save_to_csv(data: list, filename: str = "resultado.csv"):
|
|
9
|
+
if not data:
|
|
10
|
+
return
|
|
11
|
+
|
|
12
|
+
headers = data[0].keys()
|
|
13
|
+
|
|
14
|
+
with open(filename, "w", newline="", encoding="utf-8") as f:
|
|
15
|
+
writer = csv.DictWriter(f, fieldnames=headers)
|
|
16
|
+
writer.writeheader()
|
|
17
|
+
writer.writerows(data)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: undergraves
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Command-line web crawler for domain mapping and endpoint discovery
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: requests>=2.31.0
|
|
9
|
+
Requires-Dist: beautifulsoup4>=4.12.0
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# Undergraves
|
|
13
|
+
|
|
14
|
+
Command-line web crawler for domain mapping and endpoint discovery. Performs breadth-first search (BFS) restricted strictly to the target's base domain, collecting active URLs and page titles in real time.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### Via PyPI
|
|
21
|
+
```bash
|
|
22
|
+
pip install undergraves
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Local Installation (Development)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/GabrielDillDev/undergraves.git
|
|
30
|
+
cd undergraves
|
|
31
|
+
pip install -e .
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
undergraves <URL> [LEVEL]
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If no scan level is provided, **T3** is used by default.
|
|
45
|
+
|
|
46
|
+
### Scan Levels
|
|
47
|
+
|
|
48
|
+
| Level | Page Limit |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| **T1** | 50 |
|
|
51
|
+
| **T2** | 200 |
|
|
52
|
+
| **T3** | 500 *(Default)* |
|
|
53
|
+
| **T4** | 2000 |
|
|
54
|
+
| **T5** | Unlimited |
|
|
55
|
+
|
|
56
|
+
### Examples
|
|
57
|
+
|
|
58
|
+
Default scan (T3 - 500 pages):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
undergraves https://example.com
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Quick scan (T1 - 50 pages):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
undergraves https://example.com T1
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Full scan (T5 - Runs until queue is empty):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
undergraves https://example.com T5
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Output Files
|
|
82
|
+
|
|
83
|
+
Upon completion, the tool automatically generates two files in the current working directory:
|
|
84
|
+
|
|
85
|
+
* `resultado.json`: Array of objects containing `url` and `title`.
|
|
86
|
+
* `resultado.csv`: Table formatted with `URL` and `Title` columns.
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Testing
|
|
91
|
+
|
|
92
|
+
Run the unit test suite using `pytest`:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install pytest
|
|
96
|
+
pytest
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
undergraves/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
undergraves/cli.py,sha256=zUZ0LNL_fd0mHqE-z8a7q7QH-9-VV-WjiUy_SpMHHfk,1898
|
|
3
|
+
undergraves/crawler.py,sha256=neBGwHah--3_uuJlLIYbbK07HlGEamHxzPR4BqEtfvo,1723
|
|
4
|
+
undergraves/exporter.py,sha256=uvVNKP92GsiX_aILnF-SynuuRFr65FsOmv-NkZV4dAQ,519
|
|
5
|
+
undergraves-0.1.0.dist-info/licenses/LICENSE,sha256=cbiXy2wY39x58fpk6gip2vOUcA9o7KGrtNd0EK39JM4,1106
|
|
6
|
+
undergraves-0.1.0.dist-info/METADATA,sha256=xOwa2GSQUKnsCLs3Jg2uYq6bnWRoYsppQ-UulYYoO3s,1759
|
|
7
|
+
undergraves-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
8
|
+
undergraves-0.1.0.dist-info/entry_points.txt,sha256=t7koYKTjGDZKLTWZu9jbF8PhyBhBv4E4LiKrdpcmv-w,52
|
|
9
|
+
undergraves-0.1.0.dist-info/top_level.txt,sha256=SG-Lgb0oKMKTZyHCydXt_U6GMy0APVCmohgYFgMf11o,12
|
|
10
|
+
undergraves-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2026 Gabriel Augusto da Costa Dill
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
undergraves
|