SnakeScan 1.7.9__tar.gz → 1.8.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.
- {snakescan-1.7.9 → snakescan-1.8.0}/PKG-INFO +25 -24
- {snakescan-1.7.9 → snakescan-1.8.0}/README.md +24 -23
- {snakescan-1.7.9 → snakescan-1.8.0}/SnakeScan/CLI.py +173 -118
- {snakescan-1.7.9 → snakescan-1.8.0}/SnakeScan/Check_subnet.py +1 -1
- snakescan-1.8.0/SnakeScan/PoolExecutor.py +31 -0
- snakescan-1.8.0/SnakeScan/Pool_UDP_Executor.py +40 -0
- {snakescan-1.7.9 → snakescan-1.8.0}/SnakeScan/__init__.py +7 -3
- {snakescan-1.7.9 → snakescan-1.8.0}/pyproject.toml +0 -1
- snakescan-1.7.9/SnakeScan/PoolExecutor.py +0 -80
- snakescan-1.7.9/SnakeScan/Pool_UDP_Executor.py +0 -84
- {snakescan-1.7.9 → snakescan-1.8.0}/LICENSE +0 -0
- {snakescan-1.7.9 → snakescan-1.8.0}/SnakeScan/Get_ssl.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SnakeScan
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: IPv4 address scanner for collecting address information.Scan or get the IPv4 address from the IPv6 host
|
|
5
5
|
Author: Den*Ram
|
|
6
6
|
Requires-Python: >=3.7
|
|
@@ -12,17 +12,19 @@ Requires-Dist: tqdm
|
|
|
12
12
|
Requires-Dist: termcolor
|
|
13
13
|
|
|
14
14
|
<!--
|
|
15
|
-
|
|
16
15
|
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
17
|
-
|
|
18
16
|
-->
|
|
19
17
|
|
|
20
18
|
# 🐍 SnakeScan: A Robust Python Port Scanner
|
|
21
19
|
|
|
22
20
|
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
21
|
+
|
|
23
22
|
[](https://pypi.org/project/SnakeScan/)
|
|
23
|
+
|
|
24
24
|
[](https://opensource.org/licenses/MIT)
|
|
25
|
+
|
|
25
26
|
[](https://www.python.org/)
|
|
27
|
+
|
|
26
28
|
[](https://img.shields.io/badge/Status-Stable-green)
|
|
27
29
|
|
|
28
30
|
**SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers requiring reliable port scanning capabilities. From basic port verification to advanced, multi-threaded subnet analysis, SnakeScan delivers the tools necessary for effective network assessment.
|
|
@@ -30,69 +32,68 @@ A versatile and efficient Python library designed for comprehensive network port
|
|
|
30
32
|
## ⚙️ Key Features:
|
|
31
33
|
|
|
32
34
|
* **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
|
|
33
|
-
|
|
34
35
|
* **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
35
|
-
|
|
36
36
|
* **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
37
|
-
|
|
38
37
|
* **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
|
|
39
|
-
|
|
40
38
|
* **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
|
|
41
|
-
|
|
42
39
|
* **UDP Port Scanning:** Native support for scanning UDP ports.
|
|
40
|
+
* **JSON Port Definitions:** Load port definitions from JSON files for organized and reusable configurations.
|
|
43
41
|
|
|
44
42
|
## ⬇️ Installation:
|
|
45
43
|
|
|
46
44
|
Install SnakeScan using pip:
|
|
47
45
|
|
|
48
46
|
bash
|
|
49
|
-
|
|
50
47
|
pip install SnakeScan
|
|
51
48
|
|
|
49
|
+
|
|
52
50
|
## ⌨️ Command Line Usage:
|
|
53
51
|
|
|
54
52
|
### 💡 Attribute Reference:
|
|
55
53
|
|
|
56
|
-
* **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound
|
|
57
|
-
|
|
54
|
+
* **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound на первом entry. Example: To scan from port 80 to 443, define the range as `79-443`. Examples: `snake -p 80,443` или `snake -p 80,3437,8080,20-30,79-443`
|
|
58
55
|
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
59
|
-
|
|
60
56
|
* **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
61
|
-
|
|
62
57
|
* **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
63
|
-
|
|
64
58
|
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
65
|
-
|
|
66
59
|
* **-gs**: Retrieve the SSL/TLS certificate from a specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
|
|
67
|
-
|
|
68
60
|
* **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
|
|
69
|
-
|
|
70
61
|
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
71
|
-
|
|
72
62
|
* **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
|
|
73
|
-
|
|
74
63
|
* **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
|
|
64
|
+
* **-d**: Specify the path to a JSON file containing TCP port definitions, and optionally the path to a second JSON file containing UDP port definitions. **Note:** When using this argument, the paths to the JSON files must be provided with each execution of the command, separated by a comma.
|
|
65
|
+
|
|
66
|
+
Example: `snake -d /path/to/tcp_ports.json,/path/to/udp_ports.json` (if you want to specify both TCP and UDP, if only TCP: `snake -d /path/to/tcp_ports.json`)
|
|
67
|
+
|
|
68
|
+
**JSON File Format:** The JSON file should be formatted as a dictionary where the keys are the port numbers (as strings) and the values are the corresponding service names or descriptions.
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"53": "DNS",
|
|
73
|
+
"80": "HTTP",
|
|
74
|
+
"443": "HTTPS"
|
|
75
|
+
}
|
|
76
|
+
```
|
|
75
77
|
|
|
76
78
|
## 💻 Python Code Integration:
|
|
77
79
|
|
|
78
80
|
### ⏱️ Watcher Class: Real-Time Port Status
|
|
79
81
|
|
|
80
|
-
The `Watcher` class
|
|
82
|
+
The `Watcher` class enables continuous monitoring of a specified port.
|
|
81
83
|
|
|
82
84
|
python
|
|
83
|
-
|
|
84
85
|
from SnakeScan import Watcher
|
|
85
86
|
|
|
86
|
-
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
87
87
|
|
|
88
|
+
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
88
89
|
watcher.start() # Begin monitoring!
|
|
89
90
|
|
|
91
|
+
|
|
90
92
|
#### `Watcher` Methods:
|
|
91
93
|
|
|
92
94
|
* `Watcher.start()` - Initiate the port monitoring process.
|
|
93
|
-
|
|
94
95
|
* `Watcher.stop()` - Terminate the port monitoring process.
|
|
95
96
|
|
|
96
97
|
---
|
|
97
98
|
|
|
98
|
-
**Latest Update:** 1.
|
|
99
|
+
**Latest Update:** 1.8.0 (Minor bug fixes and JSON port definition)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
|
|
3
2
|
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
4
|
-
|
|
5
3
|
-->
|
|
6
4
|
|
|
7
5
|
# 🐍 SnakeScan: A Robust Python Port Scanner
|
|
8
6
|
|
|
9
7
|
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
8
|
+
|
|
10
9
|
[](https://pypi.org/project/SnakeScan/)
|
|
10
|
+
|
|
11
11
|
[](https://opensource.org/licenses/MIT)
|
|
12
|
+
|
|
12
13
|
[](https://www.python.org/)
|
|
14
|
+
|
|
13
15
|
[](https://img.shields.io/badge/Status-Stable-green)
|
|
14
16
|
|
|
15
17
|
**SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers requiring reliable port scanning capabilities. From basic port verification to advanced, multi-threaded subnet analysis, SnakeScan delivers the tools necessary for effective network assessment.
|
|
@@ -17,69 +19,68 @@ A versatile and efficient Python library designed for comprehensive network port
|
|
|
17
19
|
## ⚙️ Key Features:
|
|
18
20
|
|
|
19
21
|
* **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
|
|
20
|
-
|
|
21
22
|
* **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
22
|
-
|
|
23
23
|
* **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
24
|
-
|
|
25
24
|
* **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
|
|
26
|
-
|
|
27
25
|
* **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
|
|
28
|
-
|
|
29
26
|
* **UDP Port Scanning:** Native support for scanning UDP ports.
|
|
27
|
+
* **JSON Port Definitions:** Load port definitions from JSON files for organized and reusable configurations.
|
|
30
28
|
|
|
31
29
|
## ⬇️ Installation:
|
|
32
30
|
|
|
33
31
|
Install SnakeScan using pip:
|
|
34
32
|
|
|
35
33
|
bash
|
|
36
|
-
|
|
37
34
|
pip install SnakeScan
|
|
38
35
|
|
|
36
|
+
|
|
39
37
|
## ⌨️ Command Line Usage:
|
|
40
38
|
|
|
41
39
|
### 💡 Attribute Reference:
|
|
42
40
|
|
|
43
|
-
* **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound
|
|
44
|
-
|
|
41
|
+
* **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound на первом entry. Example: To scan from port 80 to 443, define the range as `79-443`. Examples: `snake -p 80,443` или `snake -p 80,3437,8080,20-30,79-443`
|
|
45
42
|
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
46
|
-
|
|
47
43
|
* **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
48
|
-
|
|
49
44
|
* **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
50
|
-
|
|
51
45
|
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
52
|
-
|
|
53
46
|
* **-gs**: Retrieve the SSL/TLS certificate from a specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
|
|
54
|
-
|
|
55
47
|
* **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
|
|
56
|
-
|
|
57
48
|
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
58
|
-
|
|
59
49
|
* **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
|
|
60
|
-
|
|
61
50
|
* **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
|
|
51
|
+
* **-d**: Specify the path to a JSON file containing TCP port definitions, and optionally the path to a second JSON file containing UDP port definitions. **Note:** When using this argument, the paths to the JSON files must be provided with each execution of the command, separated by a comma.
|
|
52
|
+
|
|
53
|
+
Example: `snake -d /path/to/tcp_ports.json,/path/to/udp_ports.json` (if you want to specify both TCP and UDP, if only TCP: `snake -d /path/to/tcp_ports.json`)
|
|
54
|
+
|
|
55
|
+
**JSON File Format:** The JSON file should be formatted as a dictionary where the keys are the port numbers (as strings) and the values are the corresponding service names or descriptions.
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"53": "DNS",
|
|
60
|
+
"80": "HTTP",
|
|
61
|
+
"443": "HTTPS"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
62
64
|
|
|
63
65
|
## 💻 Python Code Integration:
|
|
64
66
|
|
|
65
67
|
### ⏱️ Watcher Class: Real-Time Port Status
|
|
66
68
|
|
|
67
|
-
The `Watcher` class
|
|
69
|
+
The `Watcher` class enables continuous monitoring of a specified port.
|
|
68
70
|
|
|
69
71
|
python
|
|
70
|
-
|
|
71
72
|
from SnakeScan import Watcher
|
|
72
73
|
|
|
73
|
-
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
74
74
|
|
|
75
|
+
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
75
76
|
watcher.start() # Begin monitoring!
|
|
76
77
|
|
|
78
|
+
|
|
77
79
|
#### `Watcher` Methods:
|
|
78
80
|
|
|
79
81
|
* `Watcher.start()` - Initiate the port monitoring process.
|
|
80
|
-
|
|
81
82
|
* `Watcher.stop()` - Terminate the port monitoring process.
|
|
82
83
|
|
|
83
84
|
---
|
|
84
85
|
|
|
85
|
-
**Latest Update:** 1.
|
|
86
|
+
**Latest Update:** 1.8.0 (Minor bug fixes and JSON port definition)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
1
3
|
import sys
|
|
2
4
|
import string
|
|
3
5
|
import argparse
|
|
@@ -13,13 +15,8 @@ from SnakeScan.PoolExecutor import PoolProcessExecutor
|
|
|
13
15
|
from SnakeScan.Get_ssl import Get_ssl
|
|
14
16
|
from SnakeScan.Pool_UDP_Executor import PoolExecutorUDP
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
pass
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if __name__ == "__main__":
|
|
22
|
-
main()
|
|
18
|
+
ports_tcp = False
|
|
19
|
+
ports_udp = False
|
|
23
20
|
OpenPorts = []
|
|
24
21
|
threads = []
|
|
25
22
|
portsopen = 0
|
|
@@ -74,7 +71,34 @@ ports = {
|
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
def main():
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def load_json_config(filepath):
|
|
79
|
+
try:
|
|
80
|
+
if not os.path.isabs(filepath):
|
|
81
|
+
filepath = os.path.abspath(filepath)
|
|
82
|
+
|
|
83
|
+
with open(filepath, "r", encoding="utf-8") as f:
|
|
84
|
+
ports = json.load(f)
|
|
85
|
+
return {int(k): v for k, v in ports.items()}
|
|
86
|
+
except FileNotFoundError:
|
|
87
|
+
print(f"Error: File not found: {filepath}")
|
|
88
|
+
return None
|
|
89
|
+
except json.JSONDecodeError as e:
|
|
90
|
+
print(f"Error: Invalid JSON format in file: {filepath} - {e}")
|
|
91
|
+
return None
|
|
92
|
+
except Exception as e:
|
|
93
|
+
print(f"Error loading file: {e}")
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
main()
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
version = "1.8.0"
|
|
78
102
|
|
|
79
103
|
|
|
80
104
|
def is_port_open(host, port):
|
|
@@ -138,6 +162,13 @@ def SnakeArgs():
|
|
|
138
162
|
description="SnakeScan - It's a command line library for scan and get information about ip."
|
|
139
163
|
)
|
|
140
164
|
parser.add_argument("host", nargs="?", default="None")
|
|
165
|
+
parser.add_argument(
|
|
166
|
+
"-d",
|
|
167
|
+
"--dictonary",
|
|
168
|
+
required=False,
|
|
169
|
+
default="None",
|
|
170
|
+
help="Use custom port dictionaries",
|
|
171
|
+
)
|
|
141
172
|
parser.add_argument(
|
|
142
173
|
"-u", "--udp", action="store_true", help="Use UDP ports for scanning"
|
|
143
174
|
)
|
|
@@ -170,8 +201,8 @@ def SnakeArgs():
|
|
|
170
201
|
|
|
171
202
|
|
|
172
203
|
port_user = SnakeArgs().ports
|
|
173
|
-
host = SnakeArgs().host
|
|
174
|
-
|
|
204
|
+
host = SnakeArgs().host.split(",")
|
|
205
|
+
filepath = SnakeArgs().dictonary.split(",")
|
|
175
206
|
for n in range(len(host)):
|
|
176
207
|
if host[n].startswith("http://"):
|
|
177
208
|
host[n] = host[n].strip()
|
|
@@ -194,6 +225,12 @@ for n in range(len(host)):
|
|
|
194
225
|
host[n] = host[n][0:i]
|
|
195
226
|
if host[0] == "None":
|
|
196
227
|
host[0] = "localhost"
|
|
228
|
+
if filepath[0] != "None":
|
|
229
|
+
if len(filepath) >= 2:
|
|
230
|
+
ports_tcp = load_json_config(filepath[0])
|
|
231
|
+
ports_udp = load_json_config(filepath[1])
|
|
232
|
+
else:
|
|
233
|
+
ports_tcp = load_json_config(filepath[0])
|
|
197
234
|
if SnakeArgs().udp:
|
|
198
235
|
|
|
199
236
|
def is_port_open(host, port, timeout=1):
|
|
@@ -218,10 +255,8 @@ if SnakeArgs().udp:
|
|
|
218
255
|
return is_open
|
|
219
256
|
|
|
220
257
|
except socket.gaierror:
|
|
221
|
-
print("Error: Unable to resolve host name.")
|
|
222
258
|
return None
|
|
223
259
|
except socket.error as e:
|
|
224
|
-
print(f"Socket error: {e}")
|
|
225
260
|
return False
|
|
226
261
|
|
|
227
262
|
def is_port_open_threads(host, port, timeout=1):
|
|
@@ -237,112 +272,118 @@ if SnakeArgs().udp:
|
|
|
237
272
|
data, server = sock.recvfrom(4096)
|
|
238
273
|
print(f"Response received: {data.decode()} from {server}")
|
|
239
274
|
print(
|
|
240
|
-
f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}
|
|
275
|
+
f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
|
|
241
276
|
)
|
|
242
277
|
except socket.timeout:
|
|
243
278
|
print(
|
|
244
|
-
f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}
|
|
279
|
+
f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
|
|
245
280
|
)
|
|
246
281
|
except ConnectionRefusedError:
|
|
247
|
-
|
|
248
|
-
sock.close()
|
|
282
|
+
sock.close()
|
|
249
283
|
except socket.gaierror:
|
|
250
|
-
|
|
284
|
+
pass
|
|
251
285
|
except socket.error as e:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
286
|
+
pass
|
|
287
|
+
|
|
288
|
+
if ports_udp:
|
|
289
|
+
ports = ports_udp
|
|
290
|
+
else:
|
|
291
|
+
ports = {
|
|
292
|
+
7: "ECHO",
|
|
293
|
+
9: "DISCARD",
|
|
294
|
+
13: "DAYTIME",
|
|
295
|
+
17: "QOTD (Quote of the Day)",
|
|
296
|
+
19: "CHARGEN (Character Generator)",
|
|
297
|
+
53: "DNS (Domain Name System)",
|
|
298
|
+
67: "DHCP Server",
|
|
299
|
+
68: "DHCP Client",
|
|
300
|
+
69: "TFTP (Trivial File Transfer Protocol)",
|
|
301
|
+
111: "RPC (Remote Procedure Call)",
|
|
302
|
+
123: "NTP (Network Time Protocol)",
|
|
303
|
+
137: "NetBIOS Name Service",
|
|
304
|
+
138: "NetBIOS Datagram Service",
|
|
305
|
+
161: "SNMP (Simple Network Management Protocol)",
|
|
306
|
+
162: "SNMP Trap",
|
|
307
|
+
443: "QUIC (Quick UDP Internet Connections)",
|
|
308
|
+
500: "ISAKMP (Internet Security Association and Key Management Protocol)",
|
|
309
|
+
520: "RIP (Routing Information Protocol)",
|
|
310
|
+
1434: "Microsoft SQL Server Dynamic Port Allocation",
|
|
311
|
+
4500: "IPsec NAT-Traversal (NAT-T)",
|
|
312
|
+
5353: "mDNS (Multicast DNS)",
|
|
313
|
+
5355: "LLMNR (Link-Local Multicast Name Resolution)",
|
|
314
|
+
1900: "SSDP (Simple Service Discovery Protocol)",
|
|
315
|
+
3478: "STUN (Session Traversal Utilities for NAT)",
|
|
316
|
+
5060: "SIP (Session Initiation Protocol)",
|
|
317
|
+
5061: "SIP (Session Initiation Protocol) (TLS)",
|
|
318
|
+
20777: "Garmin Training Center",
|
|
319
|
+
3074: "Xbox Live",
|
|
320
|
+
3479: "TURN (Traversal Using Relays around NAT)",
|
|
321
|
+
4126: "Muon",
|
|
322
|
+
50000: "Drone (Drone Protocol)",
|
|
323
|
+
60000: "RDP (Remote Desktop Protocol) over UDP",
|
|
324
|
+
5000: "fCoE (Fibre Channel over Ethernet)",
|
|
325
|
+
5001: "HP OpenView Operations Agent",
|
|
326
|
+
1719: "H.323 Gatekeeper RAS",
|
|
327
|
+
1720: "H.323 Call Signaling",
|
|
328
|
+
1812: "RADIUS authentication",
|
|
329
|
+
1813: "RADIUS accounting",
|
|
330
|
+
5222: "XMPP client connection",
|
|
331
|
+
5269: "XMPP server connection",
|
|
332
|
+
}
|
|
296
333
|
|
|
297
334
|
else:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
335
|
+
if ports_tcp:
|
|
336
|
+
ports = ports_tcp
|
|
337
|
+
else:
|
|
338
|
+
ports = {
|
|
339
|
+
20: "FTP-Data",
|
|
340
|
+
21: "FTP-Control",
|
|
341
|
+
22: "SSH",
|
|
342
|
+
23: "Telnet",
|
|
343
|
+
25: "SMTP",
|
|
344
|
+
43: "Whois",
|
|
345
|
+
53: "DNS",
|
|
346
|
+
70: "Gopher",
|
|
347
|
+
79: "FINGER",
|
|
348
|
+
80: "HTTP",
|
|
349
|
+
110: "POP3",
|
|
350
|
+
111: "RPC",
|
|
351
|
+
113: "ident",
|
|
352
|
+
115: "SFTP",
|
|
353
|
+
135: "MSRPC",
|
|
354
|
+
139: "NetBIOS-SSN",
|
|
355
|
+
143: "IMAP",
|
|
356
|
+
179: "BGP",
|
|
357
|
+
194: "IRC",
|
|
358
|
+
389: "LDAP",
|
|
359
|
+
443: "HTTPS",
|
|
360
|
+
445: "SMB",
|
|
361
|
+
465: "SMTPS",
|
|
362
|
+
587: "SMTP Submission",
|
|
363
|
+
631: "IPP",
|
|
364
|
+
636: "LDAPS",
|
|
365
|
+
873: "RSYNC",
|
|
366
|
+
993: "IMAPS",
|
|
367
|
+
995: "POP3S",
|
|
368
|
+
1080: "SOCKS",
|
|
369
|
+
1433: "SQL Server",
|
|
370
|
+
1521: "Oracle",
|
|
371
|
+
2082: "CPanel",
|
|
372
|
+
2083: "CPanel",
|
|
373
|
+
2222: "SSH",
|
|
374
|
+
3128: "HTTP Proxy",
|
|
375
|
+
3306: "MySQL",
|
|
376
|
+
3389: "RDP",
|
|
377
|
+
5432: "PostgreSQL",
|
|
378
|
+
5900: "VNC",
|
|
379
|
+
8000: "HTTP Alternate",
|
|
380
|
+
8080: "HTTP Alternate",
|
|
381
|
+
8443: "HTTPS Alternate",
|
|
382
|
+
8888: "HTTP Alternate",
|
|
383
|
+
10000: "Webmin",
|
|
384
|
+
27017: "MongoDB",
|
|
385
|
+
}
|
|
386
|
+
|
|
346
387
|
|
|
347
388
|
if SnakeArgs().ports:
|
|
348
389
|
rangeports, port_user = Ports(port_user)
|
|
@@ -388,14 +429,14 @@ if SnakeArgs().ports:
|
|
|
388
429
|
if OpenPorts:
|
|
389
430
|
for i in OpenPorts:
|
|
390
431
|
print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
|
|
391
|
-
print(f"{
|
|
432
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
392
433
|
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
393
434
|
portsclosed = 0
|
|
394
435
|
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
395
436
|
portsopen = 0
|
|
396
437
|
print("—" * 60)
|
|
397
438
|
else:
|
|
398
|
-
print(f"{
|
|
439
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
399
440
|
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
400
441
|
portsclosed = 0
|
|
401
442
|
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
@@ -422,7 +463,7 @@ if SnakeArgs().info:
|
|
|
422
463
|
if host[0] == "None":
|
|
423
464
|
host[0] = "localhost"
|
|
424
465
|
for n in range(len(host)):
|
|
425
|
-
print(f"{
|
|
466
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
426
467
|
try:
|
|
427
468
|
host[n] = socket.gethostbyname(host[n])
|
|
428
469
|
except Exception as e:
|
|
@@ -498,8 +539,16 @@ if SnakeArgs().info:
|
|
|
498
539
|
|
|
499
540
|
|
|
500
541
|
if SnakeArgs().thread:
|
|
542
|
+
if SnakeArgs().udp:
|
|
543
|
+
try:
|
|
544
|
+
host[n] = socket.gethostbyname(host[n])
|
|
545
|
+
except Exception as e:
|
|
546
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
547
|
+
print(e)
|
|
548
|
+
sys.exit()
|
|
549
|
+
|
|
501
550
|
for n in range(len(host)):
|
|
502
|
-
print(f"{
|
|
551
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
503
552
|
|
|
504
553
|
for port in ports.keys():
|
|
505
554
|
t = Thread(
|
|
@@ -514,15 +563,21 @@ if SnakeArgs().version:
|
|
|
514
563
|
print(f"SnakeScan_Build_{version}")
|
|
515
564
|
if SnakeArgs().speed:
|
|
516
565
|
if SnakeArgs().udp:
|
|
566
|
+
try:
|
|
567
|
+
host[n] = socket.gethostbyname(host[n])
|
|
568
|
+
except Exception as e:
|
|
569
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
570
|
+
print(e)
|
|
571
|
+
sys.exit()
|
|
517
572
|
for n in range(len(host)):
|
|
518
|
-
print(f"{
|
|
519
|
-
PoolExecutorUDP(host[n])
|
|
573
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
574
|
+
PoolExecutorUDP(host[n], ports)
|
|
520
575
|
sys.exit()
|
|
521
576
|
for n in range(len(host)):
|
|
522
|
-
print(f"{
|
|
523
|
-
PoolProcessExecutor(host[n])
|
|
577
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
578
|
+
PoolProcessExecutor(host[n], ports)
|
|
524
579
|
if SnakeArgs().getssl:
|
|
525
580
|
for n in range(len(host)):
|
|
526
|
-
print(f"{
|
|
581
|
+
print(f"|{host[n]}|".center(60, "—"))
|
|
527
582
|
Get_ssl(host[n])
|
|
528
583
|
print("".center(60, "—"))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
from termcolor import colored
|
|
3
|
+
from concurrent.futures import ProcessPoolExecutor
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def is_port_open_threads(host, port, ports):
|
|
7
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
8
|
+
try:
|
|
9
|
+
s.settimeout(1)
|
|
10
|
+
s.connect((host, port))
|
|
11
|
+
except (OSError, socket.timeout):
|
|
12
|
+
try:
|
|
13
|
+
print(
|
|
14
|
+
f"Closed{colored('|X|','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
|
|
15
|
+
)
|
|
16
|
+
except:
|
|
17
|
+
print(f"Closed{colored('|X|','red')}-->{colored(f'|{port}|','red')}")
|
|
18
|
+
else:
|
|
19
|
+
print(
|
|
20
|
+
f"Open{colored('|√|','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def PoolProcessExecutor(host, ports):
|
|
25
|
+
with ProcessPoolExecutor(max_workers=None) as executor:
|
|
26
|
+
try:
|
|
27
|
+
for port in ports.keys():
|
|
28
|
+
future = executor.submit(is_port_open_threads, host, port, ports)
|
|
29
|
+
|
|
30
|
+
except Exception as e:
|
|
31
|
+
print(e)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import socket
|
|
2
|
+
from termcolor import colored
|
|
3
|
+
from concurrent.futures import ProcessPoolExecutor
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def is_port_open_threads(host, port, ports, timeout=1):
|
|
7
|
+
try:
|
|
8
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
9
|
+
sock.settimeout(timeout)
|
|
10
|
+
message = b"Test UDP packet"
|
|
11
|
+
address = (host, port)
|
|
12
|
+
|
|
13
|
+
sock.sendto(message, address)
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
data, server = sock.recvfrom(4096)
|
|
17
|
+
print(f"Response received: {data.decode()} from {server}")
|
|
18
|
+
print(
|
|
19
|
+
f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
|
|
20
|
+
)
|
|
21
|
+
except socket.timeout:
|
|
22
|
+
print(
|
|
23
|
+
f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
|
|
24
|
+
)
|
|
25
|
+
except ConnectionRefusedError:
|
|
26
|
+
sock.close()
|
|
27
|
+
except socket.gaierror:
|
|
28
|
+
pass
|
|
29
|
+
except socket.error as e:
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def PoolExecutorUDP(host, ports):
|
|
34
|
+
with ProcessPoolExecutor(max_workers=None) as executor:
|
|
35
|
+
try:
|
|
36
|
+
for port in ports.keys():
|
|
37
|
+
future = executor.submit(is_port_open_threads, host, port, ports)
|
|
38
|
+
|
|
39
|
+
except Exception as e:
|
|
40
|
+
print(e)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""IPv4 address scanner for collecting address information.Scan or get the IPv4 address from the IPv6 host"""
|
|
2
2
|
|
|
3
|
-
__version__ = "1.
|
|
3
|
+
__version__ = "1.8.0"
|
|
4
4
|
import socket
|
|
5
5
|
from time import sleep
|
|
6
6
|
from termcolor import colored
|
|
@@ -24,9 +24,13 @@ class Watcher:
|
|
|
24
24
|
connection = sock.connect_ex((self.host, self.port_user))
|
|
25
25
|
if previous != connection:
|
|
26
26
|
if connection == 0:
|
|
27
|
-
print(
|
|
27
|
+
print(
|
|
28
|
+
f"{colored(f'Service is up {self.host}-->|{self.port_user}|','light_green')}"
|
|
29
|
+
)
|
|
28
30
|
else:
|
|
29
|
-
print(
|
|
31
|
+
print(
|
|
32
|
+
f"{colored(f'Service is down {self.host}-->|{self.port_user}|','light_red')}"
|
|
33
|
+
)
|
|
30
34
|
previous = connection
|
|
31
35
|
except Exception as e:
|
|
32
36
|
print(f"Unable to create scanner object:{e}")
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import socket
|
|
2
|
-
from termcolor import colored
|
|
3
|
-
from concurrent.futures import ProcessPoolExecutor
|
|
4
|
-
|
|
5
|
-
ports = {
|
|
6
|
-
20: "FTP-Data",
|
|
7
|
-
21: "FTP-Control",
|
|
8
|
-
22: "SSH",
|
|
9
|
-
23: "Telnet",
|
|
10
|
-
25: "SMTP",
|
|
11
|
-
43: "Whois",
|
|
12
|
-
53: "DNS",
|
|
13
|
-
70: "Gopher",
|
|
14
|
-
79: "FINGER",
|
|
15
|
-
80: "HTTP",
|
|
16
|
-
110: "POP3",
|
|
17
|
-
111: "RPC",
|
|
18
|
-
113: "ident",
|
|
19
|
-
115: "SFTP",
|
|
20
|
-
135: "MSRPC",
|
|
21
|
-
139: "NetBIOS-SSN",
|
|
22
|
-
143: "IMAP",
|
|
23
|
-
179: "BGP",
|
|
24
|
-
194: "IRC",
|
|
25
|
-
389: "LDAP",
|
|
26
|
-
443: "HTTPS",
|
|
27
|
-
445: "SMB",
|
|
28
|
-
465: "SMTPS",
|
|
29
|
-
587: "SMTP Submission",
|
|
30
|
-
631: "IPP",
|
|
31
|
-
636: "LDAPS",
|
|
32
|
-
873: "RSYNC",
|
|
33
|
-
993: "IMAPS",
|
|
34
|
-
995: "POP3S",
|
|
35
|
-
1080: "SOCKS",
|
|
36
|
-
1433: "SQL Server",
|
|
37
|
-
1521: "Oracle",
|
|
38
|
-
2082: "CPanel",
|
|
39
|
-
2083: "CPanel",
|
|
40
|
-
2222: "SSH",
|
|
41
|
-
3128: "HTTP Proxy",
|
|
42
|
-
3306: "MySQL",
|
|
43
|
-
3389: "RDP",
|
|
44
|
-
5432: "PostgreSQL",
|
|
45
|
-
5900: "VNC",
|
|
46
|
-
8000: "HTTP Alternate",
|
|
47
|
-
8080: "HTTP Alternate",
|
|
48
|
-
8443: "HTTPS Alternate",
|
|
49
|
-
8888: "HTTP Alternate",
|
|
50
|
-
10000: "Webmin",
|
|
51
|
-
27017: "MongoDB",
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def is_port_open_threads(host, port):
|
|
56
|
-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
57
|
-
try:
|
|
58
|
-
s.settimeout(1)
|
|
59
|
-
s.connect((host, port))
|
|
60
|
-
except (OSError, socket.timeout):
|
|
61
|
-
try:
|
|
62
|
-
print(
|
|
63
|
-
f"Closed{colored('|X|','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
|
|
64
|
-
)
|
|
65
|
-
except:
|
|
66
|
-
print(f"Closed{colored('|X|','red')}-->{colored(f'|{port}|','red')}")
|
|
67
|
-
else:
|
|
68
|
-
print(
|
|
69
|
-
f"Open{colored('|√|','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def PoolProcessExecutor(host):
|
|
74
|
-
with ProcessPoolExecutor(max_workers=None) as executor:
|
|
75
|
-
try:
|
|
76
|
-
for port in ports.keys():
|
|
77
|
-
future = executor.submit(is_port_open_threads, host, port)
|
|
78
|
-
|
|
79
|
-
except Exception as e:
|
|
80
|
-
print(e)
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import socket
|
|
2
|
-
from termcolor import colored
|
|
3
|
-
from concurrent.futures import ProcessPoolExecutor
|
|
4
|
-
|
|
5
|
-
ports = {
|
|
6
|
-
7: "ECHO",
|
|
7
|
-
9: "DISCARD",
|
|
8
|
-
13: "DAYTIME",
|
|
9
|
-
17: "QOTD (Quote of the Day)",
|
|
10
|
-
19: "CHARGEN (Character Generator)",
|
|
11
|
-
53: "DNS (Domain Name System)",
|
|
12
|
-
67: "DHCP Server",
|
|
13
|
-
68: "DHCP Client",
|
|
14
|
-
69: "TFTP (Trivial File Transfer Protocol)",
|
|
15
|
-
111: "RPC (Remote Procedure Call)",
|
|
16
|
-
123: "NTP (Network Time Protocol)",
|
|
17
|
-
137: "NetBIOS Name Service",
|
|
18
|
-
138: "NetBIOS Datagram Service",
|
|
19
|
-
161: "SNMP (Simple Network Management Protocol)",
|
|
20
|
-
162: "SNMP Trap",
|
|
21
|
-
443: "QUIC (Quick UDP Internet Connections)",
|
|
22
|
-
500: "ISAKMP (Internet Security Association and Key Management Protocol)",
|
|
23
|
-
520: "RIP (Routing Information Protocol)",
|
|
24
|
-
1434: "Microsoft SQL Server Dynamic Port Allocation",
|
|
25
|
-
4500: "IPsec NAT-Traversal (NAT-T)",
|
|
26
|
-
5353: "mDNS (Multicast DNS)",
|
|
27
|
-
5355: "LLMNR (Link-Local Multicast Name Resolution)",
|
|
28
|
-
1900: "SSDP (Simple Service Discovery Protocol)",
|
|
29
|
-
3478: "STUN (Session Traversal Utilities for NAT)",
|
|
30
|
-
5060: "SIP (Session Initiation Protocol)",
|
|
31
|
-
5061: "SIP (Session Initiation Protocol) (TLS)",
|
|
32
|
-
20777: "Garmin Training Center",
|
|
33
|
-
3074: "Xbox Live",
|
|
34
|
-
3479: "TURN (Traversal Using Relays around NAT)",
|
|
35
|
-
4126: "Muon",
|
|
36
|
-
50000: "Drone (Drone Protocol)",
|
|
37
|
-
60000: "RDP (Remote Desktop Protocol) over UDP",
|
|
38
|
-
5000: "fCoE (Fibre Channel over Ethernet)",
|
|
39
|
-
5001: "HP OpenView Operations Agent",
|
|
40
|
-
1719: "H.323 Gatekeeper RAS",
|
|
41
|
-
1720: "H.323 Call Signaling",
|
|
42
|
-
1812: "RADIUS authentication",
|
|
43
|
-
1813: "RADIUS accounting",
|
|
44
|
-
5222: "XMPP client connection",
|
|
45
|
-
5269: "XMPP server connection",
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def is_port_open_threads(host, port, timeout=1):
|
|
50
|
-
try:
|
|
51
|
-
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
52
|
-
sock.settimeout(timeout)
|
|
53
|
-
message = b"Test UDP packet"
|
|
54
|
-
address = (host, port)
|
|
55
|
-
|
|
56
|
-
sock.sendto(message, address)
|
|
57
|
-
|
|
58
|
-
try:
|
|
59
|
-
data, server = sock.recvfrom(4096)
|
|
60
|
-
print(f"Response received: {data.decode()} from {server}")
|
|
61
|
-
print(
|
|
62
|
-
f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')} may be listening on host"
|
|
63
|
-
)
|
|
64
|
-
except socket.timeout:
|
|
65
|
-
print(
|
|
66
|
-
f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')} is likely closed on host"
|
|
67
|
-
)
|
|
68
|
-
except ConnectionRefusedError:
|
|
69
|
-
print("An error occurred while scanning.")
|
|
70
|
-
sock.close()
|
|
71
|
-
except socket.gaierror:
|
|
72
|
-
print("Error: Unable to resolve host name.")
|
|
73
|
-
except socket.error as e:
|
|
74
|
-
print(f"Socket error: {e}")
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def PoolExecutorUDP(host):
|
|
78
|
-
with ProcessPoolExecutor(max_workers=None) as executor:
|
|
79
|
-
try:
|
|
80
|
-
for port in ports.keys():
|
|
81
|
-
future = executor.submit(is_port_open_threads, host, port)
|
|
82
|
-
|
|
83
|
-
except Exception as e:
|
|
84
|
-
print(e)
|
|
File without changes
|
|
File without changes
|