undergraves 0.1.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.
@@ -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,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,93 @@
1
+ # Undergraves
2
+
3
+ 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.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ### Via PyPI
10
+ ```bash
11
+ pip install undergraves
12
+
13
+ ```
14
+
15
+ ### Local Installation (Development)
16
+
17
+ ```bash
18
+ git clone https://github.com/GabrielDillDev/undergraves.git
19
+ cd undergraves
20
+ pip install -e .
21
+
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Usage
27
+
28
+ ```bash
29
+ undergraves <URL> [LEVEL]
30
+
31
+ ```
32
+
33
+ If no scan level is provided, **T3** is used by default.
34
+
35
+ ### Scan Levels
36
+
37
+ | Level | Page Limit |
38
+ | --- | --- |
39
+ | **T1** | 50 |
40
+ | **T2** | 200 |
41
+ | **T3** | 500 *(Default)* |
42
+ | **T4** | 2000 |
43
+ | **T5** | Unlimited |
44
+
45
+ ### Examples
46
+
47
+ Default scan (T3 - 500 pages):
48
+
49
+ ```bash
50
+ undergraves https://example.com
51
+
52
+ ```
53
+
54
+ Quick scan (T1 - 50 pages):
55
+
56
+ ```bash
57
+ undergraves https://example.com T1
58
+
59
+ ```
60
+
61
+ Full scan (T5 - Runs until queue is empty):
62
+
63
+ ```bash
64
+ undergraves https://example.com T5
65
+
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Output Files
71
+
72
+ Upon completion, the tool automatically generates two files in the current working directory:
73
+
74
+ * `resultado.json`: Array of objects containing `url` and `title`.
75
+ * `resultado.csv`: Table formatted with `URL` and `Title` columns.
76
+
77
+ ---
78
+
79
+ ## Testing
80
+
81
+ Run the unit test suite using `pytest`:
82
+
83
+ ```bash
84
+ pip install pytest
85
+ pytest
86
+
87
+ ```
88
+
89
+ ---
90
+
91
+ ## License
92
+
93
+ MIT
@@ -0,0 +1,17 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "undergraves"
7
+ version = "0.1.0"
8
+ description = "Command-line web crawler for domain mapping and endpoint discovery"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "requests>=2.31.0",
13
+ "beautifulsoup4>=4.12.0"
14
+ ]
15
+
16
+ [project.scripts]
17
+ undergraves = "undergraves.cli:run"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -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()
@@ -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
@@ -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,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/undergraves/__init__.py
5
+ src/undergraves/cli.py
6
+ src/undergraves/crawler.py
7
+ src/undergraves/exporter.py
8
+ src/undergraves.egg-info/PKG-INFO
9
+ src/undergraves.egg-info/SOURCES.txt
10
+ src/undergraves.egg-info/dependency_links.txt
11
+ src/undergraves.egg-info/entry_points.txt
12
+ src/undergraves.egg-info/requires.txt
13
+ src/undergraves.egg-info/top_level.txt
14
+ tests/test_crawler.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ undergraves = undergraves.cli:run
@@ -0,0 +1,2 @@
1
+ requests>=2.31.0
2
+ beautifulsoup4>=4.12.0
@@ -0,0 +1 @@
1
+ undergraves
@@ -0,0 +1,43 @@
1
+ import os
2
+ import json
3
+ import csv
4
+ from undergraves.crawler import SCAN_LEVELS
5
+ from undergraves.cli import is_valid_url
6
+ from undergraves.exporter import save_to_json, save_to_csv
7
+
8
+ def test_scan_levels_configuration():
9
+ assert SCAN_LEVELS["T1"] == 50
10
+ assert SCAN_LEVELS["T2"] == 200
11
+ assert SCAN_LEVELS["T3"] == 500
12
+ assert SCAN_LEVELS["T4"] == 2000
13
+ assert SCAN_LEVELS["T5"] is None
14
+
15
+ def test_url_validation():
16
+ assert is_valid_url("https://example.com") is True
17
+ assert is_valid_url("http://sub.domain.org/path") is True
18
+ assert is_valid_url("not_a_url") is False
19
+ assert is_valid_url("ftp://invalid-scheme.com") is False
20
+
21
+ def test_exporter_json(tmp_path):
22
+ sample_data = [{"url": "https://example.com", "title": "Example"}]
23
+ file_path = tmp_path / "test_output.json"
24
+
25
+ save_to_json(sample_data, str(file_path))
26
+
27
+ assert os.path.exists(file_path)
28
+ with open(file_path, "r", encoding="utf-8") as f:
29
+ data = json.load(f)
30
+ assert data == sample_data
31
+
32
+ def test_exporter_csv(tmp_path):
33
+ sample_data = [{"url": "https://example.com", "title": "Example"}]
34
+ file_path = tmp_path / "test_output.csv"
35
+
36
+ save_to_csv(sample_data, str(file_path))
37
+
38
+ assert os.path.exists(file_path)
39
+ with open(file_path, "r", encoding="utf-8") as f:
40
+ reader = list(csv.DictReader(f))
41
+ assert len(reader) == 1
42
+ assert reader[0]["url"] == "https://example.com"
43
+ assert reader[0]["title"] == "Example"