SnakeScan 1.8.0__tar.gz → 1.8.3__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.8.3/PKG-INFO +141 -0
- snakescan-1.8.3/README.md +127 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/CLI.py +99 -13
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/__init__.py +2 -2
- snakescan-1.8.3/SnakeScan/config.ini +3 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/pyproject.toml +8 -1
- snakescan-1.8.0/PKG-INFO +0 -99
- snakescan-1.8.0/README.md +0 -86
- {snakescan-1.8.0 → snakescan-1.8.3}/LICENSE +0 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/Check_subnet.py +0 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/Get_ssl.py +0 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/PoolExecutor.py +0 -0
- {snakescan-1.8.0 → snakescan-1.8.3}/SnakeScan/Pool_UDP_Executor.py +0 -0
snakescan-1.8.3/PKG-INFO
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SnakeScan
|
|
3
|
+
Version: 1.8.3
|
|
4
|
+
Summary: Unlock the potential of your network with this powerful IPv4 address scanner. Easily scan IP address ranges, identify active hosts, and even extract IPv4 addresses from IPv6 environments. Enhance your network monitoring, troubleshooting, and security analysis!
|
|
5
|
+
Author: Den*Ram
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: art
|
|
11
|
+
Requires-Dist: tqdm
|
|
12
|
+
Requires-Dist: termcolor
|
|
13
|
+
|
|
14
|
+
<!--
|
|
15
|
+
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
16
|
+
-->
|
|
17
|
+
# 🐍 SnakeScan: Reliable Port Scanner in Python
|
|
18
|
+
|
|
19
|
+
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
20
|
+
|
|
21
|
+
[](https://pypi.org/project/SnakeScan/)
|
|
22
|
+
|
|
23
|
+
[](https://opensource.org/licenses/MIT)
|
|
24
|
+
|
|
25
|
+
[](https://www.python.org/)
|
|
26
|
+
|
|
27
|
+
[](https://img.shields.io/badge/Status-Stable-green)
|
|
28
|
+
|
|
29
|
+
**SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers who need robust port scanning capabilities. From basic port checking to advanced, multi-threaded subnet analysis, SnakeScan provides the tools you need for effective network assessment.
|
|
30
|
+
|
|
31
|
+
**Important Note:** *The following documentation describes potential features that are **partially implemented** in SnakeScan. Functionality related to custom port dictionaries is available, but has **narrowly specialized** implementations in its current state. Descriptions here are intended to demonstrate a more complete implementation and **may not fully match the library's current narrowly specialized capabilities**.*
|
|
32
|
+
|
|
33
|
+
## ⚙️ Key features:
|
|
34
|
+
|
|
35
|
+
* **Flexible port specification:** Define target ports as individual values, ranges, or via pre-configured sets.
|
|
36
|
+
|
|
37
|
+
* **Multi-threaded architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
38
|
+
|
|
39
|
+
* **IP address information retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
40
|
+
|
|
41
|
+
* **Real-time port monitoring:** Use the `Watcher` class to continuously monitor the status of important ports.
|
|
42
|
+
|
|
43
|
+
* **Concise command-line interface and API:** Easily integrate SnakeScan into workflows via command-line or programmatic access.
|
|
44
|
+
|
|
45
|
+
* **UDP port scanning:** Built-in support for scanning UDP ports.
|
|
46
|
+
|
|
47
|
+
* **Customizable port dictionaries:** Add your own port descriptions from JSON files and easily revert to the default set. *(Functionality is present, has narrowly specialized implementations. See details below).*
|
|
48
|
+
|
|
49
|
+
## ⬇️ Installation:
|
|
50
|
+
|
|
51
|
+
Install SnakeScan using pip:
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
bash
|
|
56
|
+
|
|
57
|
+
pip install SnakeScan
|
|
58
|
+
|
|
59
|
+
## ⌨️ Command-line usage:
|
|
60
|
+
|
|
61
|
+
### 💡 Attribute reference:
|
|
62
|
+
|
|
63
|
+
* **-p**: Specify target ports to scan (single port or range). Note: Range excludes the lower bound in the first entry. For example: To scan from port 80 to 443 specify the range as `79-443`. Examples: `snake -p 80,443` or `snake -p 80,3437,8080,20-30,79-443`
|
|
64
|
+
|
|
65
|
+
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
66
|
+
|
|
67
|
+
* **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
68
|
+
|
|
69
|
+
* **-sp**: Start scanning using the predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
70
|
+
|
|
71
|
+
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
72
|
+
|
|
73
|
+
* **-gs**: Retrieve the SSL/TLS certificate from the specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
|
|
74
|
+
|
|
75
|
+
* **-t**: Enable multi-threading to improve scanning performance. Example: `snake -t`
|
|
76
|
+
|
|
77
|
+
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
78
|
+
|
|
79
|
+
* **-l**: Display your public IP address (requires active internet connection). Example: `snake -l`
|
|
80
|
+
|
|
81
|
+
* **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
|
|
82
|
+
|
|
83
|
+
* **-d**: Specify the path to a JSON file containing TCP port definitions, and optionally a path to a second JSON file containing UDP port definitions. **Note:** When using this argument *for the first* time, the paths to the JSON files must be specified with each command execution, separated by a comma. After the first use, SnakeScan *may* remember these paths for subsequent scans. Functionality is present, has narrowly specialized implementations. See details below.
|
|
84
|
+
|
|
85
|
+
Example: `snake -d /путь/к/tcp_ports.json,/путь/к/udp_ports.json` (if you want to specify both TCP and UDP, if TCP only: `snake -d /путь/к/tcp_ports.json`)
|
|
86
|
+
|
|
87
|
+
**Subsequent Use**: After initial use, you can simply use the `-d` flag *without* file paths and SnakeScan *may* use previously defined JSON files. Functionality is present, has narrowly specialized implementations. See details below.
|
|
88
|
+
|
|
89
|
+
Example (after initial setup): `snake -d` (may use previously saved paths)
|
|
90
|
+
|
|
91
|
+
**JSON file format:** The JSON file must be formatted as a dictionary where the keys are port numbers (as strings) and the values are the corresponding service names or descriptions.
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
|
|
97
|
+
"53": "DNS",
|
|
98
|
+
|
|
99
|
+
"80": "HTTP",
|
|
100
|
+
|
|
101
|
+
"443": "HTTPS"
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
* **-dr**: Reset custom port dictionaries to their default state and revert to the standard SnakeScan port definitions. This functionality relies on internal mechanisms that are still under development. Functionality is present, has narrowly specialized implementations. See details below. Example: `snake -dr`
|
|
108
|
+
|
|
109
|
+
## 💻 Python Code Integration:
|
|
110
|
+
|
|
111
|
+
### ⏱️ Watcher class: Real-time port status
|
|
112
|
+
|
|
113
|
+
The `Watcher` class allows you to continuously monitor the specified port.
|
|
114
|
+
|
|
115
|
+
python
|
|
116
|
+
|
|
117
|
+
from SnakeScan import Watcher
|
|
118
|
+
|
|
119
|
+
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
120
|
+
|
|
121
|
+
watcher.start() # Start monitoring!
|
|
122
|
+
|
|
123
|
+
#### `Watcher` Methods:
|
|
124
|
+
|
|
125
|
+
* `Watcher.start()` - Start the port monitoring process.
|
|
126
|
+
|
|
127
|
+
* `Watcher.stop()` - End the port monitoring process.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
**Last updated:** 1.8.1 (Added initial support for custom port dictionaries and standard SnakeScan ports. Note: This functionality is still under development and may exhibit unexpected behavior.) *Functionality is present, has narrowly specialized implementations. See details below.*
|
|
132
|
+
|
|
133
|
+
***
|
|
134
|
+
|
|
135
|
+
**Details on the narrowly specialized functionality of custom port dictionaries:**
|
|
136
|
+
|
|
137
|
+
* The `-d` flag can load port definitions from a JSON file.
|
|
138
|
+
|
|
139
|
+
* The `-dr` flag attempts to revert to the default port definitions.
|
|
140
|
+
|
|
141
|
+
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
3
|
+
-->
|
|
4
|
+
# 🐍 SnakeScan: Reliable Port Scanner in Python
|
|
5
|
+
|
|
6
|
+
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
7
|
+
|
|
8
|
+
[](https://pypi.org/project/SnakeScan/)
|
|
9
|
+
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
[](https://www.python.org/)
|
|
13
|
+
|
|
14
|
+
[](https://img.shields.io/badge/Status-Stable-green)
|
|
15
|
+
|
|
16
|
+
**SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers who need robust port scanning capabilities. From basic port checking to advanced, multi-threaded subnet analysis, SnakeScan provides the tools you need for effective network assessment.
|
|
17
|
+
|
|
18
|
+
**Important Note:** *The following documentation describes potential features that are **partially implemented** in SnakeScan. Functionality related to custom port dictionaries is available, but has **narrowly specialized** implementations in its current state. Descriptions here are intended to demonstrate a more complete implementation and **may not fully match the library's current narrowly specialized capabilities**.*
|
|
19
|
+
|
|
20
|
+
## ⚙️ Key features:
|
|
21
|
+
|
|
22
|
+
* **Flexible port specification:** Define target ports as individual values, ranges, or via pre-configured sets.
|
|
23
|
+
|
|
24
|
+
* **Multi-threaded architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
25
|
+
|
|
26
|
+
* **IP address information retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
27
|
+
|
|
28
|
+
* **Real-time port monitoring:** Use the `Watcher` class to continuously monitor the status of important ports.
|
|
29
|
+
|
|
30
|
+
* **Concise command-line interface and API:** Easily integrate SnakeScan into workflows via command-line or programmatic access.
|
|
31
|
+
|
|
32
|
+
* **UDP port scanning:** Built-in support for scanning UDP ports.
|
|
33
|
+
|
|
34
|
+
* **Customizable port dictionaries:** Add your own port descriptions from JSON files and easily revert to the default set. *(Functionality is present, has narrowly specialized implementations. See details below).*
|
|
35
|
+
|
|
36
|
+
## ⬇️ Installation:
|
|
37
|
+
|
|
38
|
+
Install SnakeScan using pip:
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
bash
|
|
43
|
+
|
|
44
|
+
pip install SnakeScan
|
|
45
|
+
|
|
46
|
+
## ⌨️ Command-line usage:
|
|
47
|
+
|
|
48
|
+
### 💡 Attribute reference:
|
|
49
|
+
|
|
50
|
+
* **-p**: Specify target ports to scan (single port or range). Note: Range excludes the lower bound in the first entry. For example: To scan from port 80 to 443 specify the range as `79-443`. Examples: `snake -p 80,443` or `snake -p 80,3437,8080,20-30,79-443`
|
|
51
|
+
|
|
52
|
+
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
53
|
+
|
|
54
|
+
* **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
55
|
+
|
|
56
|
+
* **-sp**: Start scanning using the predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
57
|
+
|
|
58
|
+
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
59
|
+
|
|
60
|
+
* **-gs**: Retrieve the SSL/TLS certificate from the specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
|
|
61
|
+
|
|
62
|
+
* **-t**: Enable multi-threading to improve scanning performance. Example: `snake -t`
|
|
63
|
+
|
|
64
|
+
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
65
|
+
|
|
66
|
+
* **-l**: Display your public IP address (requires active internet connection). Example: `snake -l`
|
|
67
|
+
|
|
68
|
+
* **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
|
|
69
|
+
|
|
70
|
+
* **-d**: Specify the path to a JSON file containing TCP port definitions, and optionally a path to a second JSON file containing UDP port definitions. **Note:** When using this argument *for the first* time, the paths to the JSON files must be specified with each command execution, separated by a comma. After the first use, SnakeScan *may* remember these paths for subsequent scans. Functionality is present, has narrowly specialized implementations. See details below.
|
|
71
|
+
|
|
72
|
+
Example: `snake -d /путь/к/tcp_ports.json,/путь/к/udp_ports.json` (if you want to specify both TCP and UDP, if TCP only: `snake -d /путь/к/tcp_ports.json`)
|
|
73
|
+
|
|
74
|
+
**Subsequent Use**: After initial use, you can simply use the `-d` flag *without* file paths and SnakeScan *may* use previously defined JSON files. Functionality is present, has narrowly specialized implementations. See details below.
|
|
75
|
+
|
|
76
|
+
Example (after initial setup): `snake -d` (may use previously saved paths)
|
|
77
|
+
|
|
78
|
+
**JSON file format:** The JSON file must be formatted as a dictionary where the keys are port numbers (as strings) and the values are the corresponding service names or descriptions.
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
|
|
84
|
+
"53": "DNS",
|
|
85
|
+
|
|
86
|
+
"80": "HTTP",
|
|
87
|
+
|
|
88
|
+
"443": "HTTPS"
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
* **-dr**: Reset custom port dictionaries to their default state and revert to the standard SnakeScan port definitions. This functionality relies on internal mechanisms that are still under development. Functionality is present, has narrowly specialized implementations. See details below. Example: `snake -dr`
|
|
95
|
+
|
|
96
|
+
## 💻 Python Code Integration:
|
|
97
|
+
|
|
98
|
+
### ⏱️ Watcher class: Real-time port status
|
|
99
|
+
|
|
100
|
+
The `Watcher` class allows you to continuously monitor the specified port.
|
|
101
|
+
|
|
102
|
+
python
|
|
103
|
+
|
|
104
|
+
from SnakeScan import Watcher
|
|
105
|
+
|
|
106
|
+
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
107
|
+
|
|
108
|
+
watcher.start() # Start monitoring!
|
|
109
|
+
|
|
110
|
+
#### `Watcher` Methods:
|
|
111
|
+
|
|
112
|
+
* `Watcher.start()` - Start the port monitoring process.
|
|
113
|
+
|
|
114
|
+
* `Watcher.stop()` - End the port monitoring process.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
**Last updated:** 1.8.1 (Added initial support for custom port dictionaries and standard SnakeScan ports. Note: This functionality is still under development and may exhibit unexpected behavior.) *Functionality is present, has narrowly specialized implementations. See details below.*
|
|
119
|
+
|
|
120
|
+
***
|
|
121
|
+
|
|
122
|
+
**Details on the narrowly specialized functionality of custom port dictionaries:**
|
|
123
|
+
|
|
124
|
+
* The `-d` flag can load port definitions from a JSON file.
|
|
125
|
+
|
|
126
|
+
* The `-dr` flag attempts to revert to the default port definitions.
|
|
127
|
+
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import configparser
|
|
2
3
|
import json
|
|
3
4
|
import sys
|
|
4
5
|
import string
|
|
@@ -15,8 +16,6 @@ from SnakeScan.PoolExecutor import PoolProcessExecutor
|
|
|
15
16
|
from SnakeScan.Get_ssl import Get_ssl
|
|
16
17
|
from SnakeScan.Pool_UDP_Executor import PoolExecutorUDP
|
|
17
18
|
|
|
18
|
-
ports_tcp = False
|
|
19
|
-
ports_udp = False
|
|
20
19
|
OpenPorts = []
|
|
21
20
|
threads = []
|
|
22
21
|
portsopen = 0
|
|
@@ -71,8 +70,51 @@ ports = {
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
|
|
74
|
-
def
|
|
75
|
-
|
|
73
|
+
def Load_config(ports):
|
|
74
|
+
try:
|
|
75
|
+
config = configparser.ConfigParser()
|
|
76
|
+
package_dir = os.path.dirname(__file__)
|
|
77
|
+
|
|
78
|
+
config_path = os.path.join(package_dir, "config.ini")
|
|
79
|
+
|
|
80
|
+
config.read(config_path)
|
|
81
|
+
|
|
82
|
+
if "Settings" in config and ports in config["Settings"]:
|
|
83
|
+
return config["Settings"][ports]
|
|
84
|
+
except Exception as e:
|
|
85
|
+
print(e)
|
|
86
|
+
sys.exit()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def Save_config(path_tcp, path_udp):
|
|
90
|
+
if path_tcp:
|
|
91
|
+
if os.path.exists(path_tcp):
|
|
92
|
+
pass
|
|
93
|
+
else:
|
|
94
|
+
print(f"Error: File not found: {path_tcp}")
|
|
95
|
+
sys.exit()
|
|
96
|
+
else:
|
|
97
|
+
path_tcp = ""
|
|
98
|
+
if path_udp:
|
|
99
|
+
if os.path.exists(path_udp):
|
|
100
|
+
pass
|
|
101
|
+
else:
|
|
102
|
+
print(f"Error: File not found: {path_udp}")
|
|
103
|
+
sys.exit()
|
|
104
|
+
else:
|
|
105
|
+
path_udp = ""
|
|
106
|
+
try:
|
|
107
|
+
config = configparser.ConfigParser()
|
|
108
|
+
package_dir = os.path.dirname(__file__)
|
|
109
|
+
|
|
110
|
+
config_path = os.path.join(package_dir, "config.ini")
|
|
111
|
+
config["Settings"] = {"path_tcp": path_tcp, "path_udp": path_udp}
|
|
112
|
+
with open(config_path, "w") as configfile:
|
|
113
|
+
config.write(configfile)
|
|
114
|
+
|
|
115
|
+
except Exception as e:
|
|
116
|
+
print(e)
|
|
117
|
+
sys.exit()
|
|
76
118
|
|
|
77
119
|
|
|
78
120
|
def load_json_config(filepath):
|
|
@@ -84,21 +126,45 @@ def load_json_config(filepath):
|
|
|
84
126
|
ports = json.load(f)
|
|
85
127
|
return {int(k): v for k, v in ports.items()}
|
|
86
128
|
except FileNotFoundError:
|
|
87
|
-
|
|
88
|
-
|
|
129
|
+
if filepath:
|
|
130
|
+
pass
|
|
131
|
+
else:
|
|
132
|
+
print(f"Error: File not found: {filepath}")
|
|
133
|
+
sys.exit()
|
|
89
134
|
except json.JSONDecodeError as e:
|
|
90
135
|
print(f"Error: Invalid JSON format in file: {filepath} - {e}")
|
|
91
|
-
|
|
136
|
+
sys.exit()
|
|
92
137
|
except Exception as e:
|
|
93
138
|
print(f"Error loading file: {e}")
|
|
94
|
-
|
|
139
|
+
sys.exit()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def main():
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
path_tcp = Load_config("path_tcp")
|
|
147
|
+
path_udp = Load_config("path_udp")
|
|
148
|
+
if path_tcp and path_udp:
|
|
149
|
+
ports_tcp = load_json_config(path_tcp)
|
|
150
|
+
ports_udp = load_json_config(path_udp)
|
|
151
|
+
else:
|
|
152
|
+
ports_tcp = False
|
|
153
|
+
ports_udp = False
|
|
154
|
+
if path_tcp:
|
|
155
|
+
ports_tcp = load_json_config(path_tcp)
|
|
156
|
+
else:
|
|
157
|
+
ports_tcp = False
|
|
158
|
+
if path_udp:
|
|
159
|
+
ports_udp = load_json_config(path_udp)
|
|
160
|
+
else:
|
|
161
|
+
path_udp = False
|
|
95
162
|
|
|
96
163
|
|
|
97
164
|
if __name__ == "__main__":
|
|
98
165
|
main()
|
|
99
166
|
|
|
100
|
-
|
|
101
|
-
version = "1.8.0"
|
|
167
|
+
version = "1.8.3"
|
|
102
168
|
|
|
103
169
|
|
|
104
170
|
def is_port_open(host, port):
|
|
@@ -172,6 +238,12 @@ def SnakeArgs():
|
|
|
172
238
|
parser.add_argument(
|
|
173
239
|
"-u", "--udp", action="store_true", help="Use UDP ports for scanning"
|
|
174
240
|
)
|
|
241
|
+
parser.add_argument(
|
|
242
|
+
"-dr",
|
|
243
|
+
"--dictremove",
|
|
244
|
+
action="store_true",
|
|
245
|
+
help="Removes user port dictionaries",
|
|
246
|
+
)
|
|
175
247
|
parser.add_argument(
|
|
176
248
|
"-gs", "--getssl", action="store_true", help="Get official ssl certificate"
|
|
177
249
|
)
|
|
@@ -229,8 +301,10 @@ if filepath[0] != "None":
|
|
|
229
301
|
if len(filepath) >= 2:
|
|
230
302
|
ports_tcp = load_json_config(filepath[0])
|
|
231
303
|
ports_udp = load_json_config(filepath[1])
|
|
304
|
+
Save_config(filepath[0], filepath[1])
|
|
232
305
|
else:
|
|
233
306
|
ports_tcp = load_json_config(filepath[0])
|
|
307
|
+
Save_config(filepath[0], "")
|
|
234
308
|
if SnakeArgs().udp:
|
|
235
309
|
|
|
236
310
|
def is_port_open(host, port, timeout=1):
|
|
@@ -384,7 +458,17 @@ else:
|
|
|
384
458
|
27017: "MongoDB",
|
|
385
459
|
}
|
|
386
460
|
|
|
387
|
-
|
|
461
|
+
if SnakeArgs().dictremove:
|
|
462
|
+
try:
|
|
463
|
+
config = configparser.ConfigParser()
|
|
464
|
+
package_dir = os.path.dirname(__file__)
|
|
465
|
+
config_path = os.path.join(package_dir, "config.ini")
|
|
466
|
+
config["Settings"] = {"path_tcp": "", "path_udp": ""}
|
|
467
|
+
with open(config_path, "w") as configfile:
|
|
468
|
+
config.write(configfile)
|
|
469
|
+
except Exception as e:
|
|
470
|
+
print(e)
|
|
471
|
+
sys.exit()
|
|
388
472
|
if SnakeArgs().ports:
|
|
389
473
|
rangeports, port_user = Ports(port_user)
|
|
390
474
|
for i in range(len(port_user)):
|
|
@@ -455,10 +539,12 @@ if SnakeArgs().local:
|
|
|
455
539
|
s.connect(("10.255.255.255", 1))
|
|
456
540
|
local = s.getsockname()[0]
|
|
457
541
|
except Exception as e:
|
|
458
|
-
local = f"
|
|
542
|
+
local = f"{e}"
|
|
459
543
|
finally:
|
|
460
544
|
s.close()
|
|
461
|
-
print(
|
|
545
|
+
print("|localhost|".center(60, "—"))
|
|
546
|
+
print(f"Public IP:{local}")
|
|
547
|
+
print(f"".center(60, "—"))
|
|
462
548
|
if SnakeArgs().info:
|
|
463
549
|
if host[0] == "None":
|
|
464
550
|
host[0] = "localhost"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"""IPv4 address scanner
|
|
1
|
+
"""Unlock the potential of your network with this powerful IPv4 address scanner. Easily scan IP address ranges, identify active hosts, and even extract IPv4 addresses from IPv6 environments. Enhance your network monitoring, troubleshooting, and security analysis!"""
|
|
2
2
|
|
|
3
|
-
__version__ = "1.8.
|
|
3
|
+
__version__ = "1.8.3"
|
|
4
4
|
import socket
|
|
5
5
|
from time import sleep
|
|
6
6
|
from termcolor import colored
|
snakescan-1.8.0/PKG-INFO
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: SnakeScan
|
|
3
|
-
Version: 1.8.0
|
|
4
|
-
Summary: IPv4 address scanner for collecting address information.Scan or get the IPv4 address from the IPv6 host
|
|
5
|
-
Author: Den*Ram
|
|
6
|
-
Requires-Python: >=3.7
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
License-Expression: MIT
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: art
|
|
11
|
-
Requires-Dist: tqdm
|
|
12
|
-
Requires-Dist: termcolor
|
|
13
|
-
|
|
14
|
-
<!--
|
|
15
|
-
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
16
|
-
-->
|
|
17
|
-
|
|
18
|
-
# 🐍 SnakeScan: A Robust Python Port Scanner
|
|
19
|
-
|
|
20
|
-
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
21
|
-
|
|
22
|
-
[](https://pypi.org/project/SnakeScan/)
|
|
23
|
-
|
|
24
|
-
[](https://opensource.org/licenses/MIT)
|
|
25
|
-
|
|
26
|
-
[](https://www.python.org/)
|
|
27
|
-
|
|
28
|
-
[](https://img.shields.io/badge/Status-Stable-green)
|
|
29
|
-
|
|
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.
|
|
31
|
-
|
|
32
|
-
## ⚙️ Key Features:
|
|
33
|
-
|
|
34
|
-
* **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
|
|
35
|
-
* **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
36
|
-
* **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
37
|
-
* **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
|
|
38
|
-
* **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
|
|
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.
|
|
41
|
-
|
|
42
|
-
## ⬇️ Installation:
|
|
43
|
-
|
|
44
|
-
Install SnakeScan using pip:
|
|
45
|
-
|
|
46
|
-
bash
|
|
47
|
-
pip install SnakeScan
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## ⌨️ Command Line Usage:
|
|
51
|
-
|
|
52
|
-
### 💡 Attribute Reference:
|
|
53
|
-
|
|
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`
|
|
55
|
-
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
56
|
-
* **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
57
|
-
* **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
58
|
-
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
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.)
|
|
60
|
-
* **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
|
|
61
|
-
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
62
|
-
* **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
|
|
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
|
-
```
|
|
77
|
-
|
|
78
|
-
## 💻 Python Code Integration:
|
|
79
|
-
|
|
80
|
-
### ⏱️ Watcher Class: Real-Time Port Status
|
|
81
|
-
|
|
82
|
-
The `Watcher` class enables continuous monitoring of a specified port.
|
|
83
|
-
|
|
84
|
-
python
|
|
85
|
-
from SnakeScan import Watcher
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
89
|
-
watcher.start() # Begin monitoring!
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
#### `Watcher` Methods:
|
|
93
|
-
|
|
94
|
-
* `Watcher.start()` - Initiate the port monitoring process.
|
|
95
|
-
* `Watcher.stop()` - Terminate the port monitoring process.
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
**Latest Update:** 1.8.0 (Minor bug fixes and JSON port definition)
|
snakescan-1.8.0/README.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
This documentation was created with the assistance of the GeekBot language model and Den*Ram
|
|
3
|
-
-->
|
|
4
|
-
|
|
5
|
-
# 🐍 SnakeScan: A Robust Python Port Scanner
|
|
6
|
-
|
|
7
|
-
A versatile and efficient Python library designed for comprehensive network port scanning.
|
|
8
|
-
|
|
9
|
-
[](https://pypi.org/project/SnakeScan/)
|
|
10
|
-
|
|
11
|
-
[](https://opensource.org/licenses/MIT)
|
|
12
|
-
|
|
13
|
-
[](https://www.python.org/)
|
|
14
|
-
|
|
15
|
-
[](https://img.shields.io/badge/Status-Stable-green)
|
|
16
|
-
|
|
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.
|
|
18
|
-
|
|
19
|
-
## ⚙️ Key Features:
|
|
20
|
-
|
|
21
|
-
* **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
|
|
22
|
-
* **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
|
|
23
|
-
* **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
|
|
24
|
-
* **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
|
|
25
|
-
* **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
|
|
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.
|
|
28
|
-
|
|
29
|
-
## ⬇️ Installation:
|
|
30
|
-
|
|
31
|
-
Install SnakeScan using pip:
|
|
32
|
-
|
|
33
|
-
bash
|
|
34
|
-
pip install SnakeScan
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## ⌨️ Command Line Usage:
|
|
38
|
-
|
|
39
|
-
### 💡 Attribute Reference:
|
|
40
|
-
|
|
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`
|
|
42
|
-
* **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
|
|
43
|
-
* **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
|
|
44
|
-
* **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
|
|
45
|
-
* **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
|
|
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.)
|
|
47
|
-
* **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
|
|
48
|
-
* **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
|
|
49
|
-
* **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
|
|
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
|
-
```
|
|
64
|
-
|
|
65
|
-
## 💻 Python Code Integration:
|
|
66
|
-
|
|
67
|
-
### ⏱️ Watcher Class: Real-Time Port Status
|
|
68
|
-
|
|
69
|
-
The `Watcher` class enables continuous monitoring of a specified port.
|
|
70
|
-
|
|
71
|
-
python
|
|
72
|
-
from SnakeScan import Watcher
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
|
|
76
|
-
watcher.start() # Begin monitoring!
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
#### `Watcher` Methods:
|
|
80
|
-
|
|
81
|
-
* `Watcher.start()` - Initiate the port monitoring process.
|
|
82
|
-
* `Watcher.stop()` - Terminate the port monitoring process.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
**Latest Update:** 1.8.0 (Minor bug fixes and JSON port definition)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|