SnakeScan 1.6.8__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.
- {snakescan-1.6.8 → snakescan-1.6.9}/PKG-INFO +14 -36
- {snakescan-1.6.8 → snakescan-1.6.9}/README.md +13 -35
- snakescan-1.6.9/SnakeScan/CLI.py +344 -0
- {snakescan-1.6.8 → snakescan-1.6.9}/SnakeScan/__init__.py +1 -1
- snakescan-1.6.8/SnakeScan/CLI.py +0 -336
- {snakescan-1.6.8 → snakescan-1.6.9}/LICENSE +0 -0
- {snakescan-1.6.8 → snakescan-1.6.9}/SnakeScan/Check_subnet.py +0 -0
- {snakescan-1.6.8 → snakescan-1.6.9}/SnakeScan/Get_ssl.py +0 -0
- {snakescan-1.6.8 → snakescan-1.6.9}/SnakeScan/PoolExecutor.py +0 -0
- {snakescan-1.6.8 → snakescan-1.6.9}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SnakeScan
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.9
|
|
4
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
|
|
@@ -16,15 +16,15 @@ Project-URL: Repository, https://github.com/Den-Ram/SnakeScan
|
|
|
16
16
|
# SnakeScan
|
|
17
17
|

|
|
18
18
|

|
|
19
|
-

|
|
20
|
+

|
|
21
21
|

|
|
22
22
|
|
|
23
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
24
|
|
|
25
|
-
|
|
25
|
+
## Help with using the library
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
### If you use the library directly in your code:
|
|
28
28
|
```
|
|
29
29
|
import SnakeScan
|
|
30
30
|
SnakeScan.run()
|
|
@@ -37,11 +37,17 @@ SnakeScan.run()
|
|
|
37
37
|
- -check [host] scan subnet in ip
|
|
38
38
|
- exit in host or port off script
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### Watcher commands
|
|
41
41
|
```
|
|
42
42
|
Watcher.start() - Starts checking ports
|
|
43
43
|
Watcher.stop() - Stops port checking
|
|
44
44
|
```
|
|
45
|
+
### Watcher
|
|
46
|
+
```
|
|
47
|
+
from SnakeScan import Watcher
|
|
48
|
+
watcher = Watcher("localhost",53,2)
|
|
49
|
+
watcher.start()
|
|
50
|
+
```
|
|
45
51
|
## Help with attributes
|
|
46
52
|
```
|
|
47
53
|
-P:
|
|
@@ -66,33 +72,5 @@ snake -ch #Scans the subnet for others IP
|
|
|
66
72
|
snake -l #Shows your public internet IP address. Internet connection required for use
|
|
67
73
|
-I:
|
|
68
74
|
snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## Added class Watcher:
|
|
72
|
-
```
|
|
73
|
-
from SnakeScan import Watcher
|
|
74
|
-
Watcher = Watcher(host="localhost",port="80",timeout=1)
|
|
75
|
-
Watcher.start()
|
|
76
|
-
```
|
|
77
|
-
## Library added for use in terminal to use enter snake or Snake
|
|
78
|
-
```
|
|
79
|
-
usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
|
|
80
|
-
[-l]
|
|
81
|
-
[host]
|
|
82
|
-
|
|
83
|
-
Snake - It's a command line module SnakeScan. Use him for
|
|
84
|
-
more fast starting
|
|
85
|
-
|
|
86
|
-
positional arguments:
|
|
87
|
-
host
|
|
88
|
-
|
|
89
|
-
options:
|
|
90
|
-
-h, --help show this help message and exit
|
|
91
|
-
-sp, --speed speed scan
|
|
92
|
-
-v, --version version
|
|
93
|
-
-i, --info ip info
|
|
94
|
-
-p, --ports PORTS range ports to scan host
|
|
95
|
-
-t, --thread fast scan
|
|
96
|
-
-ch, --check scan subnet
|
|
97
|
-
-l, --local view you public ip - need internet
|
|
98
|
-
```
|
|
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
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# SnakeScan
|
|
2
2
|

|
|
3
3
|

|
|
4
|
-

|
|
5
|
+

|
|
6
6
|

|
|
7
7
|
|
|
8
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
9
|
|
|
10
|
-
|
|
10
|
+
## Help with using the library
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
### If you use the library directly in your code:
|
|
13
13
|
```
|
|
14
14
|
import SnakeScan
|
|
15
15
|
SnakeScan.run()
|
|
@@ -22,11 +22,17 @@ SnakeScan.run()
|
|
|
22
22
|
- -check [host] scan subnet in ip
|
|
23
23
|
- exit in host or port off script
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
### Watcher commands
|
|
26
26
|
```
|
|
27
27
|
Watcher.start() - Starts checking ports
|
|
28
28
|
Watcher.stop() - Stops port checking
|
|
29
29
|
```
|
|
30
|
+
### Watcher
|
|
31
|
+
```
|
|
32
|
+
from SnakeScan import Watcher
|
|
33
|
+
watcher = Watcher("localhost",53,2)
|
|
34
|
+
watcher.start()
|
|
35
|
+
```
|
|
30
36
|
## Help with attributes
|
|
31
37
|
```
|
|
32
38
|
-P:
|
|
@@ -51,33 +57,5 @@ snake -ch #Scans the subnet for others IP
|
|
|
51
57
|
snake -l #Shows your public internet IP address. Internet connection required for use
|
|
52
58
|
-I:
|
|
53
59
|
snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Added class Watcher:
|
|
57
|
-
```
|
|
58
|
-
from SnakeScan import Watcher
|
|
59
|
-
Watcher = Watcher(host="localhost",port="80",timeout=1)
|
|
60
|
-
Watcher.start()
|
|
61
|
-
```
|
|
62
|
-
## Library added for use in terminal to use enter snake or Snake
|
|
63
|
-
```
|
|
64
|
-
usage: snake [-h] [-sp] [-v] [-i] [-p PORTS] [-t] [-ch]
|
|
65
|
-
[-l]
|
|
66
|
-
[host]
|
|
67
|
-
|
|
68
|
-
Snake - It's a command line module SnakeScan. Use him for
|
|
69
|
-
more fast starting
|
|
70
|
-
|
|
71
|
-
positional arguments:
|
|
72
|
-
host
|
|
73
|
-
|
|
74
|
-
options:
|
|
75
|
-
-h, --help show this help message and exit
|
|
76
|
-
-sp, --speed speed scan
|
|
77
|
-
-v, --version version
|
|
78
|
-
-i, --info ip info
|
|
79
|
-
-p, --ports PORTS range ports to scan host
|
|
80
|
-
-t, --thread fast scan
|
|
81
|
-
-ch, --check scan subnet
|
|
82
|
-
-l, --local view you public ip - need internet
|
|
83
|
-
```
|
|
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])
|
snakescan-1.6.8/SnakeScan/CLI.py
DELETED
|
@@ -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.8"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|