SnakeScan 1.6.3__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.3
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.
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()
@@ -24,21 +26,30 @@ SnakeScan.run()
24
26
  ## Help
25
27
  - -l need internet to view public ip you device
26
28
  - -t threading port search
29
+ - -s single search ports
27
30
  - -i information about host
28
31
  - -help in host /-help port in host
29
32
  - -check [host] scan subnet in ip
30
33
  - exit in host or port off script
31
34
  ## Added class Watcher:
32
35
  ```
33
- for SnakeScan import Watcher
34
- Watcher(host:str,port:int)
36
+ from SnakeScan import Watcher
37
+ Watcher = Watcher(host="localhost",port="80",timeout=1)
38
+ Watcher.start()
39
+ ```
40
+ ## Watcher commands
41
+ ```
42
+ Watcher.start() - Starts checking ports
43
+ Watcher.stop() - Stops port checking
35
44
  ```
36
45
  ## Added multiple use Watcher:
37
46
  ```
38
47
  from SnakeScan import Watcher
39
48
  ports=[53,80,100,160]
49
+ Watchers=[]
40
50
  for i in range(len(ports)):
41
- Watcher("127.0.0.1",ports[i])
51
+ Watchers.append(Watcher("127.0.0.1",ports[i]))
52
+ Watchers[i].start()
42
53
  ```
43
54
  ## Added CLI command line use snake or Snake
44
55
  ```
@@ -62,10 +73,19 @@ options:
62
73
  -ch, --check scan subnet
63
74
  -l, --local view you public ip - need internet
64
75
  ```
65
- ## Attributes
76
+ ## Attributes snake-Snake
77
+ ```
78
+ -p:snake -p 80,443,3437,20-1000,300-400
79
+ -p:[20]-1000 will start from [21]-[1000]
80
+ -h:snake -h [snake usage]
81
+ -sp:snake -sp [use processpoolexecutir to scan host]
82
+ -v:snake -v [Build_version]
83
+ -t:snake -t [use thread pool to scan]
84
+ -ch:snake -ch [scan subnet in host]
85
+ -l:snake -l [view you public ip and to view need on internet]
86
+ -i:snake www.google.com -i [info ip of host]
87
+ All:snake -p 100,200,79-443 www.google.com -i -l -t -ch -sp
66
88
  ```
67
- --p:snake -p 80,443,3437,20-1000
68
- --p:[20]-1000 will start from [21]-[1000]
69
89
  ## Added Info about ipv6
