SnakeScan 1.6.4__tar.gz → 1.6.5__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,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SnakeScan
3
- Version: 1.6.4
4
- Summary: IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it. Scan only IPv4 or get the IPv4 address from the IPv6 host
3
+ Version: 1.6.5
4
+ Summary: IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it. Scan only IPv4 or get the IPv4 address from the IPv6 host
5
5
  Author: Den*Ram
6
6
  Requires-Python: >=3.7
7
7
  Description-Content-Type: text/markdown
@@ -14,9 +14,11 @@ Project-URL: Homepage, https://github.com/Den-Ram/SnakeScan
14
14
  Project-URL: Repository, https://github.com/Den-Ram/SnakeScan
15
15
 
16
16
  # SnakeScan
17
+ Use to scan Ports and use carefully
17
18
  ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
18
- ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
19
19
  ![License](https://img.shields.io/badge/License-MIT-blue.svg)
20
+ ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
21
+ This is the final release version, which already has full functionality. Further work will include bug fixes and the creation of more user-friendly documentation for the code and functions. AI was not used in this code.It was used only to gain knowledge on how to implement this. After all, I did not find more convenient libraries for port scanning on the Internet, so the library was created to make scanning easier. If you want, you can improve it at your discretion. Enjoy using it! \|•√•|/
20
22
  ```
21
23
  import SnakeScan
22
24
  SnakeScan.run()
@@ -39,6 +41,7 @@ SnakeScan.run()
39
41
  ```
40
42
  Watcher.start() - Starts checking ports
41
43
  Watcher.stop() - Stops port checking
44
+ ```
42
45
  ## Added multiple use Watcher:
43
46
  ```
44
47
  from SnakeScan import Watcher
@@ -72,7 +75,7 @@ options:
72
75
  ```
73
76
  ## Attributes snake-Snake
74
77
  ```
75
- -p:snake -p 80,443,3437,20-1000
78
+ -p:snake -p 80,443,3437,20-1000,300-400
76
79
  -p:[20]-1000 will start from [21]-[1000]
77
80
  -h:snake -h [snake usage]
78
81
  -sp:snake -sp [use processpoolexecutir to scan host]
@@ -1,7 +1,9 @@
1
1
  # SnakeScan
2
+ Use to scan Ports and use carefully
2
3
  ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
3
- ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
4
4
  ![License](https://img.shields.io/badge/License-MIT-blue.svg)
5
+ ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
6
+ This is the final release version, which already has full functionality. Further work will include bug fixes and the creation of more user-friendly documentation for the code and functions. AI was not used in this code.It was used only to gain knowledge on how to implement this. After all, I did not find more convenient libraries for port scanning on the Internet, so the library was created to make scanning easier. If you want, you can improve it at your discretion. Enjoy using it! \|•√•|/
5
7
  ```
6
8
  import SnakeScan
7
9
  SnakeScan.run()
@@ -24,6 +26,7 @@ SnakeScan.run()
24
26
  ```
25
27
  Watcher.start() - Starts checking ports
26
28
  Watcher.stop() - Stops port checking
29
+ ```
27
30
  ## Added multiple use Watcher:
28
31
  ```
29
32
  from SnakeScan import Watcher
@@ -57,7 +60,7 @@ options:
57
60
  ```
58
61
  ## Attributes snake-Snake
59
62
  ```
60
- -p:snake -p 80,443,3437,20-1000
63
+ -p:snake -p 80,443,3437,20-1000,300-400
61
64
  -p:[20]-1000 will start from [21]-[1000]
62
65
  -h:snake -h [snake usage]
63
66
  -sp:snake -sp [use processpoolexecutir to scan host]
@@ -66,7 +66,7 @@ ports = {
66
66
  8080: "Tomcat",
67
67
  10000: "Webmin",
68
68
  }
69
- version = "1.6.4"
69
+ version = "1.6.5"
70
70
 
71
71
 
72
72
  def is_port_open(host, port):
@@ -92,28 +92,35 @@ def is_port_open_threads(host, port):
92
92
  print(f"Closed{colored('|X|','red')}-->|{port}|")
93
93
  else:
94
94
  print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
95
+
96
+
95
97
  def Ports(str=""):
96
- rangeports=[]
97
- port=[]
98
- str=str.split(",")
98
+ rangeports = []
99
+ rangeport = []
100
+ port = []
101
+ doneports = []
102
+ str = str.split(",")
99
103
  for p in range(len(str)):
100
- if "-" in str[p]:
101
- rangeports.append(str[p])
102
- else:
103
- port.append(str[p])
104
+ if "-" in str[p]:
105
+ rangeports.append(str[p])
106
+ else:
107
+ port.append(str[p])
104
108
  for n in range(len(port)):
105
109
  for i in string.punctuation:
106
110
  if i in port[n]:
107
- port[n]=port[n].replace(i,"")
111
+ port[n] = port[n].replace(i, "")
108
112
  for r in range(len(rangeports)):
109
- rangeport=rangeports[r].split("-")
113
+ rangeport = rangeports[r].split("-")
114
+ for i in range(len(rangeport)):
115
+ doneports.append(rangeport[i])
110
116
  try:
111
- return rangeport,port
117
+ return doneports, port
112
118
  except Exception as e:
113
- rangeport=""
114
- return rangeport,port
119
+ rangeport = ""
120
+ return doneports, port
115
121
  sys.exit()
116
122
 
123
+
117
124
  def SnakeArgs():
118
125
  parser = argparse.ArgumentParser(
119
126
  description="Snake - It's a command line module SnakeScan. Use him for more fast starting"
@@ -158,45 +165,44 @@ if host.startswith("https://"):
158
165
  if host == "None":
159
166
  host = "localhost"
160
167
  if SnakeArgs().ports:
161
- rangeports,port_user=Ports(port_user)
168
+ rangeports, port_user = Ports(port_user)
162
169
  for i in range(len(port_user)):
163
- port_user[i]=int(port_user[i])
170
+ port_user[i] = int(port_user[i])
164
171
  for port in range(len(port_user)):
165
- if is_port_open(host, port_user[port]):
172
+ if is_port_open(host, port_user[port]):
173
+ print(
174
+ f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
175
+ )
176
+ else:
177
+ try:
166
178
  print(
167
- f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
179
+ f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
168
180
  )
169
- else:
170
- try:
171
- print(
172
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
173
- )
174
- except:
175
- print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
181
+ except:
182
+ print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
176
183
  try:
177
- if int(rangeports[0]) > int(rangeports[1]):
178
- rangesave1=rangeports[0]
179
- rangesave2=rangeports[1]
180
- rangeports[1]=rangesave1
181
- rangeports[0]=rangesave2
182
- for port in tqdm(range(int(rangeports[0]) + 1, int(rangeports[1])+1)):
183
- if is_port_open(host, port):
184
- for name in ports:
185
- if port == name:
186
- OpenPorts = [port]
187
- portsopen += 1
184
+ first = rangeports[::2]
185
+ second = rangeports[1::2]
186
+ minimal = min(len(first), len(second))
187
+ for i in range(minimal):
188
+ for port in tqdm(range(int(first[i]) + 1, int(second[i]) + 1)):
189
+ if is_port_open(host, port):
190
+ for name in ports:
191
+ if port == name:
192
+ OpenPorts = [port]
193
+ portsopen += 1
194
+ else:
195
+ portsclosed += 1
196
+ if OpenPorts:
197
+ for i in OpenPorts:
198
+ print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
199
+ print(f"{host}".center(60, "-"))
200
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
201
+ portsclosed = 0
202
+ print(f"Open{colored('|√|','green')}:{portsopen}")
203
+ portsopen = 0
204
+ print("-" * 60)
188
205
  else:
189
- portsclosed += 1
190
- if OpenPorts:
191
- for i in OpenPorts:
192
- print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
193
- print(f"{host}".center(60, "-"))
194
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
195
- portsclosed = 0
196
- print(f"Open{colored('|√|','green')}:{portsopen}")
197
- portsopen = 0
198
- print("-" * 60)
199
- else:
200
206
  print(f"{host}".center(60, "-"))
201
207
  print(f"Closed{colored('|X|','red')}:{portsclosed}")
202
208
  portsclosed = 0
@@ -4,8 +4,11 @@ import platform
4
4
  import socket
5
5
  from termcolor import colored
6
6
  from concurrent.futures import ThreadPoolExecutor
7
+
7
8
  global threads
8
9
  threads = []
10
+
11
+
9
12
  def Check_network(host):
10
13
  def check_host(host):
11
14
  try:
@@ -25,6 +28,7 @@ def Check_network(host):
25
28
  except Exception as e:
26
29
  print(f"Check error {ip}: {e}")
27
30
  return False
31
+
28
32
  try:
29
33
  print("".center(60, "-"))
30
34
  try:
@@ -45,11 +49,11 @@ def Check_network(host):
45
49
  network = ipaddress.ip_network(network_str)
46
50
  print(f"Checking the IP addresses in the subset {network_str}...")
47
51
  with ThreadPoolExecutor(max_workers=None) as executor:
48
- try:
49
- for ip in network.hosts():
50
- future = executor.submit(check_host, ip)
51
- future.result()
52
- except Exception as e:
53
- print(e)
52
+ try:
53
+ for ip in network.hosts():
54
+ future = executor.submit(check_host, ip)
55
+ future.result()
56
+ except Exception as e:
57
+ print(e)
54
58
  except ValueError as e:
55
59
  print(f"Error creating network object {e}")
@@ -1,6 +1,6 @@
1
- """IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it. Scan only IPv4 or get the IPv4 address from the IPv6 host """
1
+ """IPv4 address scanner for collecting address information.Use carefully for your network safety.Use to get IPV4 from IPV6 address.Don't use it to scan IPV6 because it's not designed for it. Scan only IPv4 or get the IPv4 address from the IPv6 host"""
2
2
 
3
- __version__ = "1.6.4"
3
+ __version__ = "1.6.5"
4
4
  import socket
5
5
  import ipaddress
6
6
  from art import tprint
@@ -12,35 +12,38 @@ from SnakeScan.Check_subnet import Check_network
12
12
 
13
13
 
14
14
  class Watcher:
15
- def __init__(self, host, port_user, timeout = 1):
16
- #Initialized class and variables host, port, and delay.
17
- self.host = host #localhost
18
- self.port_user = port_user #80
19
- self.timeout = timeout #2 or 2.0
20
- self.work = False # run value
15
+ def __init__(self, host, port_user, timeout=1):
16
+ # Initialized class and variables host, port, and delay.
17
+ self.host = host # localhost
18
+ self.port_user = port_user # 80
19
+ self.timeout = timeout # 2 or 2.0
20
+ self.work = False # run value
21
+
21
22
  def run(self):
22
- #Basic process of connecting to a host and checking the port
23
- previous = None
24
- while self.work:
25
- try:
26
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
27
- connection = sock.connect_ex((self.host, self.port_user))
28
- if previous != connection:
29
- if connection == 0:
30
- print(f"Service is up {self.host}-->|{self.port_user}|")
31
- else:
32
- print(f"Service is down {self.host}-->|{self.port_user}|")
33
- previous = connection
34
- except Exception as e:
35
- print(f"Unable to create scanner object:{e}")
36
- sleep(self.timeout)
23
+ # Basic process of connecting to a host and checking the port
24
+ previous = None
25
+ while self.work:
26
+ try:
27
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
28
+ connection = sock.connect_ex((self.host, self.port_user))
29
+ if previous != connection:
30
+ if connection == 0:
31
+ print(f"Service is up {self.host}-->|{self.port_user}|")
32
+ else:
33
+ print(f"Service is down {self.host}-->|{self.port_user}|")
34
+ previous = connection
35
+ except Exception as e:
36
+ print(f"Unable to create scanner object:{e}")
37
+ sleep(self.timeout)
38
+
37
39
  def start(self):
38
- #Run a port check to see if it is running or offline.
40
+ # Run a port check to see if it is running or offline.
39
41
  self.work = True
40
42
  self.thread = Thread(target=self.run)
41
43
  self.thread.start()
44
+
42
45
  def stop(self):
43
- #Stops port checking
46
+ # Stops port checking
44
47
  self.work = False
45
48
  self.thread.join()
46
49
 
@@ -49,11 +52,10 @@ def run():
49
52
  portsopen = 0
50
53
  portsclosed = 0
51
54
  Run_now = True
52
-
53
-
55
+
54
56
  global num
55
57
  num = 0
56
-
58
+
57
59
  OpenPorts = []
58
60
  threads = []
59
61
  ports = {
@@ -98,26 +100,28 @@ def run():
98
100
  8080: "Tomcat",
99
101
  10000: "Webmin",
100
102
  }
103
+
101
104
  def Ports(str=""):
102
- rangeports=[]
103
- port=[]
104
- str=str.split(",")
105
+ rangeports = []
106
+ port = []
107
+ str = str.split(",")
105
108
  for p in range(len(str)):
106
- if "-" in str[p]:
107
- rangeports.append(str[p])
108
- else:
109
- port.append(str[p])
109
+ if "-" in str[p]:
110
+ rangeports.append(str[p])
111
+ else:
112
+ port.append(str[p])
110
113
  for n in range(len(port)):
111
114
  for i in string.punctuation:
112
115
  if i in port[n]:
113
- port[n]=port[n].replace(i,"")
116
+ port[n] = port[n].replace(i, "")
114
117
  for r in range(len(rangeports)):
115
- rangeport=rangeports[r].split("-")
118
+ rangeport = rangeports[r].split("-")
116
119
  try:
117
- return rangeport,port
120
+ return rangeport, port
118
121
  except Exception as e:
119
122
  print("Error: invalid value")
120
123
  sys.exit()
124
+
121
125
  def is_port_open(host, port):
122
126
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
123
127
  try:
@@ -262,7 +266,6 @@ def run():
262
266
  t.start()
263
267
  for t in threads:
264
268
  t.join()
265
-
266
269
 
267
270
  else:
268
271
  if "-t" in port_user:
@@ -281,29 +284,29 @@ def run():
281
284
  length = port_user
282
285
  print(f"{colored('|!|','red')}Listening {host} please wait...")
283
286
  # |----------------starting---------------------|
284
- rangeports,port_user=Ports(port_user)
287
+ rangeports, port_user = Ports(port_user)
285
288
  for i in range(len(port_user)):
286
- port_user[i]=int(port_user[i])
289
+ port_user[i] = int(port_user[i])
287
290
  for port in range(len(port_user)):
288
- if is_port_open(host, port_user[port]):
291
+ if is_port_open(host, port_user[port]):
292
+ print(
293
+ f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
294
+ )
295
+ else:
296
+ try:
289
297
  print(
290
- f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
298
+ f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
291
299
  )
292
- else:
293
- try:
294
- print(
295
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
296
- )
297
- except:
298
- print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
299
- for port in tqdm(range(int(rangeports[0]), int(rangeports[1])+1)):
300
+ except:
301
+ print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
302
+ for port in tqdm(range(int(rangeports[0]), int(rangeports[1]) + 1)):
300
303
  if is_port_open(host, port):
301
304
  for name in ports:
302
305
  if port == name:
303
306
  OpenPorts = [port]
304
307
  portsopen += 1
305
308
  else:
306
- portsclosed += 1
309
+ portsclosed += 1
307
310
  if OpenPorts:
308
311
  for i in OpenPorts:
309
312
  print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
@@ -314,9 +317,9 @@ def run():
314
317
  portsopen = 0
315
318
  print("-" * 60)
316
319
  else:
317
- print(f"{host}".center(60, "-"))
318
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
319
- portsclosed = 0
320
- print(f"Open{colored('|√|','green')}:{portsopen}")
321
- portsopen = 0
322
- print("-" * 60)
320
+ print(f"{host}".center(60, "-"))
321
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
322
+ portsclosed = 0
323
+ print(f"Open{colored('|√|','green')}:{portsopen}")
324
+ portsopen = 0
325
+ print("-" * 60)
File without changes
File without changes