SnakeScan 1.8.7__tar.gz → 1.8.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SnakeScan
3
- Version: 1.8.7
3
+ Version: 1.8.8
4
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
5
  Author: Den*Ram
6
6
  Requires-Python: >=3.7
@@ -50,11 +50,11 @@ A versatile and efficient Python library designed for comprehensive network port
50
50
 
51
51
  ## ⬇️ Installation:
52
52
 
53
- **It is strongly recommended to install this specific version of SnakeScan (1.8.7) as it includes significant enhancements and bug fixes that improve reliability and operational stability. The updates are aimed at ensuring optimal performance and eliminating issues encountered in previous versions.**
53
+ **It is strongly recommended to install this specific version of SnakeScan (1.8.8) as it includes significant enhancements and bug fixes that improve reliability and operational stability. The updates are aimed at ensuring optimal performance and eliminating issues encountered in previous versions.**
54
54
 
55
55
  **Installation via pip (recommended):**
56
56
 
57
-
57
+
58
58
 
59
59
  bash
60
60
 
@@ -84,8 +84,6 @@ flit install
84
84
 
85
85
  * **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
86
86
 
87
- * **-sp**: Initiate a scan using a predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
88
-
89
87
  * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
90
88
 
91
89
  * **-gs**: Retrieve an SSL/TLS certificate from a specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
@@ -98,6 +96,8 @@ flit install
98
96
 
99
97
  * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
100
98
 
99
+ * **-a --asynchronous**: Uses all ports from the predefined dictionary for asynchronous port scanning. Example: `snake -a`. If you want to scan all ports using your own port file, use the `-d` argument to specify the path to that file.
100
+
101
101
  * **-d**: Specify the path to a JSON file containing TCP port definitions and optionally, a second JSON file containing UDP port definitions. **Note:** Upon the first use of this argument, the paths to the JSON files must be provided with each command execution and separated by a comma. After the initial use, SnakeScan can remember these paths for subsequent scans.
102
102
 
103
103
  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`)
@@ -109,17 +109,11 @@ flit install
109
109
  **JSON File Format:** The JSON file should be formatted as a dictionary where the keys are port numbers (as strings), and the values are the corresponding service names or descriptions.
110
110
 
111
111
  ```json
112
-
113
112
  {
114
-
115
113
  "53": "DNS",
116
-
117
114
  "80": "HTTP",
118
-
119
115
  "443": "HTTPS"
120
-
121
116
  }
122
-
123
117
  ```
124
118
 
125
119
  * **-dr**: Reset custom port dictionaries to their default state and revert to standard SnakeScan port definitions. Example: `snake -dr`
@@ -150,6 +144,5 @@ watcher.start() # Start monitoring!
150
144
 
151
145
  ---
152
146
 
153
- **Last Updated:** 1.8.7 (Automatic Home Directory Detection, Added `-home` and `--homedir` arguments. All config files are stored outside the installed library for permanent and secure customization.)
154
-
147
+ **Last Updated:** 1.8.8 (Automatic Home Directory Detection, Added `-home` and `--homedir` arguments. Added `-a` or `--asynchronous` arguments for scan allports from dictionaries. All config files are stored outside the installed library for permanent and secure customization.)
155
148
 
@@ -37,11 +37,11 @@ A versatile and efficient Python library designed for comprehensive network port
37
37
 
38
38
  ## ⬇️ Installation:
39
39
 
40
- **It is strongly recommended to install this specific version of SnakeScan (1.8.7) as it includes significant enhancements and bug fixes that improve reliability and operational stability. The updates are aimed at ensuring optimal performance and eliminating issues encountered in previous versions.**
40
+ **It is strongly recommended to install this specific version of SnakeScan (1.8.8) as it includes significant enhancements and bug fixes that improve reliability and operational stability. The updates are aimed at ensuring optimal performance and eliminating issues encountered in previous versions.**
41
41
 
42
42
  **Installation via pip (recommended):**
43
43
 
44
-
44
+
45
45
 
46
46
  bash
47
47
 
@@ -71,8 +71,6 @@ flit install
71
71
 
72
72
  * **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
73
73
 
74
- * **-sp**: Initiate a scan using a predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
75
-
76
74
  * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
77
75
 
78
76
  * **-gs**: Retrieve an SSL/TLS certificate from a specified web server. Example: `snake www.google.com -gs` (Requires a valid hostname to avoid connection errors.)
@@ -85,6 +83,8 @@ flit install
85
83
 
86
84
  * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
87
85
 
86
+ * **-a --asynchronous**: Uses all ports from the predefined dictionary for asynchronous port scanning. Example: `snake -a`. If you want to scan all ports using your own port file, use the `-d` argument to specify the path to that file.
87
+
88
88
  * **-d**: Specify the path to a JSON file containing TCP port definitions and optionally, a second JSON file containing UDP port definitions. **Note:** Upon the first use of this argument, the paths to the JSON files must be provided with each command execution and separated by a comma. After the initial use, SnakeScan can remember these paths for subsequent scans.
89
89
 
90
90
  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`)