70
90
  ```
71
91
  snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
@@ -0,0 +1,77 @@
1
+ # SnakeScan
2
+ Use to scan Ports and use carefully
3
+ ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
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! \|•√•|/
7
+ ```
8
+ import SnakeScan
9
+ SnakeScan.run()
10
+ ```
11
+ ## Help
12
+ - -l need internet to view public ip you device
13
+ - -t threading port search
14
+ - -s single search ports
15
+ - -i information about host
16
+ - -help in host /-help port in host
17
+ - -check [host] scan subnet in ip
18
+ - exit in host or port off script
19
+ ## Added class Watcher:
20
+ ```
21
+ from SnakeScan import Watcher
22
+ Watcher = Watcher(host="localhost",port="80",timeout=1)
23
+ Watcher.start()
24
+ ```
25
+ ## Watcher commands
26
+ ```
27
+ Watcher.start() - Starts checking ports
28
+ Watcher.stop() - Stops port checking
29
+ ```
30
+ ## Added multiple use Watcher:
31
+ ```
32
+ from SnakeScan import Watcher
33
+ ports=[53,80,100,160]
34
+ Watchers=[]
35
+ for i in range(len(ports)):
36
+ Watchers.append(Watcher("127.0.0.1",ports[i]))
37
+ Watchers[i].start()
38
+ ```
39
+ ## Added CLI command line use snake or Snake
40
+ ```
41
+ usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
42
+ [-l]
43
+ [host]
44
+
45
+ Snake - It's a command line module SnakeScan. Use him for
46
+ more fast starting
47
+
48
+ positional arguments:
49
+ host
50
+
51
+ options:
52
+ -h, --help show this help message and exit
53
+ -sp, --speed speed scan
54
+ -v, --version version
55
+ -i, --info ip info
56
+ -p, --ports PORTS range ports to scan host
57
+ -t, --thread fast scan
58
+ -ch, --check scan subnet
59
+ -l, --local view you public ip - need internet
60
+ ```
61
+ ## Attributes snake-Snake
62
+ ```
63
+ -p:snake -p 80,443,3437,20-1000,300-400
64
+ -p:[20]-1000 will start from [21]-[1000]
65
+ -h:snake -h [snake usage]
66
+ -sp:snake -sp [use processpoolexecutir to scan host]
67
+ -v:snake -v [Build_version]
68
+ -t:snake -t [use thread pool to scan]
69
+ -ch:snake -ch [scan subnet in host]
70
+ -l:snake -l [view you public ip and to view need on internet]
71
+ -i:snake www.google.com -i [info ip of host]
72
+ All:snake -p 100,200,79-443 www.google.com -i -l -t -ch -sp
73
+ ```
74
+ ## Added Info about ipv6
75
+ ```
76
+ snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
77
+ ```
@@ -66,7 +66,7 @@ ports = {
66
66
  8080: "Tomcat",
67
67
  10000: "Webmin",
68
68
  }
69
- version = "1.6.2"
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,9 +1,10 @@
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. """
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.3"
3
+ __version__ = "1.6.5"
4
4
  import socket
5
5
  import ipaddress
6
6
  from art import tprint
7
+ from time import sleep
7
8
  from tqdm import tqdm
8
9
  from termcolor import colored
9
10
  from threading import Thread
@@ -11,35 +12,50 @@ from SnakeScan.Check_subnet import Check_network
11
12
 
12
13
 
13
14
  class Watcher:
14
- def __init__(self, host, port_user):
15
- self.host = host
16
- self.port_user = port_user
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
17
21
 
18
- def run(host, port_user):
19
- previous = None
20
- while True:
22
+ def run(self):
23
+ # Basic process of connecting to a host and checking the port
24
+ previous = None
25
+ while self.work:
26
+ try:
21
27
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
22
- connection = sock.connect_ex((host, port_user))
28
+ connection = sock.connect_ex((self.host, self.port_user))
23
29
  if previous != connection:
24
30
  if connection == 0:
25
- print(f"Service is up {host}-->|{port_user}|")
31
+ print(f"Service is up {self.host}-->|{self.port_user}|")
26
32
  else:
27
- print(f"Service is down {host}-->|{port_user}|")
33
+ print(f"Service is down {self.host}-->|{self.port_user}|")
28
34
  previous = connection
35
+ except Exception as e:
36
+ print(f"Unable to create scanner object:{e}")
37
+ sleep(self.timeout)
29
38
 
30
- w = Thread(target=run, kwargs={"host": self.host, "port_user": self.port_user})
31
- w.start()
39
+ def start(self):
40
+ # Run a port check to see if it is running or offline.
41
+ self.work = True
42
+ self.thread = Thread(target=self.run)
43
+ self.thread.start()
44
+
45
+ def stop(self):
46
+ # Stops port checking
47
+ self.work = False
48
+ self.thread.join()
32
49
 
33
50
 
34
51
  def run():
35
52
  portsopen = 0
36
53
  portsclosed = 0
37
54
  Run_now = True
38
-
39
-
55
+
40
56
  global num
41
57
  num = 0
42
-
58
+
43
59
  OpenPorts = []
44
60
  threads = []
45
61
  ports = {
@@ -84,26 +100,28 @@ def run():
84
100
  8080: "Tomcat",
85
101
  10000: "Webmin",
86
102
  }
103
+
87
104
  def Ports(str=""):
88
- rangeports=[]
89
- port=[]
90
- str=str.split(",")
105
+ rangeports = []
106
+ port = []
107
+ str = str.split(",")
91
108
  for p in range(len(str)):
92
- if "-" in str[p]:
93
- rangeports.append(str[p])
94
- else:
95
- port.append(str[p])
109
+ if "-" in str[p]:
110
+ rangeports.append(str[p])
111
+ else:
112
+ port.append(str[p])
96
113
  for n in range(len(port)):
97
114
  for i in string.punctuation:
98
115
  if i in port[n]:
99
- port[n]=port[n].replace(i,"")
116
+ port[n] = port[n].replace(i, "")
100
117
  for r in range(len(rangeports)):
101
- rangeport=rangeports[r].split("-")
118
+ rangeport = rangeports[r].split("-")
102
119
  try:
103
- return rangeport,port
120
+ return rangeport, port
104
121
  except Exception as e:
105
122
  print("Error: invalid value")
106
123
  sys.exit()
124
+
107
125
  def is_port_open(host, port):
108
126
  with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
109
127
  try:
@@ -248,7 +266,6 @@ def run():
248
266
  t.start()
249
267
  for t in threads:
250
268
  t.join()
251
-
252
269
 
253
270
  else:
254
271
  if "-t" in port_user:
@@ -267,29 +284,29 @@ def run():
267
284
  length = port_user
268
285
  print(f"{colored('|!|','red')}Listening {host} please wait...")
269
286
  # |----------------starting---------------------|
270
- rangeports,port_user=Ports(port_user)
287
+ rangeports, port_user = Ports(port_user)
271
288
  for i in range(len(port_user)):
272
- port_user[i]=int(port_user[i])
289
+ port_user[i] = int(port_user[i])
273
290
  for port in range(len(port_user)):
274
- 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:
275
297
  print(
276
- 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]}|"
277
299
  )
278
- else:
279
- try:
280
- print(
281
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
282
- )
283
- except:
284
- print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
285
- 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)):
286
303
  if is_port_open(host, port):
287
304
  for name in ports:
288
305
  if port == name:
289
306
  OpenPorts = [port]
290
307
  portsopen += 1
291
308
  else:
292
- portsclosed += 1
309
+ portsclosed += 1
293
310
  if OpenPorts:
294
311
  for i in OpenPorts:
295
312
  print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
@@ -300,9 +317,9 @@ def run():
300
317
  portsopen = 0
301
318
  print("-" * 60)
302
319
  else:
303
- print(f"{host}".center(60, "-"))
304
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
305
- portsclosed = 0
306
- print(f"Open{colored('|√|','green')}:{portsopen}")
307
- portsopen = 0
308
- 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)
snakescan-1.6.3/README.md DELETED
@@ -1,57 +0,0 @@
1
- # SnakeScan
2
- ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
3
- ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
4
- ![License](https://img.shields.io/badge/License-MIT-blue.svg)
5
- ```
6
- import SnakeScan
7
- SnakeScan.run()
8
- ```
9
- ## Help
10
- - -l need internet to view public ip you device
11
- - -t threading port search
12
- - -i information about host
13
- - -help in host /-help port in host
14
- - -check [host] scan subnet in ip
15
- - exit in host or port off script
16
- ## Added class Watcher:
17
- ```
18
- for SnakeScan import Watcher
19
- Watcher(host:str,port:int)
20
- ```
21
- ## Added multiple use Watcher:
22
- ```
23
- from SnakeScan import Watcher
24
- ports=[53,80,100,160]
25
- for i in range(len(ports)):
26
- Watcher("127.0.0.1",ports[i])
27
- ```
28
- ## Added CLI command line use snake or Snake
29
- ```
30
- usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
31
- [-l]
32
- [host]
33
-
34
- Snake - It's a command line module SnakeScan. Use him for
35
- more fast starting
36
-
37
- positional arguments:
38
- host
39
-
40
- options:
41
- -h, --help show this help message and exit
42
- -sp, --speed speed scan
43
- -v, --version version
44
- -i, --info ip info
45
- -p, --ports PORTS range ports to scan host
46
- -t, --thread fast scan
47
- -ch, --check scan subnet
48
- -l, --local view you public ip - need internet
49
- ```
50
- ## Attributes
51
- ```
52
- --p:snake -p 80,443,3437,20-1000
53
- --p:[20]-1000 will start from [21]-[1000]
54
- ## Added Info about ipv6
55
- ```
56
- snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
57
- ```
File without changes
File without changes