SnakeScan 1.7.9__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.
@@ -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
+ [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
22
+
23
+ [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
24
+
25
+ [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
26
+
27
+ [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](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
+ [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
9
+
10
+ [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
11
+
12
+ [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
13
+
14
+ [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](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,3 +1,6 @@
1
+ import os
2
+ import configparser
3
+ import json
1
4
  import sys
2
5
  import string
3
6
  import argparse
@@ -13,13 +16,6 @@ from SnakeScan.PoolExecutor import PoolProcessExecutor
13
16
  from SnakeScan.Get_ssl import Get_ssl
14
17
  from SnakeScan.Pool_UDP_Executor import PoolExecutorUDP
15
18
 
16
-
17
- def main():
18
- pass
19
-
20
-
21
- if __name__ == "__main__":
22
- main()
23
19
  OpenPorts = []
24
20
  threads = []
25
21
  portsopen = 0
@@ -74,7 +70,101 @@ ports = {
74
70
  }
75
71
 
76
72
 
77
- version = "1.7.9"
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()
118
+
119
+
120
+ def load_json_config(filepath):
121
+ try:
122
+ if not os.path.isabs(filepath):
123
+ filepath = os.path.abspath(filepath)
124
+
125
+ with open(filepath, "r", encoding="utf-8") as f:
126
+ ports = json.load(f)
127
+ return {int(k): v for k, v in ports.items()}
128
+ except FileNotFoundError:
129
+ if filepath:
130
+ pass
131
+ else:
132
+ print(f"Error: File not found: {filepath}")
133
+ sys.exit()
134
+ except json.JSONDecodeError as e:
135
+ print(f"Error: Invalid JSON format in file: {filepath} - {e}")
136
+ sys.exit()
137
+ except Exception as e:
138
+ print(f"Error loading file: {e}")
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
162
+
163
+
164
+ if __name__ == "__main__":
165
+ main()
166
+
167
+ version = "1.8.3"
78
168
 
79
169
 
80
170
  def is_port_open(host, port):
@@ -138,9 +228,22 @@ def SnakeArgs():
138
228
  description="SnakeScan - It's a command line library for scan and get information about ip."
139
229
  )
140
230
  parser.add_argument("host", nargs="?", default="None")
231
+ parser.add_argument(
232
+ "-d",
233
+ "--dictonary",
234
+ required=False,
235
+ default="None",
236
+ help="Use custom port dictionaries",
237
+ )
141
238
  parser.add_argument(
142
239
  "-u", "--udp", action="store_true", help="Use UDP ports for scanning"
143
240
  )
241
+ parser.add_argument(
242
+ "-dr",
243
+ "--dictremove",
244
+ action="store_true",
245
+ help="Removes user port dictionaries",
246
+ )
144
247
  parser.add_argument(
145
248
  "-gs", "--getssl", action="store_true", help="Get official ssl certificate"
146
249
  )
@@ -170,8 +273,8 @@ def SnakeArgs():
170
273
 
171
274
 
172
275
  port_user = SnakeArgs().ports
173
- host = SnakeArgs().host
174
- host = host.split(",")
276
+ host = SnakeArgs().host.split(",")
277
+ filepath = SnakeArgs().dictonary.split(",")
175
278
  for n in range(len(host)):
176
279
  if host[n].startswith("http://"):
177
280
  host[n] = host[n].strip()
@@ -194,6 +297,14 @@ for n in range(len(host)):
194
297
  host[n] = host[n][0:i]
195
298
  if host[0] == "None":
196
299
  host[0] = "localhost"
300
+ if filepath[0] != "None":
301
+ if len(filepath) >= 2:
302
+ ports_tcp = load_json_config(filepath[0])
303
+ ports_udp = load_json_config(filepath[1])
304
+ Save_config(filepath[0], filepath[1])
305
+ else:
306
+ ports_tcp = load_json_config(filepath[0])
307
+ Save_config(filepath[0], "")
197
308
  if SnakeArgs().udp:
198
309
 
199
310
  def is_port_open(host, port, timeout=1):
@@ -218,10 +329,8 @@ if SnakeArgs().udp:
218
329
  return is_open
219
330
 
220
331
  except socket.gaierror:
221
- print("Error: Unable to resolve host name.")
222
332
  return None
223
333
  except socket.error as e:
224
- print(f"Socket error: {e}")
225
334
  return False
226
335
 
227
336
  def is_port_open_threads(host, port, timeout=1):
@@ -237,113 +346,129 @@ if SnakeArgs().udp:
237
346
  data, server = sock.recvfrom(4096)
238
347
  print(f"Response received: {data.decode()} from {server}")
239
348
  print(
240
- f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')} may be listening on host"
349
+ f"Open{colored('[√]','green')}-->{colored(ports.get(port),'light_green')}{colored(f'|{port}|','green')}"
241
350
  )
242
351
  except socket.timeout:
243
352
  print(
244
- f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')} is likely closed on host"
353
+ f"Closed{colored('[X]','red')}-->{colored(ports.get(port),'light_red')}{colored(f'|{port}|','red')}"
245
354
  )
246
355
  except ConnectionRefusedError:
247
- print("An error occurred while scanning.")
248
- sock.close()
356
+ sock.close()
249
357
  except socket.gaierror:
250
- print("Error: Unable to resolve host name.")
358
+ pass
251
359
  except socket.error as e:
252
- print(f"Socket error: {e}")
253
-
254
- ports = {
255
- 7: "ECHO",
256
- 9: "DISCARD",
257
- 13: "DAYTIME",
258
- 17: "QOTD (Quote of the Day)",
259
- 19: "CHARGEN (Character Generator)",
260
- 53: "DNS (Domain Name System)",
261
- 67: "DHCP Server",
262
- 68: "DHCP Client",
263
- 69: "TFTP (Trivial File Transfer Protocol)",
264
- 111: "RPC (Remote Procedure Call)",
265
- 123: "NTP (Network Time Protocol)",
266
- 137: "NetBIOS Name Service",
267
- 138: "NetBIOS Datagram Service",
268
- 161: "SNMP (Simple Network Management Protocol)",
269
- 162: "SNMP Trap",
270
- 443: "QUIC (Quick UDP Internet Connections)",
271
- 500: "ISAKMP (Internet Security Association and Key Management Protocol)",
272
- 520: "RIP (Routing Information Protocol)",
273
- 1434: "Microsoft SQL Server Dynamic Port Allocation",
274
- 4500: "IPsec NAT-Traversal (NAT-T)",
275
- 5353: "mDNS (Multicast DNS)",
276
- 5355: "LLMNR (Link-Local Multicast Name Resolution)",
277
- 1900: "SSDP (Simple Service Discovery Protocol)",
278
- 3478: "STUN (Session Traversal Utilities for NAT)",
279
- 5060: "SIP (Session Initiation Protocol)",
280
- 5061: "SIP (Session Initiation Protocol) (TLS)",
281
- 20777: "Garmin Training Center",
282
- 3074: "Xbox Live",
283
- 3479: "TURN (Traversal Using Relays around NAT)",
284
- 4126: "Muon",
285
- 50000: "Drone (Drone Protocol)",
286
- 60000: "RDP (Remote Desktop Protocol) over UDP",
287
- 5000: "fCoE (Fibre Channel over Ethernet)",
288
- 5001: "HP OpenView Operations Agent",
289
- 1719: "H.323 Gatekeeper RAS",
290
- 1720: "H.323 Call Signaling",
291
- 1812: "RADIUS authentication",
292
- 1813: "RADIUS accounting",
293
- 5222: "XMPP client connection",
294
- 5269: "XMPP server connection",
295
- }
360
+ pass
361
+
362
+ if ports_udp:
363
+ ports = ports_udp
364
+ else:
365
+ ports = {
366
+ 7: "ECHO",
367
+ 9: "DISCARD",
368
+ 13: "DAYTIME",
369
+ 17: "QOTD (Quote of the Day)",
370
+ 19: "CHARGEN (Character Generator)",
371
+ 53: "DNS (Domain Name System)",
372
+ 67: "DHCP Server",
373
+ 68: "DHCP Client",
374
+ 69: "TFTP (Trivial File Transfer Protocol)",
375
+ 111: "RPC (Remote Procedure Call)",
376
+ 123: "NTP (Network Time Protocol)",
377
+ 137: "NetBIOS Name Service",
378
+ 138: "NetBIOS Datagram Service",
379
+ 161: "SNMP (Simple Network Management Protocol)",
380
+ 162: "SNMP Trap",
381
+ 443: "QUIC (Quick UDP Internet Connections)",
382
+ 500: "ISAKMP (Internet Security Association and Key Management Protocol)",
383
+ 520: "RIP (Routing Information Protocol)",
384
+ 1434: "Microsoft SQL Server Dynamic Port Allocation",
385
+ 4500: "IPsec NAT-Traversal (NAT-T)",
386
+ 5353: "mDNS (Multicast DNS)",
387
+ 5355: "LLMNR (Link-Local Multicast Name Resolution)",
388
+ 1900: "SSDP (Simple Service Discovery Protocol)",
389
+ 3478: "STUN (Session Traversal Utilities for NAT)",
390
+ 5060: "SIP (Session Initiation Protocol)",
391
+ 5061: "SIP (Session Initiation Protocol) (TLS)",
392
+ 20777: "Garmin Training Center",
393
+ 3074: "Xbox Live",
394
+ 3479: "TURN (Traversal Using Relays around NAT)",
395
+ 4126: "Muon",
396
+ 50000: "Drone (Drone Protocol)",
397
+ 60000: "RDP (Remote Desktop Protocol) over UDP",
398
+ 5000: "fCoE (Fibre Channel over Ethernet)",
399
+ 5001: "HP OpenView Operations Agent",
400
+ 1719: "H.323 Gatekeeper RAS",
401
+ 1720: "H.323 Call Signaling",
402
+ 1812: "RADIUS authentication",
403
+ 1813: "RADIUS accounting",
404
+ 5222: "XMPP client connection",
405
+ 5269: "XMPP server connection",
406
+ }
296
407
 
297
408
  else:
298
- ports = {
299
- 20: "FTP-Data",
300
- 21: "FTP-Control",
301
- 22: "SSH",
302
- 23: "Telnet",
303
- 25: "SMTP",
304
- 43: "Whois",
305
- 53: "DNS",
306
- 70: "Gopher",
307
- 79: "FINGER",
308
- 80: "HTTP",
309
- 110: "POP3",
310
- 111: "RPC",
311
- 113: "ident",
312
- 115: "SFTP",
313
- 135: "MSRPC",
314
- 139: "NetBIOS-SSN",
315
- 143: "IMAP",
316
- 179: "BGP",
317
- 194: "IRC",
318
- 389: "LDAP",
319
- 443: "HTTPS",
320
- 445: "SMB",
321
- 465: "SMTPS",
322
- 587: "SMTP Submission",
323
- 631: "IPP",
324
- 636: "LDAPS",
325
- 873: "RSYNC",
326
- 993: "IMAPS",
327
- 995: "POP3S",
328
- 1080: "SOCKS",
329
- 1433: "SQL Server",
330
- 1521: "Oracle",
331
- 2082: "CPanel",
332
- 2083: "CPanel",
333
- 2222: "SSH",
334
- 3128: "HTTP Proxy",
335
- 3306: "MySQL",
336
- 3389: "RDP",
337
- 5432: "PostgreSQL",
338
- 5900: "VNC",
339
- 8000: "HTTP Alternate",
340
- 8080: "HTTP Alternate",
341
- 8443: "HTTPS Alternate",
342
- 8888: "HTTP Alternate",
343
- 10000: "Webmin",
344
- 27017: "MongoDB",
345
- }
346
-
409
+ if ports_tcp:
410
+ ports = ports_tcp
411
+ else:
412
+ ports = {
413
+ 20: "FTP-Data",
414
+ 21: "FTP-Control",
415
+ 22: "SSH",
416
+ 23: "Telnet",
417
+ 25: "SMTP",
418
+ 43: "Whois",
419
+ 53: "DNS",
420
+ 70: "Gopher",
421
+ 79: "FINGER",
422
+ 80: "HTTP",
423
+ 110: "POP3",
424
+ 111: "RPC",
425
+ 113: "ident",
426
+ 115: "SFTP",
427
+ 135: "MSRPC",
428
+ 139: "NetBIOS-SSN",
429
+ 143: "IMAP",
430
+ 179: "BGP",
431
+ 194: "IRC",
432
+ 389: "LDAP",
433
+ 443: "HTTPS",
434
+ 445: "SMB",
435
+ 465: "SMTPS",
436
+ 587: "SMTP Submission",
437
+ 631: "IPP",
438
+ 636: "LDAPS",
439
+ 873: "RSYNC",
440
+ 993: "IMAPS",
441
+ 995: "POP3S",
442
+ 1080: "SOCKS",
443
+ 1433: "SQL Server",
444
+ 1521: "Oracle",
445
+ 2082: "CPanel",
446
+ 2083: "CPanel",
447
+ 2222: "SSH",
448
+ 3128: "HTTP Proxy",
449
+ 3306: "MySQL",
450
+ 3389: "RDP",
451
+ 5432: "PostgreSQL",
452
+ 5900: "VNC",
453
+ 8000: "HTTP Alternate",
454
+ 8080: "HTTP Alternate",
455
+ 8443: "HTTPS Alternate",
456
+ 8888: "HTTP Alternate",
457
+ 10000: "Webmin",
458
+ 27017: "MongoDB",
459
+ }
460
+
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()
347
472
  if SnakeArgs().ports:
348
473
  rangeports, port_user = Ports(port_user)
349
474
  for i in range(len(port_user)):
@@ -388,14 +513,14 @@ if SnakeArgs().ports:
388
513
  if OpenPorts:
389
514
  for i in OpenPorts:
390
515
  print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
391
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
516
+ print(f"|{host[n]}|".center(60, "—"))
392
517
  print(f"Closed{colored('|X|','red')}:{portsclosed}")
393
518
  portsclosed = 0
394
519
  print(f"Open{colored('|√|','green')}:{portsopen}")
395
520
  portsopen = 0
396
521
  print("—" * 60)
397
522
  else:
398
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
523
+ print(f"|{host[n]}|".center(60, "—"))
399
524
  print(f"Closed{colored('|X|','red')}:{portsclosed}")
400
525
  portsclosed = 0
401
526
  print(f"Open{colored('|√|','green')}:{portsopen}")
@@ -414,15 +539,17 @@ if SnakeArgs().local:
414
539
  s.connect(("10.255.255.255", 1))
415
540
  local = s.getsockname()[0]
416
541
  except Exception as e:
417
- local = f"127.0.0.1:{e}"
542
+ local = f"{e}"
418
543
  finally:
419
544
  s.close()
420
- print(local)
545
+ print("|localhost|".center(60, "—"))
546
+ print(f"Public IP:{local}")
547
+ print(f"".center(60, "—"))
421
548
  if SnakeArgs().info:
422
549
  if host[0] == "None":
423
550
  host[0] = "localhost"
424
551
  for n in range(len(host)):
425
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
552
+ print(f"|{host[n]}|".center(60, "—"))
426
553
  try:
427
554
  host[n] = socket.gethostbyname(host[n])
428
555
  except Exception as e:
@@ -498,8 +625,16 @@ if SnakeArgs().info:
498
625
 
499
626
 
500
627
  if SnakeArgs().thread:
628
+ if SnakeArgs().udp:
629
+ try:
630
+ host[n] = socket.gethostbyname(host[n])
631
+ except Exception as e:
632
+ print(f"|{host[n]}|".center(60, "—"))
633
+ print(e)
634
+ sys.exit()
635
+
501
636
  for n in range(len(host)):
502
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
637
+ print(f"|{host[n]}|".center(60, "—"))
503
638
 
504
639
  for port in ports.keys():
505
640
  t = Thread(
@@ -514,15 +649,21 @@ if SnakeArgs().version:
514
649
  print(f"SnakeScan_Build_{version}")
515
650
  if SnakeArgs().speed:
516
651
  if SnakeArgs().udp:
652
+ try:
653
+ host[n] = socket.gethostbyname(host[n])
654
+ except Exception as e:
655
+ print(f"|{host[n]}|".center(60, "—"))
656
+ print(e)
657
+ sys.exit()
517
658
  for n in range(len(host)):
518
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
519
- PoolExecutorUDP(host[n])
659
+ print(f"|{host[n]}|".center(60, "—"))
660
+ PoolExecutorUDP(host[n], ports)
520
661
  sys.exit()
521
662
  for n in range(len(host)):
522
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
523
- PoolProcessExecutor(host[n])
663
+ print(f"|{host[n]}|".center(60, "—"))
664
+ PoolProcessExecutor(host[n], ports)
524
665
  if SnakeArgs().getssl:
525
666
  for n in range(len(host)):
526
- print(f"{colored(f'{host[n]}','light_cyan')}".center(69, "—"))
667
+ print(f"|{host[n]}|".center(60, "—"))
527
668
  Get_ssl(host[n])
528
669
  print("".center(60, "—"))
@@ -30,7 +30,7 @@ def Check_network(host):
30
30
  return False
31
31
 
32
32
  try:
33
- print(f"{colored(f'{host}','light_cyan')}".center(69, "—"))
33
+ print(f"|{host}|".center(60, "—"))
34
34
  try:
35
35
  host = socket.gethostbyname(host)
36
36
  except Exception as e:
@@ -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
- """IPv4 address scanner for collecting address information.Scan or get the IPv4 address from the IPv6 host"""
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.7.9"
3
+ __version__ = "1.8.3"
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(f"{colored(f'Service is up {self.host}-->|{self.port_user}|','light_green')}")
27
+ print(
28
+ f"{colored(f'Service is up {self.host}-->|{self.port_user}|','light_green')}"
29
+ )
28
30
  else:
29
- print(f"{colored(f'Service is down {self.host}-->|{self.port_user}|','light_red')}")
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}")
@@ -0,0 +1,3 @@
1
+ [Settings]
2
+ path_tcp = ""
3
+ path_udp = ""
@@ -17,6 +17,12 @@ dependencies = [
17
17
  "termcolor",
18
18
  ]
19
19
  [project.scripts]
20
- SnakeScan = "SnakeScan:run"
21
20
  Snake = "SnakeScan.CLI:main"
22
- snake = "SnakeScan.CLI:main"
21
+ snake = "SnakeScan.CLI:main"
22
+ [tool.flit.module]
23
+
24
+ name = "SnakeScan"
25
+
26
+ [tool.flit.sdist]
27
+
28
+ include = ["SnakeScan/config.ini"]
snakescan-1.7.9/PKG-INFO DELETED
@@ -1,98 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: SnakeScan
3
- Version: 1.7.9
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
-
16
- This documentation was created with the assistance of the GeekBot language model and Den*Ram
17
-
18
- -->
19
-
20
- # 🐍 SnakeScan: A Robust Python Port Scanner
21
-
22
- A versatile and efficient Python library designed for comprehensive network port scanning.
23
- [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
24
- [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
25
- [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
26
- [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](https://img.shields.io/badge/Status-Stable-green)
27
-
28
- **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.
29
-
30
- ## ⚙️ Key Features:
31
-
32
- * **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
33
-
34
- * **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
35
-
36
- * **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
37
-
38
- * **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
39
-
40
- * **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
41
-
42
- * **UDP Port Scanning:** Native support for scanning UDP ports.
43
-
44
- ## ⬇️ Installation:
45
-
46
- Install SnakeScan using pip:
47
-
48
- bash
49
-
50
- pip install SnakeScan
51
-
52
- ## ⌨️ Command Line Usage:
53
-
54
- ### 💡 Attribute Reference:
55
-
56
- * **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound on the first entry. Example: To scan from port 80 to 443, define the range as `79-443`. Examples: `snake -p 80,443` or `snake -p 80,3437,8080,20-30,79-443`
57
-
58
- * **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
59
-
60
- * **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
61
-
62
- * **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
63
-
64
- * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
65
-
66
- * **-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
- * **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
69
-
70
- * **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
71
-
72
- * **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
73
-
74
- * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
75
-
76
- ## 💻 Python Code Integration:
77
-
78
- ### ⏱️ Watcher Class: Real-Time Port Status
79
-
80
- The `Watcher` class facilitates continuous monitoring of a specified port.
81
-
82
- python
83
-
84
- from SnakeScan import Watcher
85
-
86
- watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
87
-
88
- watcher.start() # Begin monitoring!
89
-
90
- #### `Watcher` Methods:
91
-
92
- * `Watcher.start()` - Initiate the port monitoring process.
93
-
94
- * `Watcher.stop()` - Terminate the port monitoring process.
95
-
96
- ---
97
-
98
- **Latest Update:** 1.7.9 (Added full color output)
snakescan-1.7.9/README.md DELETED
@@ -1,85 +0,0 @@
1
- <!--
2
-
3
- This documentation was created with the assistance of the GeekBot language model and Den*Ram
4
-
5
- -->
6
-
7
- # 🐍 SnakeScan: A Robust Python Port Scanner
8
-
9
- A versatile and efficient Python library designed for comprehensive network port scanning.
10
- [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
11
- [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
12
- [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
13
- [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](https://img.shields.io/badge/Status-Stable-green)
14
-
15
- **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.
16
-
17
- ## ⚙️ Key Features:
18
-
19
- * **Flexible Port Specification:** Define target ports as single values, ranges, or through pre-configured sets.
20
-
21
- * **Multi-Threaded Architecture:** Accelerate scanning operations with parallel processing for rapid analysis.
22
-
23
- * **IP Information Retrieval:** Obtain detailed information about target IP addresses, supporting both IPv4 and IPv6.
24
-
25
- * **Real-time Port Monitoring:** Utilize the `Watcher` class for continuous monitoring of critical port statuses.
26
-
27
- * **Concise Command-Line Interface & API:** Integrate SnakeScan seamlessly into workflows via CLI or programmatic access.
28
-
29
- * **UDP Port Scanning:** Native support for scanning UDP ports.
30
-
31
- ## ⬇️ Installation:
32
-
33
- Install SnakeScan using pip:
34
-
35
- bash
36
-
37
- pip install SnakeScan
38
-
39
- ## ⌨️ Command Line Usage:
40
-
41
- ### 💡 Attribute Reference:
42
-
43
- * **-p**: Specify target ports for scanning (single port or range). Note: Range specifications exclude the lower bound on the first entry. Example: To scan from port 80 to 443, define the range as `79-443`. Examples: `snake -p 80,443` or `snake -p 80,3437,8080,20-30,79-443`
44
-
45
- * **-u**: Enable UDP port scanning. Example: `snake -p 53 -u`
46
-
47
- * **-h**: Display the complete list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
48
-
49
- * **-sp**: Initiate a scan using a predefined set of common ports with `ProcessPoolExecutor`. Example: `snake -sp`
50
-
51
- * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
52
-
53
- * **-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
- * **-t**: Enable multi-threading for enhanced scan performance. Example: `snake -t`
56
-
57
- * **-ch**: Scan a subnet to discover active IP addresses on the network. Example: `snake -ch`
58
-
59
- * **-l**: Display your public IP address (requires an active internet connection). Example: `snake -l`
60
-
61
- * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
62
-
63
- ## 💻 Python Code Integration:
64
-
65
- ### ⏱️ Watcher Class: Real-Time Port Status
66
-
67
- The `Watcher` class facilitates continuous monitoring of a specified port.
68
-
69
- python
70
-
71
- from SnakeScan import Watcher
72
-
73
- watcher = Watcher("localhost", 53, 2) # Host, port, check interval (in seconds)
74
-
75
- watcher.start() # Begin monitoring!
76
-
77
- #### `Watcher` Methods:
78
-
79
- * `Watcher.start()` - Initiate the port monitoring process.
80
-
81
- * `Watcher.stop()` - Terminate the port monitoring process.
82
-
83
- ---
84
-
85
- **Latest Update:** 1.7.9 (Added full color output)
@@ -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