scopeverifier 0.1.1__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.
- scopeverifier-0.1.1/LICENSE +21 -0
- scopeverifier-0.1.1/PKG-INFO +23 -0
- scopeverifier-0.1.1/README.md +13 -0
- scopeverifier-0.1.1/pyproject.toml +20 -0
- scopeverifier-0.1.1/scopeverifier.egg-info/PKG-INFO +23 -0
- scopeverifier-0.1.1/scopeverifier.egg-info/SOURCES.txt +9 -0
- scopeverifier-0.1.1/scopeverifier.egg-info/dependency_links.txt +1 -0
- scopeverifier-0.1.1/scopeverifier.egg-info/entry_points.txt +2 -0
- scopeverifier-0.1.1/scopeverifier.egg-info/top_level.txt +1 -0
- scopeverifier-0.1.1/scopeverifier.py +120 -0
- scopeverifier-0.1.1/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jan Keuchel
|
|
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.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scopeverifier
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: scopeverifier checks if a list of domains is inside a scope which is defined by a list of IP addresses.
|
|
5
|
+
Author: Jan Keuchel
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# ScopeVerifier
|
|
12
|
+
|
|
13
|
+
`scopeverifier` resolves a list of domains to IPv4 addresses and checks whether the resolved addresses are contained in a provided list of in-scope IPs.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
```bash
|
|
17
|
+
pip install scopeverifier
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
```bash
|
|
22
|
+
scopeverifier --domains domains.txt --ips ip-scope.txt -o results.csv
|
|
23
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# ScopeVerifier
|
|
2
|
+
|
|
3
|
+
`scopeverifier` resolves a list of domains to IPv4 addresses and checks whether the resolved addresses are contained in a provided list of in-scope IPs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
pip install scopeverifier
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
```bash
|
|
12
|
+
scopeverifier --domains domains.txt --ips ip-scope.txt -o results.csv
|
|
13
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scopeverifier"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "scopeverifier checks if a list of domains is inside a scope which is defined by a list of IP addresses."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jan Keuchel" }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
scopeverifier = "scopeverifier:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
py-modules = ["scopeverifier"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scopeverifier
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: scopeverifier checks if a list of domains is inside a scope which is defined by a list of IP addresses.
|
|
5
|
+
Author: Jan Keuchel
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# ScopeVerifier
|
|
12
|
+
|
|
13
|
+
`scopeverifier` resolves a list of domains to IPv4 addresses and checks whether the resolved addresses are contained in a provided list of in-scope IPs.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
```bash
|
|
17
|
+
pip install scopeverifier
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
```bash
|
|
22
|
+
scopeverifier --domains domains.txt --ips ip-scope.txt -o results.csv
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scopeverifier
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import argparse
|
|
3
|
+
import csv
|
|
4
|
+
import ipaddress
|
|
5
|
+
import sys
|
|
6
|
+
import shutil
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
def read_file_into_list(file_path):
|
|
10
|
+
res_list = []
|
|
11
|
+
try:
|
|
12
|
+
with open(file_path, encoding="utf-8") as f:
|
|
13
|
+
for line in f:
|
|
14
|
+
res_list.append(line.strip())
|
|
15
|
+
except Exception as e:
|
|
16
|
+
print(f"Error opening file: '{file_path}': {e}")
|
|
17
|
+
sys.exit(1)
|
|
18
|
+
|
|
19
|
+
return res_list
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_domain_ips(domain):
|
|
23
|
+
if len(domain) == 0:
|
|
24
|
+
return []
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
ip = subprocess.run(["dig", "A", f"{domain}", "+short"],
|
|
28
|
+
capture_output=True,
|
|
29
|
+
text=True,
|
|
30
|
+
timeout=10
|
|
31
|
+
)
|
|
32
|
+
except subprocess.TimeoutExpired:
|
|
33
|
+
print(f"Lookup for '{domain}' timed out.")
|
|
34
|
+
return []
|
|
35
|
+
|
|
36
|
+
if ip.returncode != 0:
|
|
37
|
+
print(f"Error when looking up domain '{domain}'.")
|
|
38
|
+
return []
|
|
39
|
+
if len(ip.stdout.strip()) == 0:
|
|
40
|
+
print(f"The domain '{domain}' didn't resolve to any IP.")
|
|
41
|
+
return []
|
|
42
|
+
|
|
43
|
+
# Convert string which might contain multiple IP addresses
|
|
44
|
+
# and CNAME values separated by '\n' into a list of IP addresses
|
|
45
|
+
ip_list_raw = ip.stdout.strip().split('\n')
|
|
46
|
+
|
|
47
|
+
# Filter out CNAME values
|
|
48
|
+
ip_list = []
|
|
49
|
+
for v in ip_list_raw:
|
|
50
|
+
try:
|
|
51
|
+
ipaddress.ip_address(v)
|
|
52
|
+
ip_list.append(v)
|
|
53
|
+
except Exception:
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
return ip_list
|
|
57
|
+
|
|
58
|
+
def write_data_to_csv(data, out_file):
|
|
59
|
+
print(f"Writing results to {out_file}")
|
|
60
|
+
try:
|
|
61
|
+
with open(out_file, "w", newline="", encoding="utf-8") as csv_file:
|
|
62
|
+
fieldnames = ["domain", "ip", "in_scope"]
|
|
63
|
+
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
|
|
64
|
+
writer.writeheader()
|
|
65
|
+
writer.writerows(data)
|
|
66
|
+
except Exception as _:
|
|
67
|
+
print(f"Writing to '{out_file}' failed.")
|
|
68
|
+
sys.exit(1)
|
|
69
|
+
|
|
70
|
+
def check_requirements():
|
|
71
|
+
if shutil.which("dig") is None:
|
|
72
|
+
print("Error: 'dig' is not installed.")
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
|
|
75
|
+
def main():
|
|
76
|
+
|
|
77
|
+
# --- Configure command line argument parser ---
|
|
78
|
+
parser = argparse.ArgumentParser(description="Verify if a list of domains is inside a scope, defined by a list of IPv4 addresses.")
|
|
79
|
+
parser.add_argument("-d", "--domains",
|
|
80
|
+
type=str,
|
|
81
|
+
required=True,
|
|
82
|
+
help="Path to file with a list of domains to check.")
|
|
83
|
+
|
|
84
|
+
parser.add_argument("-i", "--ips",
|
|
85
|
+
type=str,
|
|
86
|
+
required=True,
|
|
87
|
+
help="Path to file with a list of in-scope IP addresses.")
|
|
88
|
+
|
|
89
|
+
parser.add_argument("-o", "--outfile",
|
|
90
|
+
type=str,
|
|
91
|
+
required=True,
|
|
92
|
+
help="Specify the CSV file to write the data to.")
|
|
93
|
+
|
|
94
|
+
args = parser.parse_args()
|
|
95
|
+
|
|
96
|
+
check_requirements()
|
|
97
|
+
|
|
98
|
+
domains_input = read_file_into_list(args.domains)
|
|
99
|
+
ips_input = set(read_file_into_list(args.ips))
|
|
100
|
+
|
|
101
|
+
data = []
|
|
102
|
+
|
|
103
|
+
print(f"Resolving {len(domains_input)} domains...")
|
|
104
|
+
print("(Delay between requests: 0.5 seconds.)")
|
|
105
|
+
for d in domains_input:
|
|
106
|
+
ips = get_domain_ips(d)
|
|
107
|
+
time.sleep(0.5)
|
|
108
|
+
for ip in ips:
|
|
109
|
+
data.append({
|
|
110
|
+
"domain": d,
|
|
111
|
+
"ip": ip,
|
|
112
|
+
"in_scope": ip in ips_input
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
write_data_to_csv(data, args.outfile)
|
|
116
|
+
print("Finished.")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == '__main__':
|
|
120
|
+
main()
|