@@ -96,17 +96,11 @@ flit install
96
96
  **JSON File Format:** The JSON file should be formatted as a dictionary where the keys are port numbers (as strings), and the values are the corresponding service names or descriptions.
97
97
 
98
98
  ```json
99
-
100
99
  {
101
-
102
100
  "53": "DNS",
103
-
104
101
  "80": "HTTP",
105
-
106
102
  "443": "HTTPS"
107
-
108
103
  }
109
-
110
104
  ```
111
105
 
112
106
  * **-dr**: Reset custom port dictionaries to their default state and revert to standard SnakeScan port definitions. Example: `snake -dr`
@@ -137,5 +131,4 @@ watcher.start() # Start monitoring!
137
131
 
138
132
  ---
139
133
 
140
- **Last Updated:** 1.8.7 (Automatic Home Directory Detection, Added `-home` and `--homedir` arguments. All config files are stored outside the installed library for permanent and secure customization.)
141
-
134
+ **Last Updated:** 1.8.8 (Automatic Home Directory Detection, Added `-home` and `--homedir` arguments. Added `-a` or `--asynchronous` arguments for scan allports from dictionaries. All config files are stored outside the installed library for permanent and secure customization.)
@@ -1,4 +1,5 @@
1
1
  import os
2
+ import asyncio
2
3
  import configparser
3
4
  from pathlib import Path
4
5
  import json
@@ -8,14 +9,12 @@ import argparse
8
9
  import socket
9
10
  import ipaddress
10
11
  from art import tprint
11
- from concurrent.futures import ProcessPoolExecutor
12
12
  from termcolor import colored
13
13
  from threading import Thread
14
14
  from tqdm import tqdm
15
15
  from SnakeScan.Check_subnet import Check_network
16
- from SnakeScan.PoolExecutor import PoolProcessExecutor
17
16
  from SnakeScan.Get_ssl import Get_ssl
18
- from SnakeScan.Pool_UDP_Executor import PoolExecutorUDP
17
+
19
18
 
20
19
  OpenPorts = []
21
20
  threads = []
@@ -78,6 +77,39 @@ ports = {
78
77
  }
79
78
 
80
79
 
