SnakeScan 1.8.7__tar.gz → 1.8.9__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.9
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
@@ -21,11 +21,8 @@ This documentation was created with GeekBot Language Model and Den*Ram
21
21
  A versatile and efficient Python library designed for comprehensive network port scanning.
22
22
 
23
23
  [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
24
-
25
24
  [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
26
-
27
25
  [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
28
-
29
26
  [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](https://img.shields.io/badge/Status-Stable-green)
30
27
 
31
28
  **SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers who need reliable port scanning capabilities. From simple port checks to advanced, multi-threaded subnet analysis, SnakeScan provides the tools necessary for effective network assessment.
@@ -50,16 +47,14 @@ A versatile and efficient Python library designed for comprehensive network port
50
47
 
51
48
  ## ⬇️ Installation:
52
49
 
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.**
54
-
55
50
  **Installation via pip (recommended):**
56
51
 
57
-
58
52
 
59
53
  bash
60
54
 
61
55
  pip install SnakeScan
62
56
 
57
+
63
58
  **Alternative Installation from Source Code Archive:**
64
59
 
65
60
  SnakeScan is distributed with open source code. This means you can download the code archive, examine it, make necessary changes, and fix any errors that occur during use.
@@ -84,8 +79,6 @@ flit install
84
79
 
85
80
  * **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
86
81
 
87
- * **-sp**: Initiate a scan using a predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
88
-
89
82
  * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
90
83
 
91
84
  * **-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 +91,8 @@ flit install
98
91
 
99
92
  * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
100
93
 
94
+ * **-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.
95
+
101
96
  * **-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
97
 
103
98
  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 +104,11 @@ flit install
109
104
  **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
105
 
111
106
  ```json
112
-
113
107
  {
114
-
115
108
  "53": "DNS",
116
-
117
109
  "80": "HTTP",
118
-
119
110
  "443": "HTTPS"
120
-
121
111
  }
122
-
123
112
  ```
124
113
 
125
114
  * **-dr**: Reset custom port dictionaries to their default state and revert to standard SnakeScan port definitions. Example: `snake -dr`
@@ -150,6 +139,5 @@ watcher.start() # Start monitoring!
150
139
 
151
140
  ---
152
141
 
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
-
142
+ **Last Updated:** 1.8.9 (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
143
 
@@ -8,11 +8,8 @@ This documentation was created with GeekBot Language Model and Den*Ram
8
8
  A versatile and efficient Python library designed for comprehensive network port scanning.
9
9
 
10
10
  [![PyPI](https://img.shields.io/pypi/v/SnakeScan?color=blue&label=PyPI)](https://pypi.org/project/SnakeScan/)
11
-
12
11
  [![MIT License](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
13
-
14
12
  [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-brightgreen)](https://www.python.org/)
15
-
16
13
  [![Status: Stable](https://img.shields.io/badge/Status-Stable-green)](https://img.shields.io/badge/Status-Stable-green)
17
14
 
18
15
  **SnakeScan** provides a flexible and powerful solution for network administrators, security professionals, and developers who need reliable port scanning capabilities. From simple port checks to advanced, multi-threaded subnet analysis, SnakeScan provides the tools necessary for effective network assessment.
@@ -37,16 +34,14 @@ A versatile and efficient Python library designed for comprehensive network port
37
34
 
38
35
  ## ⬇️ Installation:
39
36
 
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.**
41
-
42
37
  **Installation via pip (recommended):**
43
38
 
44
-
45
39
 
46
40
  bash
47
41
 
48
42
  pip install SnakeScan
49
43
 
44
+
50
45
  **Alternative Installation from Source Code Archive:**
51
46
 
52
47
  SnakeScan is distributed with open source code. This means you can download the code archive, examine it, make necessary changes, and fix any errors that occur during use.
@@ -71,8 +66,6 @@ flit install
71
66
 
72
67
  * **-h**: Show the full list of available command-line attributes and their descriptions. Example: `snake -h` or `snake -help`
73
68
 
74
- * **-sp**: Initiate a scan using a predefined common port set with `ProcessPoolExecutor`. Example: `snake -sp`
75
-
76
69
  * **-v**: Display the current version of the SnakeScan library. Example: `snake -v`
77
70
 
78
71
  * **-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 +78,8 @@ flit install
85
78
 
86
79
  * **-i**: Show detailed information about a specific IP address (supports both IPv4 and IPv6). Example: `snake www.google.com -i`
87
80
 
81
+ * **-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.
82
+
88
83
  * **-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
84
 
90
85
  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 +91,11 @@ flit install
96
91
  **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
92
 
98
93
  ```json
99
-
100
94
  {
101
-
102
95
  "53": "DNS",
103
-
104
96
  "80": "HTTP",
105
-
106
97
  "443": "HTTPS"
107
-
108
98
  }
109
-
110
99
  ```
111
100
 
112
101
  * **-dr**: Reset custom port dictionaries to their default state and revert to standard SnakeScan port definitions. Example: `snake -dr`
@@ -137,5 +126,4 @@ watcher.start() # Start monitoring!
137
126
 
138
127
  ---
139
128
 
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
-
129
+ **Last Updated:** 1.8.9 (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,40 @@ 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
+ print("".center(60, "—"))
112
+
113
+
81
114
  def Load_config(ports):
82
115
  try:
83
116
  config = configparser.ConfigParser()
@@ -183,7 +216,7 @@ else:
183
216
  if __name__ == "__main__":
184
217
  main()
185
218
 
186
- version = "1.8.7"
219
+ version = "1.8.9"
187
220
 
188
221
 
189
222
  def is_port_open(host, port):
@@ -247,6 +280,12 @@ def SnakeArgs():
247
280
  description="SnakeScan - It's a command line library for scan and get information about ip."
248
281
  )
249
282
  parser.add_argument("host", nargs="?", default="None")
283
+ parser.add_argument(
284
+ "-a",
285
+ "--asynchrous",
286
+ action="store_true",
287
+ help="Use scan with asyncio",
288
+ )
250
289
  parser.add_argument(
251
290
  "-home",
252
291
  "--homedir",
@@ -278,12 +317,6 @@ def SnakeArgs():
278
317
  parser.add_argument(
279
318
  "-gs", "--getssl", action="store_true", help="Get official ssl certificate"
280
319
  )
281
- parser.add_argument(
282
- "-sp",
283
- "--speed",
284
- action="store_true",
285
- help="Scan with using PoolProcessExecutor",
286
- )
287
320
  parser.add_argument("-v", "--version", action="store_true", help="Library version")
288
321
  parser.add_argument(
289
322
  "-i", "--info", action="store_true", help="IP information about host"
@@ -495,7 +528,8 @@ else:
495
528
  10000: "Webmin",
496
529
  27017: "MongoDB",
497
530
  }
498
-
531
+ if SnakeArgs().asynchrous:
532
+ asyncio.run(is_port_run_threads(host, ports))
499
533
  if SnakeArgs().dictremove:
500
534
  try:
501
535
  config = configparser.ConfigParser()
@@ -566,6 +600,7 @@ if SnakeArgs().ports:
566
600
  print("—" * 60)
567
601
  except Exception as e:
568
602
  print(e)
603
+ print("".center(60, "—"))
569
604
  sys.exit()
570
605
  if SnakeArgs().check:
571
606
  for n in range(len(host)):
@@ -605,6 +640,7 @@ if SnakeArgs().info:
605
640
  hostname, list, iplist = socket.gethostbyaddr(host[n])
606
641
  except Exception as e:
607
642
  print(e)
643
+ print("".center(60, "—"))
608
644
  sys.exit()
609
645
 
610
646
  hosting = ""
@@ -638,6 +674,7 @@ if SnakeArgs().info:
638
674
  pass
639
675
  except Exception as e:
640
676
  print(e)
677
+ print("".center(60, "—"))
641
678
  print(f"Type IP: {type(ip_obj)}")
642
679
  print(f"Version IP: {ip_obj.version}")
643
680
  network_obj = ipaddress.ip_network(network)
@@ -678,6 +715,7 @@ if SnakeArgs().thread:
678
715
  except Exception as e:
679
716
  print(f"|{host[n]}|".center(60, "—"))
680
717
  print(e)
718
+ print("".center(60, "—"))
681
719
 
682
720
  if SnakeArgs().version:
683
721
  print("|Version|".center(60, "—"))
@@ -690,26 +728,6 @@ if SnakeArgs().homedir:
690
728
  except Exception as e:
691
729
  print(e)
692
730
 
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
731
 
714
732
  if SnakeArgs().getssl:
715
733
  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.9"
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