SnakeScan 1.6.7__tar.gz → 1.6.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,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SnakeScan
3
- Version: 1.6.7
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.9
4
+ Summary: IPv4 address scanner for collecting address information.Use carefully for your network safety.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
@@ -17,12 +17,14 @@ Project-URL: Repository, https://github.com/Den-Ram/SnakeScan
17
17
  ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
18
18
  ![License](https://img.shields.io/badge/License-MIT-blue.svg)
19
19
  ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
20
- ![Status](https://img.shields.io/badge/State-In%20development-yellow)
21
- ![Platforms](https://img.shields.io/badge/Platforms-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey)
22
- #Description
23
- Use to scan Ports and use carefully.Use the library in the terminal, because that's what it's focused on. If you don't want to use the terminal, run it in code, but then some new functions won't be present there.You will need to use it differently.
24
- # Help with using the library
25
- ## If you use the library directly in your code:
20
+ ![Status](https://img.shields.io/badge/%20Beta-orange)
21
+ ![Platforms](https://img.shields.io/badge/Platforms-macOS%20%7C%20Linux%20%7C%20Windows-blue)
22
+
23
+ Use the library in the terminal, because that's what it's focused on. If you don't want to use the terminal, run it in code, but then some new functions won't be present there.You will need to use it differently.
24
+
25
+ ## Help with using the library
26
+
27
+ ### If you use the library directly in your code:
26
28
  ```
27
29
  import SnakeScan
28
30
  SnakeScan.run()
@@ -35,11 +37,17 @@ SnakeScan.run()
35
37
  - -check [host] scan subnet in ip
36
38
  - exit in host or port off script
37
39
 
38
- ## Watcher commands
40
+ ### Watcher commands
39
41
  ```
40
42
  Watcher.start() - Starts checking ports
41
43
  Watcher.stop() - Stops port checking
42
44
  ```
45
+ ### Watcher
46
+ ```
47
+ from SnakeScan import Watcher
48
+ watcher = Watcher("localhost",53,2)
49
+ watcher.start()
50
+ ```
43
51
  ## Help with attributes
44
52
  ```
45
53
  -P:
@@ -57,57 +65,12 @@ snake -v #Shows the library version
57
65
  -GS:
58
66
  snake www.google.com -gs #Get a certificate from the official website. If you don't enter the hostname, you'll get this error [Errno 111] Connection refused
59
67
  -T:
60
- snake -t #Uses streams for port scanning
68
+ snake -t #Uses threads for port scanning
61
69
  -CH:
62
70
  snake -ch #Scans the subnet for others IP
63
71
  -L:
64
72
  snake -l #Shows your public internet IP address. Internet connection required for use
65
73
  -I:
66
74
  snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
67
- #You can also use all attributes in place:
68
- ```
69
- snake -p 100,200,79-443 www.google.com -i -l -t -ch -sp
70
- ```
71
- # Library changes
72
-
73
- ## Added class Watcher:
74
- ```
75
- from SnakeScan import Watcher
76
- Watcher = Watcher(host="localhost",port="80",timeout=1)
77
- Watcher.start()
78
- ```
79
- ## Added multiple use Watcher:
80
- ```
81
- from SnakeScan import Watcher
82
- ports=[53,80,100,160]
83
- Watchers=[]
84
- for i in range(len(ports)):
85
- Watchers.append(Watcher("127.0.0.1",ports[i]))
86
- Watchers[i].start()
87
- ```
88
- ## Library added for use in terminal to use enter snake or Snake
89
- ```
90
- usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
91
- [-l]
92
- [host]
93
-
94
- Snake - It's a command line module SnakeScan. Use him for
95
- more fast starting
96
-
97
- positional arguments:
98
- host
99
-
100
- options:
101
- -h, --help show this help message and exit
102
- -sp, --speed speed scan
103
- -v, --version version
104
- -i, --info ip info
105
- -p, --ports PORTS range ports to scan host
106
- -t, --thread fast scan
107
- -ch, --check scan subnet
108
- -l, --local view you public ip - need internet
109
- ```
110
- ## Added Info about ipv6
111
- ```
112
- snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
113
- ```
75
+ ##Update in 1.6.9
76
+ - Added support for multi-hosting: snake www.google.com,www.example.com -i -p 53,80,443,0-1000 -ch -sp -t
@@ -2,12 +2,14 @@
2
2
  ![PyPI version](https://badge.fury.io/py/SnakeScan.svg)
3
3
  ![License](https://img.shields.io/badge/License-MIT-blue.svg)
4
4
  ![Requires-python](https://img.shields.io/badge/requires--python-3.7+-red)
5
- ![Status](https://img.shields.io/badge/State-In%20development-yellow)
6
- ![Platforms](https://img.shields.io/badge/Platforms-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey)
7
- #Description
8
- Use to scan Ports and use carefully.Use the library in the terminal, because that's what it's focused on. If you don't want to use the terminal, run it in code, but then some new functions won't be present there.You will need to use it differently.
9
- # Help with using the library
10
- ## If you use the library directly in your code:
5
+ ![Status](https://img.shields.io/badge/%20Beta-orange)
6
+ ![Platforms](https://img.shields.io/badge/Platforms-macOS%20%7C%20Linux%20%7C%20Windows-blue)
7
+
8
+ Use the library in the terminal, because that's what it's focused on. If you don't want to use the terminal, run it in code, but then some new functions won't be present there.You will need to use it differently.
9
+
10
+ ## Help with using the library
11
+
12
+ ### If you use the library directly in your code:
11
13
  ```
12
14
  import SnakeScan
13
15
  SnakeScan.run()
@@ -20,11 +22,17 @@ SnakeScan.run()
20
22
  - -check [host] scan subnet in ip
21
23
  - exit in host or port off script
22
24
 
23
- ## Watcher commands
25
+ ### Watcher commands
24
26
  ```
25
27
  Watcher.start() - Starts checking ports
26
28
  Watcher.stop() - Stops port checking
27
29
  ```
30
+ ### Watcher
31
+ ```
32
+ from SnakeScan import Watcher
33
+ watcher = Watcher("localhost",53,2)
34
+ watcher.start()
35
+ ```
28
36
  ## Help with attributes
29
37
  ```
30
38
  -P:
@@ -42,57 +50,12 @@ snake -v #Shows the library version
42
50
  -GS:
43
51
  snake www.google.com -gs #Get a certificate from the official website. If you don't enter the hostname, you'll get this error [Errno 111] Connection refused
44
52
  -T:
45
- snake -t #Uses streams for port scanning
53
+ snake -t #Uses threads for port scanning
46
54
  -CH:
47
55
  snake -ch #Scans the subnet for others IP
48
56
  -L:
49
57
  snake -l #Shows your public internet IP address. Internet connection required for use
50
58
  -I:
51
59
  snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
52
- #You can also use all attributes in place:
53
- ```
54
- snake -p 100,200,79-443 www.google.com -i -l -t -ch -sp
55
- ```
56
- # Library changes
57
-
58
- ## Added class Watcher:
59
- ```
60
- from SnakeScan import Watcher
61
- Watcher = Watcher(host="localhost",port="80",timeout=1)
62
- Watcher.start()
63
- ```
64
- ## Added multiple use Watcher:
65
- ```
66
- from SnakeScan import Watcher
67
- ports=[53,80,100,160]
68
- Watchers=[]
69
- for i in range(len(ports)):
70
- Watchers.append(Watcher("127.0.0.1",ports[i]))
71
- Watchers[i].start()
72
- ```
73
- ## Library added for use in terminal to use enter snake or Snake
74
- ```
75
- usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
76
- [-l]
77
- [host]
78
-
79
- Snake - It's a command line module SnakeScan. Use him for
80
- more fast starting
81
-
82
- positional arguments:
83
- host
84
-
85
- options:
86
- -h, --help show this help message and exit
87
- -sp, --speed speed scan
88
- -v, --version version
89
- -i, --info ip info
90
- -p, --ports PORTS range ports to scan host
91
- -t, --thread fast scan
92
- -ch, --check scan subnet
93
- -l, --local view you public ip - need internet
94
- ```
95
- ## Added Info about ipv6
96
- ```
97
- snake 2001:db8:: -i or snake [2001:4860:4860::8888] -i
98
- ```
60
+ ##Update in 1.6.9
61
+ - Added support for multi-hosting: snake www.google.com,www.example.com -i -p 53,80,443,0-1000 -ch -sp -t
@@ -0,0 +1,344 @@
1
+ import sys
2
+ import string
3
+ import argparse
4
+ import socket
5
+ import ipaddress
6
+ from concurrent.futures import ProcessPoolExecutor
7
+ from termcolor import colored
8
+ from threading import Thread
9
+ from tqdm import tqdm
10
+ from SnakeScan.Check_subnet import Check_network
11
+ from SnakeScan.PoolExecutor import PoolProcessExecutor
12
+ from SnakeScan.Get_ssl import Get_ssl
13
+
14
+
15
+ def main():
16
+ pass
17
+
18
+
19
+ if __name__ == "__main__":
20
+ main()
21
+ OpenPorts = []
22
+ threads = []
23
+ portsopen = 0
24
+ portsclosed = 0
25
+ Bool = True
26
+ boolsd = True
27
+ boolean = 0
28
+ ports = {
29
+ 20: "FTP-DATA",
30
+ 21: "FTP",
31
+ 22: "SSH",
32
+ 23: "Telnet",
33
+ 25: "SMTP",
34
+ 43: "WHOIS",
35
+ 53: "DNS",
36
+ 67: "DHCP",
37
+ 68: "DHCP",
38
+ 69: "TFTP",
39
+ 80: "http",
40
+ 110: "POP3",
41
+ 115: "SFTP",
42
+ 123: "NTP",
43
+ 139: "NetBios",
44
+ 143: "IMAP",
45
+ 161: "SNMP",
46
+ 179: "BGP",
47
+ 443: "HTTPS",
48
+ 445: "MICROSOFT-DS",
49
+ 465: "SSL/TLS",
50
+ 514: "SYSLOG",
51
+ 515: "PRINTER",
52
+ 554: "RTSP",
53
+ 587: "TLS/STARTTLS",
54
+ 636: "LDAPS",
55
+ 990: "FTPS",
56
+ 993: "IMAPS",
57
+ 995: "POP3S",
58
+ 1080: "SOCKS",
59
+ 1194: "OpenVPN",
60
+ 1433: "SQL Server",
61
+ 1723: "PPTP",
62
+ 2222: "SSH",
63
+ 3128: "HTTP",
64
+ 3268: "LDAP",
65
+ 3306: "MySQL",
66
+ 3389: "RDP",
67
+ 5432: "PostgreSQL",
68
+ 5900: "VNC",
69
+ 8080: "Tomcat",
70
+ 10000: "Webmin",
71
+ }
72
+ version = "1.6.9"
73
+
74
+
75
+ def is_port_open(host, port):
76
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
77
+ try:
78
+ s.settimeout(1)
79
+ s.connect((host, port))
80
+ except (OSError, socket.timeout):
81
+ return False
82
+ else:
83
+ return True
84
+
85
+
86
+ def is_port_open_threads(host, port):
87
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
88
+ try:
89
+ s.settimeout(1)
90
+ s.connect((host, port))
91
+ except (OSError, socket.timeout):
92
+ try:
93
+ print(f"Closed{colored('|X|','red')}-->{ports.get(port)}|{port}|")
94
+ except:
95
+ print(f"Closed{colored('|X|','red')}-->|{port}|")
96
+ else:
97
+ print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
98
+
99
+
100
+ def Ports(str=""):
101
+ rangeports = []
102
+ rangeport = []
103
+ port = []
104
+ doneports = []
105
+ str = str.split(",")
106
+ for p in range(len(str)):
107
+ if "-" in str[p]:
108
+ rangeports.append(str[p])
109
+ else:
110
+ port.append(str[p])
111
+ for n in range(len(port)):
112
+ for i in string.punctuation:
113
+ if i in port[n]:
114
+ port[n] = port[n].replace(i, "")
115
+ for r in range(len(rangeports)):
116
+ rangeport = rangeports[r].split("-")
117
+ for i in range(len(rangeport)):
118
+ doneports.append(rangeport[i])
119
+ try:
120
+ return doneports, port
121
+ except Exception as e:
122
+ rangeport = ""
123
+ return doneports, port
124
+ sys.exit()
125
+
126
+
127
+ def SnakeArgs():
128
+ parser = argparse.ArgumentParser(
129
+ description="Snake - It's a command line module SnakeScan. Use him for more fast starting"
130
+ )
131
+ parser.add_argument("host", nargs="?", default="None")
132
+ parser.add_argument(
133
+ "-gs", "--getssl", action="store_true", help="get official ssl certificate"
134
+ )
135
+ parser.add_argument("-sp", "--speed", action="store_true", help="speed scan")
136
+ parser.add_argument("-v", "--version", action="store_true", help="version")
137
+ parser.add_argument("-i", "--info", action="store_true", help="ip info")
138
+ parser.add_argument("-p", "--ports", help="range ports to scan host")
139
+ parser.add_argument("-t", "--thread", action="store_true", help="fast scan")
140
+ parser.add_argument("-ch", "--check", action="store_true", help="scan subnet")
141
+ parser.add_argument(
142
+ "-l",
143
+ "--local",
144
+ action="store_true",
145
+ help="view you public ip - need internet",
146
+ )
147
+ args = parser.parse_args()
148
+ return args
149
+
150
+
151
+ port_user = SnakeArgs().ports
152
+ host = SnakeArgs().host
153
+ host=host.split(",")
154
+ for n in range(len(host)):
155
+ if host[n].startswith("http://"):
156
+ host[n] = host[n].strip()
157
+ host[n] = host[n].split("http:")
158
+ host[n] = host[n][1].strip("//")
159
+ host[n] = host[n].split("/")
160
+ host[n] = host[n][0]
161
+ for i in range(len(host)):
162
+ if host[n][i] == "/":
163
+ host[n] = host[n][0:i]
164
+ for n in range(len(host)):
165
+ if host[n].startswith("https://"):
166
+ host[n] = host[n].strip()
167
+ host[n] = host[n].split("https:")
168
+ host[n] = host[n][1].strip("//")
169
+ host[n] = host[n].split("/")
170
+ host[n] = host[n][0]
171
+ for i in range(len(host)):
172
+ if host[n][i] == "/":
173
+ host[n] = host[n][0:i]
174
+ if host[0] == "None":
175
+ host[0] = "localhost"
176
+ if SnakeArgs().ports:
177
+ rangeports, port_user = Ports(port_user)
178
+ for i in range(len(port_user)):
179
+ port_user[i] = int(port_user[i])
180
+ for n in range(len(host)):
181
+ for port in range(len(port_user)):
182
+ if is_port_open(host[n], port_user[port]):
183
+ print(
184
+ f"Open{colored('|√|','green')}{host[n]}-->{ports[port_user[port]]}|{port_user[port]}|"
185
+ )
186
+ else:
187
+ try:
188
+ print(
189
+ f"Closed{colored('|X|','red')}{host[n]}-->{ports[port_user[port]]}|{port_user[port]}|"
190
+ )
191
+ except:
192
+ print(f"Closed{colored('|X|','red')}{host[n]}-->|{port_user[port]}|")
193
+ try:
194
+ first = rangeports[::2]
195
+ second = rangeports[1::2]
196
+ minimal = min(len(first), len(second))
197
+ for i in range(minimal):
198
+ if int(first[i]) > int(second[i]):
199
+ number = second[i]
200
+ second[i] = first[i]
201
+ first[i] = number
202
+ for i in range(minimal):
203
+ for port in tqdm(range(int(first[i]) + 1, int(second[i]) + 1)):
204
+ if is_port_open(host[n], port):
205
+ for name in ports:
206
+ if port == name:
207
+ OpenPorts = [port]
208
+ portsopen += 1
209
+ else:
210
+ portsclosed += 1
211
+ if OpenPorts:
212
+ for i in OpenPorts:
213
+ print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
214
+ print(f"{host[n]}".center(60, "-"))
215
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
216
+ portsclosed = 0
217
+ print(f"Open{colored('|√|','green')}:{portsopen}")
218
+ portsopen = 0
219
+ print("-" * 60)
220
+ else:
221
+ print(f"{host[n]}".center(60, "-"))
222
+ print(f"Closed{colored('|X|','red')}:{portsclosed}")
223
+ portsclosed = 0
224
+ print(f"Open{colored('|√|','green')}:{portsopen}")
225
+ portsopen = 0
226
+ print("-" * 60)
227
+ except Exception as e:
228
+ print(e)
229
+ sys.exit()
230
+ if SnakeArgs().check:
231
+ for n in range(len(host)):
232
+ Check_network(host[n])
233
+ if SnakeArgs().local:
234
+ local = ""
235
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
236
+ try:
237
+ s.connect(("10.255.255.255", 1))
238
+ local = s.getsockname()[0]
239
+ except Exception as e:
240
+ local = f"127.0.0.1:{e}"
241
+ finally:
242
+ s.close()
243
+ print(local)
244
+ if SnakeArgs().info:
245
+ if host[0] == "None":
246
+ host[0] = "localhost"
247
+ for n in range(len(host)):
248
+ print("".center(60, "-"))
249
+ try:
250
+ host[n] = socket.gethostbyname(host[n])
251
+ except Exception as e:
252
+ try:
253
+ hostname, list, iplist = socket.gethostbyaddr(host[n])
254
+ except Exception as e:
255
+ if host[n].startswith("[") and host[n].endswith("]"):
256
+ host[n] = host[n][1:-1]
257
+ else:
258
+ host[n] = host[n].split("[")
259
+ for i in range(len(host)):
260
+ host[n] = host[n][i - 1].split("]")
261
+ host[n] = host[n][0]
262
+ try:
263
+ hostname, list, iplist = socket.gethostbyaddr(host[n])
264
+ except Exception as e:
265
+ print(e)
266
+ sys.exit()
267
+
268
+ hosting = ""
269
+ hosting = host[n].split(".")
270
+ hosting[len(hosting) - 1] = "0"
271
+ network = ""
272
+ for i in range(len(hosting) - 1):
273
+ network += hosting[i] + "."
274
+ network += "0"
275
+ network += "/24"
276
+ hosting = network
277
+ try:
278
+ if host[n].startswith("[") and host[n].endswith("]"):
279
+ host[n] = host[n][1:-1]
280
+ else:
281
+ host[n] = host[n].split("[")
282
+ for i in range(len(host)):
283
+ host[n] = host[n][i - 1].split("]")
284
+ host[n] = host[n][0]
285
+ ip_obj = ipaddress.ip_address(host[n])
286
+ if ip_obj.version == 6:
287
+
288
+ try:
289
+ network = host[n] + "/64"
290
+ network_obj = ipaddress.ip_network(network)
291
+ except Exception as e:
292
+ pass
293
+ try:
294
+ network = host[n] + "/128"
295
+ network_obj = ipaddress.ip_network(network)
296
+ except Exception as e:
297
+ pass
298
+ except Exception as e:
299
+ print(e)
300
+ print(f"Type IP: {type(ip_obj)}")
301
+ print(f"Version IP: {ip_obj.version}")
302
+ network_obj = ipaddress.ip_network(network)
303
+ print(f"Network: {network_obj}")
304
+ print(f"Subnet mask: {network_obj.netmask}")
305
+ try:
306
+ hostname = socket.gethostbyaddr(host[n])
307
+ print(f"Host:{hostname[0]}")
308
+ except:
309
+ hostname = "Undefined"
310
+ print(f"Host:{hostname}")
311
+ try:
312
+ print(f"IP:{socket.gethostbyname(host[n])}")
313
+ except Exception as e:
314
+ try:
315
+ hostname, list, iplist = socket.gethostbyaddr(host[n])
316
+ print(f"IP:{socket.gethostbyname(hostname)}")
317
+ except:
318
+ pass
319
+ finally:
320
+ print("".center(60, "-"))
321
+
322
+
323
+ if SnakeArgs().thread:
324
+ for n in range(len(host)):
325
+ print(f"{host[n]}".center(60, "-"))
326
+
327
+ for port in ports.keys():
328
+ t = Thread(
329
+ target=is_port_open_threads,
330
+ kwargs={"host": host[n], "port": port},
331
+ )
332
+ threads.append(t)
333
+ t.start()
334
+ for t in threads:
335
+ t.join()
336
+ if SnakeArgs().version:
337
+ print(f"Build_{version}")
338
+ if SnakeArgs().speed:
339
+ for n in range(len(host)):
340
+ print(f"{host[n]}".center(60, "-"))
341
+ PoolProcessExecutor(host[n])
342
+ if SnakeArgs().getssl:
343
+ for n in range(len(host)):
344
+ Get_ssl(host[n])
@@ -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.Scan only IPv4 or get the IPv4 address from the IPv6 host"""
2
2
 
3
- __version__ = "1.6.7"
3
+ __version__ = "1.6.9"
4
4
  import socket
5
5
  import ipaddress
6
6
  from art import tprint
@@ -47,7 +47,7 @@ class Watcher:
47
47
  self.work = False
48
48
  self.thread.join()
49
49
 
50
-
50
+ #Run SnakeScan
51
51
  def run():
52
52
  portsopen = 0
53
53
  portsclosed = 0
@@ -1,336 +0,0 @@
1
- import sys
2
- import string
3
- import argparse
4
- import socket
5
- import ipaddress
6
- from concurrent.futures import ProcessPoolExecutor
7
- from termcolor import colored
8
- from threading import Thread
9
- from tqdm import tqdm
10
- from SnakeScan.Check_subnet import Check_network
11
- from SnakeScan.PoolExecutor import PoolProcessExecutor
12
- from SnakeScan.Get_ssl import Get_ssl
13
-
14
-
15
- def main():
16
- pass
17
-
18
-
19
- if __name__ == "__main__":
20
- main()
21
- OpenPorts = []
22
- threads = []
23
- portsopen = 0
24
- portsclosed = 0
25
- Bool = True
26
- boolsd = True
27
- boolean = 0
28
- ports = {
29
- 20: "FTP-DATA",
30
- 21: "FTP",
31
- 22: "SSH",
32
- 23: "Telnet",
33
- 25: "SMTP",
34
- 43: "WHOIS",
35
- 53: "DNS",
36
- 67: "DHCP",
37
- 68: "DHCP",
38
- 69: "TFTP",
39
- 80: "http",
40
- 110: "POP3",
41
- 115: "SFTP",
42
- 123: "NTP",
43
- 139: "NetBios",
44
- 143: "IMAP",
45
- 161: "SNMP",
46
- 179: "BGP",
47
- 443: "HTTPS",
48
- 445: "MICROSOFT-DS",
49
- 465: "SSL/TLS",
50
- 514: "SYSLOG",
51
- 515: "PRINTER",
52
- 554: "RTSP",
53
- 587: "TLS/STARTTLS",
54
- 636: "LDAPS",
55
- 990: "FTPS",
56
- 993: "IMAPS",
57
- 995: "POP3S",
58
- 1080: "SOCKS",
59
- 1194: "OpenVPN",
60
- 1433: "SQL Server",
61
- 1723: "PPTP",
62
- 2222: "SSH",
63
- 3128: "HTTP",
64
- 3268: "LDAP",
65
- 3306: "MySQL",
66
- 3389: "RDP",
67
- 5432: "PostgreSQL",
68
- 5900: "VNC",
69
- 8080: "Tomcat",
70
- 10000: "Webmin",
71
- }
72
- version = "1.6.7"
73
-
74
-
75
- def is_port_open(host, port):
76
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
77
- try:
78
- s.settimeout(1)
79
- s.connect((host, port))
80
- except (OSError, socket.timeout):
81
- return False
82
- else:
83
- return True
84
-
85
-
86
- def is_port_open_threads(host, port):
87
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
88
- try:
89
- s.settimeout(1)
90
- s.connect((host, port))
91
- except (OSError, socket.timeout):
92
- try:
93
- print(f"Closed{colored('|X|','red')}-->{ports.get(port)}|{port}|")
94
- except:
95
- print(f"Closed{colored('|X|','red')}-->|{port}|")
96
- else:
97
- print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
98
-
99
-
100
- def Ports(str=""):
101
- rangeports = []
102
- rangeport = []
103
- port = []
104
- doneports = []
105
- str = str.split(",")
106
- for p in range(len(str)):
107
- if "-" in str[p]:
108
- rangeports.append(str[p])
109
- else:
110
- port.append(str[p])
111
- for n in range(len(port)):
112
- for i in string.punctuation:
113
- if i in port[n]:
114
- port[n] = port[n].replace(i, "")
115
- for r in range(len(rangeports)):
116
- rangeport = rangeports[r].split("-")
117
- for i in range(len(rangeport)):
118
- doneports.append(rangeport[i])
119
- try:
120
- return doneports, port
121
- except Exception as e:
122
- rangeport = ""
123
- return doneports, port
124
- sys.exit()
125
-
126
-
127
- def SnakeArgs():
128
- parser = argparse.ArgumentParser(
129
- description="Snake - It's a command line module SnakeScan. Use him for more fast starting"
130
- )
131
- parser.add_argument("host", nargs="?", default="None")
132
- parser.add_argument(
133
- "-gs", "--getssl", action="store_true", help="get official ssl certificate"
134
- )
135
- parser.add_argument("-sp", "--speed", action="store_true", help="speed scan")
136
- parser.add_argument("-v", "--version", action="store_true", help="version")
137
- parser.add_argument("-i", "--info", action="store_true", help="ip info")
138
- parser.add_argument("-p", "--ports", help="range ports to scan host")
139
- parser.add_argument("-t", "--thread", action="store_true", help="fast scan")
140
- parser.add_argument("-ch", "--check", action="store_true", help="scan subnet")
141
- parser.add_argument(
142
- "-l",
143
- "--local",
144
- action="store_true",
145
- help="view you public ip - need internet",
146
- )
147
- args = parser.parse_args()
148
- return args
149
-
150
-
151
- port_user = SnakeArgs().ports
152
- host = SnakeArgs().host
153
- if host.startswith("http://"):
154
- host = host.strip()
155
- host = host.split("http:")
156
- host = host[1].strip("//")
157
- host = host.split("/")
158
- host = host[0]
159
- for i in range(len(host)):
160
- if host[i] == "/":
161
- host = host[0:i]
162
- if host.startswith("https://"):
163
- host = host.strip()
164
- host = host.split("https:")
165
- host = host[1].strip("//")
166
- host = host.split("/")
167
- host = host[0]
168
- for i in range(len(host)):
169
- if host[i] == "/":
170
- host = host[0:i]
171
- if host == "None":
172
- host = "localhost"
173
- if SnakeArgs().ports:
174
- rangeports, port_user = Ports(port_user)
175
- for i in range(len(port_user)):
176
- port_user[i] = int(port_user[i])
177
- for port in range(len(port_user)):
178
- if is_port_open(host, port_user[port]):
179
- print(
180
- f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
181
- )
182
- else:
183
- try:
184
- print(
185
- f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
186
- )
187
- except:
188
- print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
189
- try:
190
- first = rangeports[::2]
191
- second = rangeports[1::2]
192
- minimal = min(len(first), len(second))
193
- for i in range(minimal):
194
- if int(first[i]) > int(second[i]):
195
- number = second[i]
196
- second[i] = first[i]
197
- first[i] = number
198
- for i in range(minimal):
199
- for port in tqdm(range(int(first[i]) + 1, int(second[i]) + 1)):
200
- if is_port_open(host, port):
201
- for name in ports:
202
- if port == name:
203
- OpenPorts = [port]
204
- portsopen += 1
205
- else:
206
- portsclosed += 1
207
- if OpenPorts:
208
- for i in OpenPorts:
209
- print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
210
- print(f"{host}".center(60, "-"))
211
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
212
- portsclosed = 0
213
- print(f"Open{colored('|√|','green')}:{portsopen}")
214
- portsopen = 0
215
- print("-" * 60)
216
- else:
217
- print(f"{host}".center(60, "-"))
218
- print(f"Closed{colored('|X|','red')}:{portsclosed}")
219
- portsclosed = 0
220
- print(f"Open{colored('|√|','green')}:{portsopen}")
221
- portsopen = 0
222
- print("-" * 60)
223
- except Exception as e:
224
- print(e)
225
- sys.exit()
226
- if SnakeArgs().check:
227
- Check_network(host)
228
- if SnakeArgs().local:
229
- local = ""
230
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
231
- try:
232
- s.connect(("10.255.255.255", 1))
233
- local = s.getsockname()[0]
234
- except Exception as e:
235
- local = f"127.0.0.1:{e}"
236
- finally:
237
- s.close()
238
- print(local)
239
- if SnakeArgs().info:
240
- if host == "None":
241
- host = "localhost"
242
-
243
- print("".center(60, "-"))
244
- try:
245
- host = socket.gethostbyname(host)
246
- except Exception as e:
247
- try:
248
- hostname, list, iplist = socket.gethostbyaddr(host)
249
- except Exception as e:
250
- if host.startswith("[") and host.endswith("]"):
251
- host = host[1:-1]
252
- else:
253
- host = host.split("[")
254
- for i in range(len(host)):
255
- host = host[i - 1].split("]")
256
- host = host[0]
257
- try:
258
- hostname, list, iplist = socket.gethostbyaddr(host)
259
- except Exception as e:
260
- print(e)
261
- sys.exit()
262
-
263
- hosting = ""
264
- hosting = host.split(".")
265
- hosting[len(hosting) - 1] = "0"
266
- network = ""
267
- for i in range(len(hosting) - 1):
268
- network += hosting[i] + "."
269
- network += "0"
270
- network += "/24"
271
- hosting = network
272
- try:
273
- if host.startswith("[") and host.endswith("]"):
274
- host = host[1:-1]
275
- else:
276
- host = host.split("[")
277
- for i in range(len(host)):
278
- host = host[i - 1].split("]")
279
- host = host[0]
280
- ip_obj = ipaddress.ip_address(host)
281
- if ip_obj.version == 6:
282
-
283
- try:
284
- network = host + "/64"
285
- network_obj = ipaddress.ip_network(network)
286
- except Exception as e:
287
- pass
288
- try:
289
- network = host + "/128"
290
- network_obj = ipaddress.ip_network(network)
291
- except Exception as e:
292
- pass
293
- except Exception as e:
294
- print(e)
295
- print(f"Type IP: {type(ip_obj)}")
296
- print(f"Version IP: {ip_obj.version}")
297
- network_obj = ipaddress.ip_network(network)
298
- print(f"Network: {network_obj}")
299
- print(f"Subnet mask: {network_obj.netmask}")
300
- try:
301
- hostname = socket.gethostbyaddr(host)
302
- print(f"Host:{hostname[0]}")
303
- except:
304
- hostname = "Undefined"
305
- print(f"Host:{hostname}")
306
- try:
307
- print(f"IP:{socket.gethostbyname(host)}")
308
- except Exception as e:
309
- try:
310
- hostname, list, iplist = socket.gethostbyaddr(host)
311
- print(f"IP:{socket.gethostbyname(hostname)}")
312
- except:
313
- pass
314
- finally:
315
- print("".center(60, "-"))
316
-
317
-
318
- if SnakeArgs().thread:
319
- print(f"Thread".center(60, "-"))
320
-
321
- for port in ports.keys():
322
- t = Thread(
323
- target=is_port_open_threads,
324
- kwargs={"host": host, "port": port},
325
- )
326
- threads.append(t)
327
- t.start()
328
- for t in threads:
329
- t.join()
330
- if SnakeArgs().version:
331
- print(f"Build_{version}")
332
- if SnakeArgs().speed:
333
- print(f"ProcessPoolExecutor".center(60, "-"))
334
- PoolProcessExecutor(host)
335
- if SnakeArgs().getssl:
336
- Get_ssl(host)
File without changes
File without changes