80
+ async def is_port_open_async(host, port):
81
+ try:
82
+ reader, writer = await asyncio.wait_for(
83
+ asyncio.open_connection(host, port), timeout=1
84
+ )
85
+ except (OSError, asyncio.TimeoutError):
86
+ try:
87
+ print(
88
+ f"Closed\033[31m|X|\033[0m-->\033[91m{ports.get(port)}\033[0m\033[31m|{port}|\033[0m"
89
+ )
90
+ except Exception:
91
+ print(f"Closed\033[31m|X|\033[0m-->\033[31m|{port}|\033[0m")
92
+ else:
93
+ print(
94
+ f"Open\033[32m|√|\033[0m-->\033[92m{ports.get(port)}\033[0m\033[32m|{port}|\033[0m"
95
+ )
96
+ writer.close()
97
+ await writer.wait_closed()
98
+
99
+
100
+ async def is_port_run_threads(host, ports):
101
+ for n in range(len(host)):
102
+ try:
103
+ loop = asyncio.get_event_loop()
104
+ await loop.run_in_executor(None, socket.gethostbyname, host[n])
105
+ print(f"|{host[n]}|".center(60, "—"))
106
+ tasks = [is_port_open_async(host[n], port) for port in ports.keys()]
107
+ await asyncio.gather(*tasks)
108
+ except Exception as e:
109
+ print(f"|{host[n]}|".center(60, "—"))
110
+ print(e)
111
+
112
+
81
113
  def Load_config(ports):
82
114
  try:
83
115
  config = configparser.ConfigParser()
@@ -183,7 +215,7 @@ else:
183
215
  if __name__ == "__main__":
184
216
  main()
185
217
 
186
- version = "1.8.7"
218
+ version = "1.8.8"
187
219
 
188
220
 
189
221
  def is_port_open(host, port):
@@ -247,6 +279,12 @@ def SnakeArgs():
247
279
  description="SnakeScan - It's a command line library for scan and get information about ip."
248
280
  )
249
281
  parser.add_argument("host", nargs="?", default="None")
282
+ parser.add_argument(
283
+ "-a",
284
+ "--asynchrous",
285
+ action="store_true",
286
+ help="Use scan with asyncio",
287
+ )
250
288
  parser.add_argument(
251
289
  "-home",
252
290
  "--homedir",
@@ -278,12 +316,6 @@ def SnakeArgs():
278
316
  parser.add_argument(
279
317
  "-gs", "--getssl", action="store_true", help="Get official ssl certificate"
280
318
  )
281
- parser.add_argument(
282
- "-sp",
283
- "--speed",
284
- action="store_true",
285
- help="Scan with using PoolProcessExecutor",
286
- )
287
319
  parser.add_argument("-v", "--version", action="store_true", help="Library version")
288
320
  parser.add_argument(
289
321
  "-i", "--info", action="store_true", help="IP information about host"
@@ -495,7 +527,8 @@ else:
495
527
  10000: "Webmin",
496
528
  27017: "MongoDB",
497
529
  }
498
-
530
+ if SnakeArgs().asynchrous:
531
+ asyncio.run(is_port_run_threads(host, ports))
499
532
  if SnakeArgs().dictremove:
500
533
  try:
501
534
  config = configparser.ConfigParser()
@@ -690,26 +723,6 @@ if SnakeArgs().homedir:
690
723
  except Exception as e:
691
724
  print(e)
692
725
 
693
- if SnakeArgs().speed:
694
- if SnakeArgs().udp:
695
- for n in range(len(host)):
696
- try:
697
- socket.gethostbyname(host[n])
698
- print(f"|{host[n]}|".center(60, "—"))
699
- PoolExecutorUDP(host[n], ports)
700
- except Exception as e:
701
- print(f"|{host[n]}|".center(60, "—"))
702
- print(e)
703
- else:
704
- for n in range(len(host)):
705
- try:
706
- socket.gethostbyname(host[n])
707
- print(f"|{host[n]}|".center(60, "—"))
708
- PoolProcessExecutor(host[n], ports)
709
- except Exception as e:
710
- print(f"|{host[n]}|".center(60, "—"))
711
- print(e)
712
-
713
726
 
714
727
  if SnakeArgs().getssl:
715
728
  for n in range(len(host)):
@@ -1,6 +1,6 @@
1
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.7"
3
+ __version__ = "1.8.8"
4
4
  import socket
5
5
  from time import sleep
6
6
  from termcolor import colored
@@ -1,31 +0,0 @@
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)
@@ -1,40 +0,0 @@
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)
File without changes
File without changes