SnakeScan 1.6.8__tar.gz → 1.7.0__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.7.0}/PKG-INFO +16 -44
- {snakescan-1.6.8 → snakescan-1.7.0}/README.md +15 -41
- snakescan-1.7.0/SnakeScan/CLI.py +356 -0
- snakescan-1.7.0/SnakeScan/__init__.py +44 -0
- {snakescan-1.6.8 → snakescan-1.7.0}/pyproject.toml +0 -3
- snakescan-1.6.8/SnakeScan/CLI.py +0 -336
- snakescan-1.6.8/SnakeScan/__init__.py +0 -327
- {snakescan-1.6.8 → snakescan-1.7.0}/LICENSE +0 -0
- {snakescan-1.6.8 → snakescan-1.7.0}/SnakeScan/Check_subnet.py +0 -0
- {snakescan-1.6.8 → snakescan-1.7.0}/SnakeScan/Get_ssl.py +0 -0
- {snakescan-1.6.8 → snakescan-1.7.0}/SnakeScan/PoolExecutor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: SnakeScan
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
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
|
|
@@ -10,25 +10,17 @@ License-File: LICENSE
|
|
|
10
10
|
Requires-Dist: art
|
|
11
11
|
Requires-Dist: tqdm
|
|
12
12
|
Requires-Dist: termcolor
|
|
13
|
-
Project-URL: Homepage, https://github.com/Den-Ram/SnakeScan
|
|
14
|
-
Project-URL: Repository, https://github.com/Den-Ram/SnakeScan
|
|
15
13
|
|
|
16
14
|
# SnakeScan
|
|
17
15
|

|
|
18
16
|

|
|
19
|
-

|
|
18
|
+

|
|
21
19
|

|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
This library is now used only in the terminal.
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## If you use the library directly in your code:
|
|
28
|
-
```
|
|
29
|
-
import SnakeScan
|
|
30
|
-
SnakeScan.run()
|
|
31
|
-
```
|
|
23
|
+
## Help with using the library
|
|
32
24
|
- -l need internet to view public ip you device
|
|
33
25
|
- -t threading port search
|
|
34
26
|
- -s single search ports
|
|
@@ -37,12 +29,18 @@ SnakeScan.run()
|
|
|
37
29
|
- -check [host] scan subnet in ip
|
|
38
30
|
- exit in host or port off script
|
|
39
31
|
|
|
40
|
-
|
|
32
|
+
### Watcher commands
|
|
41
33
|
```
|
|
42
34
|
Watcher.start() - Starts checking ports
|
|
43
35
|
Watcher.stop() - Stops port checking
|
|
44
36
|
```
|
|
45
|
-
|
|
37
|
+
### Watcher
|
|
38
|
+
```
|
|
39
|
+
from SnakeScan import Watcher
|
|
40
|
+
watcher = Watcher("localhost",53,2)
|
|
41
|
+
watcher.start()
|
|
42
|
+
```
|
|
43
|
+
### Help with attributes
|
|
46
44
|
```
|
|
47
45
|
-P:
|
|
48
46
|
snake -p 80,443 #Scanning specific ports
|
|
@@ -66,33 +64,7 @@ snake -ch #Scans the subnet for others IP
|
|
|
66
64
|
snake -l #Shows your public internet IP address. Internet connection required for use
|
|
67
65
|
-I:
|
|
68
66
|
snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
|
|
69
|
-
# Library changes
|
|
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
67
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
```
|
|
68
|
+
##Update in 1.7.0
|
|
69
|
+
- Unnecessary functions have been removed and some bugs have been fixed.
|
|
70
|
+
- Now SnakeScan run is deleted and run in code is now impossible.
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
# SnakeScan
|
|
2
2
|

|
|
3
3
|

|
|
4
|
-

|
|
5
|
+

|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
This library is now used only in the terminal.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## If you use the library directly in your code:
|
|
13
|
-
```
|
|
14
|
-
import SnakeScan
|
|
15
|
-
SnakeScan.run()
|
|
16
|
-
```
|
|
10
|
+
## Help with using the library
|
|
17
11
|
- -l need internet to view public ip you device
|
|
18
12
|
- -t threading port search
|
|
19
13
|
- -s single search ports
|
|
@@ -22,12 +16,18 @@ SnakeScan.run()
|
|
|
22
16
|
- -check [host] scan subnet in ip
|
|
23
17
|
- exit in host or port off script
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
### Watcher commands
|
|
26
20
|
```
|
|
27
21
|
Watcher.start() - Starts checking ports
|
|
28
22
|
Watcher.stop() - Stops port checking
|
|
29
23
|
```
|
|
30
|
-
|
|
24
|
+
### Watcher
|
|
25
|
+
```
|
|
26
|
+
from SnakeScan import Watcher
|
|
27
|
+
watcher = Watcher("localhost",53,2)
|
|
28
|
+
watcher.start()
|
|
29
|
+
```
|
|
30
|
+
### Help with attributes
|
|
31
31
|
```
|
|
32
32
|
-P:
|
|
33
33
|
snake -p 80,443 #Scanning specific ports
|
|
@@ -51,33 +51,7 @@ snake -ch #Scans the subnet for others IP
|
|
|
51
51
|
snake -l #Shows your public internet IP address. Internet connection required for use
|
|
52
52
|
-I:
|
|
53
53
|
snake www.google.com -i #Shows information about the IP address.Can receive information from IPV4 and IPV6
|
|
54
|
-
# Library changes
|
|
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
54
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
```
|
|
55
|
+
##Update in 1.7.0
|
|
56
|
+
- Unnecessary functions have been removed and some bugs have been fixed.
|
|
57
|
+
- Now SnakeScan run is deleted and run in code is now impossible.
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import string
|
|
3
|
+
import argparse
|
|
4
|
+
import socket
|
|
5
|
+
import ipaddress
|
|
6
|
+
from art import tprint
|
|
7
|
+
from concurrent.futures import ProcessPoolExecutor
|
|
8
|
+
from termcolor import colored
|
|
9
|
+
from threading import Thread
|
|
10
|
+
from tqdm import tqdm
|
|
11
|
+
from SnakeScan.Check_subnet import Check_network
|
|
12
|
+
from SnakeScan.PoolExecutor import PoolProcessExecutor
|
|
13
|
+
from SnakeScan.Get_ssl import Get_ssl
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
if __name__ == "__main__":
|
|
21
|
+
main()
|
|
22
|
+
OpenPorts = []
|
|
23
|
+
threads = []
|
|
24
|
+
portsopen = 0
|
|
25
|
+
portsclosed = 0
|
|
26
|
+
Bool = True
|
|
27
|
+
boolsd = True
|
|
28
|
+
boolean = 0
|
|
29
|
+
ports = {
|
|
30
|
+
20: "FTP-DATA",
|
|
31
|
+
21: "FTP",
|
|
32
|
+
22: "SSH",
|
|
33
|
+
23: "Telnet",
|
|
34
|
+
25: "SMTP",
|
|
35
|
+
43: "WHOIS",
|
|
36
|
+
53: "DNS",
|
|
37
|
+
67: "DHCP",
|
|
38
|
+
68: "DHCP",
|
|
39
|
+
69: "TFTP",
|
|
40
|
+
80: "http",
|
|
41
|
+
110: "POP3",
|
|
42
|
+
115: "SFTP",
|
|
43
|
+
123: "NTP",
|
|
44
|
+
139: "NetBios",
|
|
45
|
+
143: "IMAP",
|
|
46
|
+
161: "SNMP",
|
|
47
|
+
179: "BGP",
|
|
48
|
+
443: "HTTPS",
|
|
49
|
+
445: "MICROSOFT-DS",
|
|
50
|
+
465: "SSL/TLS",
|
|
51
|
+
514: "SYSLOG",
|
|
52
|
+
515: "PRINTER",
|
|
53
|
+
554: "RTSP",
|
|
54
|
+
587: "TLS/STARTTLS",
|
|
55
|
+
636: "LDAPS",
|
|
56
|
+
990: "FTPS",
|
|
57
|
+
993: "IMAPS",
|
|
58
|
+
995: "POP3S",
|
|
59
|
+
1080: "SOCKS",
|
|
60
|
+
1194: "OpenVPN",
|
|
61
|
+
1433: "SQL Server",
|
|
62
|
+
1723: "PPTP",
|
|
63
|
+
2222: "SSH",
|
|
64
|
+
3128: "HTTP",
|
|
65
|
+
3268: "LDAP",
|
|
66
|
+
3306: "MySQL",
|
|
67
|
+
3389: "RDP",
|
|
68
|
+
5432: "PostgreSQL",
|
|
69
|
+
5900: "VNC",
|
|
70
|
+
8080: "Tomcat",
|
|
71
|
+
10000: "Webmin",
|
|
72
|
+
}
|
|
73
|
+
version = "1.7.0"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def is_port_open(host, port):
|
|
77
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
78
|
+
try:
|
|
79
|
+
s.settimeout(1)
|
|
80
|
+
s.connect((host, port))
|
|
81
|
+
except (OSError, socket.timeout):
|
|
82
|
+
return False
|
|
83
|
+
else:
|
|
84
|
+
return True
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def is_port_open_threads(host, port):
|
|
88
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
89
|
+
try:
|
|
90
|
+
s.settimeout(1)
|
|
91
|
+
s.connect((host, port))
|
|
92
|
+
except (OSError, socket.timeout):
|
|
93
|
+
try:
|
|
94
|
+
print(f"Closed{colored('|X|','red')}-->{ports.get(port)}|{port}|")
|
|
95
|
+
except:
|
|
96
|
+
print(f"Closed{colored('|X|','red')}-->|{port}|")
|
|
97
|
+
else:
|
|
98
|
+
print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def Ports(str=""):
|
|
102
|
+
rangeports = []
|
|
103
|
+
rangeport = []
|
|
104
|
+
port = []
|
|
105
|
+
doneports = []
|
|
106
|
+
str = str.split(",")
|
|
107
|
+
for p in range(len(str)):
|
|
108
|
+
if "-" in str[p]:
|
|
109
|
+
rangeports.append(str[p])
|
|
110
|
+
else:
|
|
111
|
+
port.append(str[p])
|
|
112
|
+
for n in range(len(port)):
|
|
113
|
+
for i in string.punctuation:
|
|
114
|
+
if i in port[n]:
|
|
115
|
+
port[n] = port[n].replace(i, "")
|
|
116
|
+
for r in range(len(rangeports)):
|
|
117
|
+
rangeport = rangeports[r].split("-")
|
|
118
|
+
for i in range(len(rangeport)):
|
|
119
|
+
doneports.append(rangeport[i])
|
|
120
|
+
try:
|
|
121
|
+
return doneports, port
|
|
122
|
+
except Exception as e:
|
|
123
|
+
rangeport = ""
|
|
124
|
+
return doneports, port
|
|
125
|
+
sys.exit()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def SnakeArgs():
|
|
129
|
+
parser = argparse.ArgumentParser(
|
|
130
|
+
description="SnakeScan - It's a command line library for scan and get information about ip."
|
|
131
|
+
)
|
|
132
|
+
parser.add_argument("host", nargs="?", default="None")
|
|
133
|
+
parser.add_argument(
|
|
134
|
+
"-gs", "--getssl", action="store_true", help="Get official ssl certificate"
|
|
135
|
+
)
|
|
136
|
+
parser.add_argument(
|
|
137
|
+
"-sp",
|
|
138
|
+
"--speed",
|
|
139
|
+
action="store_true",
|
|
140
|
+
help="Scan with using PoolProcessExecutor",
|
|
141
|
+
)
|
|
142
|
+
parser.add_argument("-v", "--version", action="store_true", help="Library version")
|
|
143
|
+
parser.add_argument(
|
|
144
|
+
"-i", "--info", action="store_true", help="IP information about host"
|
|
145
|
+
)
|
|
146
|
+
parser.add_argument("-p", "--ports", help="Range ports to scan host")
|
|
147
|
+
parser.add_argument(
|
|
148
|
+
"-t", "--thread", action="store_true", help="Scan with using Threading"
|
|
149
|
+
)
|
|
150
|
+
parser.add_argument("-ch", "--check", action="store_true", help="Scan ip subnet")
|
|
151
|
+
parser.add_argument(
|
|
152
|
+
"-l",
|
|
153
|
+
"--local",
|
|
154
|
+
action="store_true",
|
|
155
|
+
help="View you public ip - need internet",
|
|
156
|
+
)
|
|
157
|
+
args = parser.parse_args()
|
|
158
|
+
return args
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
port_user = SnakeArgs().ports
|
|
162
|
+
host = SnakeArgs().host
|
|
163
|
+
host = host.split(",")
|
|
164
|
+
for n in range(len(host)):
|
|
165
|
+
if host[n].startswith("http://"):
|
|
166
|
+
host[n] = host[n].strip()
|
|
167
|
+
host[n] = host[n].split("http:")
|
|
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
|
+
for n in range(len(host)):
|
|
175
|
+
if host[n].startswith("https://"):
|
|
176
|
+
host[n] = host[n].strip()
|
|
177
|
+
host[n] = host[n].split("https:")
|
|
178
|
+
host[n] = host[n][1].strip("//")
|
|
179
|
+
host[n] = host[n].split("/")
|
|
180
|
+
host[n] = host[n][0]
|
|
181
|
+
for i in range(len(host)):
|
|
182
|
+
if host[n][i] == "/":
|
|
183
|
+
host[n] = host[n][0:i]
|
|
184
|
+
if host[0] == "None":
|
|
185
|
+
host[0] = "localhost"
|
|
186
|
+
if SnakeArgs().ports:
|
|
187
|
+
rangeports, port_user = Ports(port_user)
|
|
188
|
+
for i in range(len(port_user)):
|
|
189
|
+
port_user[i] = int(port_user[i])
|
|
190
|
+
for n in range(len(host)):
|
|
191
|
+
for port in range(len(port_user)):
|
|
192
|
+
if is_port_open(host[n], port_user[port]):
|
|
193
|
+
print(
|
|
194
|
+
f"Open{colored('|√|','green')}{host[n]}-->{ports[port_user[port]]}|{port_user[port]}|"
|
|
195
|
+
)
|
|
196
|
+
else:
|
|
197
|
+
try:
|
|
198
|
+
print(
|
|
199
|
+
f"Closed{colored('|X|','red')}{host[n]}-->{ports[port_user[port]]}|{port_user[port]}|"
|
|
200
|
+
)
|
|
201
|
+
except:
|
|
202
|
+
print(
|
|
203
|
+
f"Closed{colored('|X|','red')}{host[n]}-->|{port_user[port]}|"
|
|
204
|
+
)
|
|
205
|
+
try:
|
|
206
|
+
first = rangeports[::2]
|
|
207
|
+
second = rangeports[1::2]
|
|
208
|
+
minimal = min(len(first), len(second))
|
|
209
|
+
for i in range(minimal):
|
|
210
|
+
if int(first[i]) > int(second[i]):
|
|
211
|
+
number = second[i]
|
|
212
|
+
second[i] = first[i]
|
|
213
|
+
first[i] = number
|
|
214
|
+
for i in range(minimal):
|
|
215
|
+
for port in tqdm(range(int(first[i]) + 1, int(second[i]) + 1)):
|
|
216
|
+
if is_port_open(host[n], port):
|
|
217
|
+
for name in ports:
|
|
218
|
+
if port == name:
|
|
219
|
+
OpenPorts = [port]
|
|
220
|
+
portsopen += 1
|
|
221
|
+
else:
|
|
222
|
+
portsclosed += 1
|
|
223
|
+
if OpenPorts:
|
|
224
|
+
for i in OpenPorts:
|
|
225
|
+
print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
|
|
226
|
+
print(f"{host[n]}".center(60, "-"))
|
|
227
|
+
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
228
|
+
portsclosed = 0
|
|
229
|
+
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
230
|
+
portsopen = 0
|
|
231
|
+
print("-" * 60)
|
|
232
|
+
else:
|
|
233
|
+
print(f"{host[n]}".center(60, "-"))
|
|
234
|
+
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
235
|
+
portsclosed = 0
|
|
236
|
+
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
237
|
+
portsopen = 0
|
|
238
|
+
print("-" * 60)
|
|
239
|
+
except Exception as e:
|
|
240
|
+
print(e)
|
|
241
|
+
sys.exit()
|
|
242
|
+
if SnakeArgs().check:
|
|
243
|
+
for n in range(len(host)):
|
|
244
|
+
Check_network(host[n])
|
|
245
|
+
if SnakeArgs().local:
|
|
246
|
+
local = ""
|
|
247
|
+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
248
|
+
try:
|
|
249
|
+
s.connect(("10.255.255.255", 1))
|
|
250
|
+
local = s.getsockname()[0]
|
|
251
|
+
except Exception as e:
|
|
252
|
+
local = f"127.0.0.1:{e}"
|
|
253
|
+
finally:
|
|
254
|
+
s.close()
|
|
255
|
+
print(local)
|
|
256
|
+
if SnakeArgs().info:
|
|
257
|
+
if host[0] == "None":
|
|
258
|
+
host[0] = "localhost"
|
|
259
|
+
for n in range(len(host)):
|
|
260
|
+
print("".center(60, "-"))
|
|
261
|
+
try:
|
|
262
|
+
host[n] = socket.gethostbyname(host[n])
|
|
263
|
+
except Exception as e:
|
|
264
|
+
try:
|
|
265
|
+
hostname, list, iplist = socket.gethostbyaddr(host[n])
|
|
266
|
+
except Exception as e:
|
|
267
|
+
if host[n].startswith("[") and host[n].endswith("]"):
|
|
268
|
+
host[n] = host[n][1:-1]
|
|
269
|
+
else:
|
|
270
|
+
host[n] = host[n].split("[")
|
|
271
|
+
for i in range(len(host)):
|
|
272
|
+
host[n] = host[n][i - 1].split("]")
|
|
273
|
+
host[n] = host[n][0]
|
|
274
|
+
try:
|
|
275
|
+
hostname, list, iplist = socket.gethostbyaddr(host[n])
|
|
276
|
+
except Exception as e:
|
|
277
|
+
print(e)
|
|
278
|
+
sys.exit()
|
|
279
|
+
|
|
280
|
+
hosting = ""
|
|
281
|
+
hosting = host[n].split(".")
|
|
282
|
+
hosting[len(hosting) - 1] = "0"
|
|
283
|
+
network = ""
|
|
284
|
+
for i in range(len(hosting) - 1):
|
|
285
|
+
network += hosting[i] + "."
|
|
286
|
+
network += "0"
|
|
287
|
+
network += "/24"
|
|
288
|
+
hosting = network
|
|
289
|
+
try:
|
|
290
|
+
if host[n].startswith("[") and host[n].endswith("]"):
|
|
291
|
+
host[n] = host[n][1:-1]
|
|
292
|
+
else:
|
|
293
|
+
host[n] = host[n].split("[")
|
|
294
|
+
for i in range(len(host)):
|
|
295
|
+
host[n] = host[n][i - 1].split("]")
|
|
296
|
+
host[n] = host[n][0]
|
|
297
|
+
ip_obj = ipaddress.ip_address(host[n])
|
|
298
|
+
if ip_obj.version == 6:
|
|
299
|
+
|
|
300
|
+
try:
|
|
301
|
+
network = host[n] + "/64"
|
|
302
|
+
network_obj = ipaddress.ip_network(network)
|
|
303
|
+
except Exception as e:
|
|
304
|
+
pass
|
|
305
|
+
try:
|
|
306
|
+
network = host[n] + "/128"
|
|
307
|
+
network_obj = ipaddress.ip_network(network)
|
|
308
|
+
except Exception as e:
|
|
309
|
+
pass
|
|
310
|
+
except Exception as e:
|
|
311
|
+
print(e)
|
|
312
|
+
print(f"Type IP: {type(ip_obj)}")
|
|
313
|
+
print(f"Version IP: {ip_obj.version}")
|
|
314
|
+
network_obj = ipaddress.ip_network(network)
|
|
315
|
+
print(f"Network: {network_obj}")
|
|
316
|
+
print(f"Subnet mask: {network_obj.netmask}")
|
|
317
|
+
try:
|
|
318
|
+
hostname = socket.gethostbyaddr(host[n])
|
|
319
|
+
print(f"Host:{hostname[0]}")
|
|
320
|
+
except:
|
|
321
|
+
hostname = "Undefined"
|
|
322
|
+
print(f"Host:{hostname}")
|
|
323
|
+
try:
|
|
324
|
+
print(f"IP:{socket.gethostbyname(host[n])}")
|
|
325
|
+
except Exception as e:
|
|
326
|
+
try:
|
|
327
|
+
hostname, list, iplist = socket.gethostbyaddr(host[n])
|
|
328
|
+
print(f"IP:{socket.gethostbyname(hostname)}")
|
|
329
|
+
except:
|
|
330
|
+
pass
|
|
331
|
+
finally:
|
|
332
|
+
print("".center(60, "-"))
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
if SnakeArgs().thread:
|
|
336
|
+
for n in range(len(host)):
|
|
337
|
+
print(f"{host[n]}".center(60, "-"))
|
|
338
|
+
|
|
339
|
+
for port in ports.keys():
|
|
340
|
+
t = Thread(
|
|
341
|
+
target=is_port_open_threads,
|
|
342
|
+
kwargs={"host": host[n], "port": port},
|
|
343
|
+
)
|
|
344
|
+
threads.append(t)
|
|
345
|
+
t.start()
|
|
346
|
+
for t in threads:
|
|
347
|
+
t.join()
|
|
348
|
+
if SnakeArgs().version:
|
|
349
|
+
print(f"SnakeScan_Build_{version}")
|
|
350
|
+
if SnakeArgs().speed:
|
|
351
|
+
for n in range(len(host)):
|
|
352
|
+
print(f"{host[n]}".center(60, "-"))
|
|
353
|
+
PoolProcessExecutor(host[n])
|
|
354
|
+
if SnakeArgs().getssl:
|
|
355
|
+
for n in range(len(host)):
|
|
356
|
+
Get_ssl(host[n])
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
|
|
3
|
+
__version__ = "1.7.0"
|
|
4
|
+
import socket
|
|
5
|
+
from time import sleep
|
|
6
|
+
from termcolor import colored
|
|
7
|
+
from threading import Thread
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Watcher:
|
|
11
|
+
def __init__(self, host, port_user, timeout=1):
|
|
12
|
+
# Initialized class and variables host, port, and delay.
|
|
13
|
+
self.host = host # localhost
|
|
14
|
+
self.port_user = port_user # 80
|
|
15
|
+
self.timeout = timeout # 2 or 2.0
|
|
16
|
+
self.work = False # run value
|
|
17
|
+
|
|
18
|
+
def run(self):
|
|
19
|
+
# Basic process of connecting to a host and checking the port
|
|
20
|
+
previous = None
|
|
21
|
+
while self.work:
|
|
22
|
+
try:
|
|
23
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
24
|
+
connection = sock.connect_ex((self.host, self.port_user))
|
|
25
|
+
if previous != connection:
|
|
26
|
+
if connection == 0:
|
|
27
|
+
print(f"Service is up {self.host}-->|{self.port_user}|")
|
|
28
|
+
else:
|
|
29
|
+
print(f"Service is down {self.host}-->|{self.port_user}|")
|
|
30
|
+
previous = connection
|
|
31
|
+
except Exception as e:
|
|
32
|
+
print(f"Unable to create scanner object:{e}")
|
|
33
|
+
sleep(self.timeout)
|
|
34
|
+
|
|
35
|
+
def start(self):
|
|
36
|
+
# Run a port check to see if it is running or offline.
|
|
37
|
+
self.work = True
|
|
38
|
+
self.thread = Thread(target=self.run)
|
|
39
|
+
self.thread.start()
|
|
40
|
+
|
|
41
|
+
def stop(self):
|
|
42
|
+
# Stops port checking
|
|
43
|
+
self.work = False
|
|
44
|
+
self.thread.join()
|
|
@@ -16,9 +16,6 @@ dependencies = [
|
|
|
16
16
|
"tqdm",
|
|
17
17
|
"termcolor",
|
|
18
18
|
]
|
|
19
|
-
[project.urls]
|
|
20
|
-
Homepage = "https://github.com/Den-Ram/SnakeScan"
|
|
21
|
-
Repository = "https://github.com/Den-Ram/SnakeScan"
|
|
22
19
|
[project.scripts]
|
|
23
20
|
SnakeScan = "SnakeScan:run"
|
|
24
21
|
Snake = "SnakeScan.CLI:main"
|
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)
|
|
@@ -1,327 +0,0 @@
|
|
|
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
|
-
|
|
3
|
-
__version__ = "1.6.8"
|
|
4
|
-
import socket
|
|
5
|
-
import ipaddress
|
|
6
|
-
from art import tprint
|
|
7
|
-
from time import sleep
|
|
8
|
-
from tqdm import tqdm
|
|
9
|
-
from termcolor import colored
|
|
10
|
-
from threading import Thread
|
|
11
|
-
from SnakeScan.Check_subnet import Check_network
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
21
|
-
|
|
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:
|
|
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
|
-
|
|
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()
|
|
49
|
-
|
|
50
|
-
#Run SnakeScan
|
|
51
|
-
def run():
|
|
52
|
-
portsopen = 0
|
|
53
|
-
portsclosed = 0
|
|
54
|
-
Run_now = True
|
|
55
|
-
|
|
56
|
-
global num
|
|
57
|
-
num = 0
|
|
58
|
-
|
|
59
|
-
OpenPorts = []
|
|
60
|
-
threads = []
|
|
61
|
-
ports = {
|
|
62
|
-
20: "FTP-DATA",
|
|
63
|
-
21: "FTP",
|
|
64
|
-
22: "SSH",
|
|
65
|
-
23: "Telnet",
|
|
66
|
-
25: "SMTP",
|
|
67
|
-
43: "WHOIS",
|
|
68
|
-
53: "DNS",
|
|
69
|
-
67: "DHCP",
|
|
70
|
-
68: "DHCP",
|
|
71
|
-
69: "TFTP",
|
|
72
|
-
80: "http",
|
|
73
|
-
110: "POP3",
|
|
74
|
-
115: "SFTP",
|
|
75
|
-
123: "NTP",
|
|
76
|
-
139: "NetBios",
|
|
77
|
-
143: "IMAP",
|
|
78
|
-
161: "SNMP",
|
|
79
|
-
179: "BGP",
|
|
80
|
-
443: "HTTPS",
|
|
81
|
-
445: "MICROSOFT-DS",
|
|
82
|
-
465: "SSL/TLS",
|
|
83
|
-
514: "SYSLOG",
|
|
84
|
-
515: "PRINTER",
|
|
85
|
-
554: "RTSP",
|
|
86
|
-
587: "TLS/STARTTLS",
|
|
87
|
-
636: "LDAPS",
|
|
88
|
-
990: "FTPS",
|
|
89
|
-
993: "IMAPS",
|
|
90
|
-
995: "POP3S",
|
|
91
|
-
1080: "SOCKS",
|
|
92
|
-
1194: "OpenVPN",
|
|
93
|
-
1433: "SQL Server",
|
|
94
|
-
1723: "PPTP",
|
|
95
|
-
2222: "SSH",
|
|
96
|
-
3128: "HTTP",
|
|
97
|
-
3268: "LDAP",
|
|
98
|
-
3306: "MySQL",
|
|
99
|
-
3389: "RDP",
|
|
100
|
-
5432: "PostgreSQL",
|
|
101
|
-
5900: "VNC",
|
|
102
|
-
8080: "Tomcat",
|
|
103
|
-
10000: "Webmin",
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
def Ports(str=""):
|
|
107
|
-
rangeports = []
|
|
108
|
-
port = []
|
|
109
|
-
str = str.split(",")
|
|
110
|
-
for p in range(len(str)):
|
|
111
|
-
if "-" in str[p]:
|
|
112
|
-
rangeports.append(str[p])
|
|
113
|
-
else:
|
|
114
|
-
port.append(str[p])
|
|
115
|
-
for n in range(len(port)):
|
|
116
|
-
for i in string.punctuation:
|
|
117
|
-
if i in port[n]:
|
|
118
|
-
port[n] = port[n].replace(i, "")
|
|
119
|
-
for r in range(len(rangeports)):
|
|
120
|
-
rangeport = rangeports[r].split("-")
|
|
121
|
-
try:
|
|
122
|
-
return rangeport, port
|
|
123
|
-
except Exception as e:
|
|
124
|
-
print("Error: invalid value")
|
|
125
|
-
sys.exit()
|
|
126
|
-
|
|
127
|
-
def is_port_open(host, port):
|
|
128
|
-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
129
|
-
try:
|
|
130
|
-
s.settimeout(1)
|
|
131
|
-
s.connect((host, port))
|
|
132
|
-
except (OSError, socket.timeout):
|
|
133
|
-
return False
|
|
134
|
-
else:
|
|
135
|
-
return True
|
|
136
|
-
|
|
137
|
-
def is_port_open_threads(host, port):
|
|
138
|
-
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
139
|
-
try:
|
|
140
|
-
s.settimeout(1)
|
|
141
|
-
s.connect((host, port))
|
|
142
|
-
except (OSError, socket.timeout):
|
|
143
|
-
try:
|
|
144
|
-
print(f"Closed{colored('|X|','red')}-->{ports.get(port)}|{port}|")
|
|
145
|
-
except:
|
|
146
|
-
print(f"Closed{colored('|X|','red')}-->|{port}|")
|
|
147
|
-
else:
|
|
148
|
-
print(f"Open{colored('|√|','green')}-->{ports.get(port)}|{port}|")
|
|
149
|
-
|
|
150
|
-
print("–" * 60)
|
|
151
|
-
tprint("SnakeScan")
|
|
152
|
-
print("–" * 60)
|
|
153
|
-
while Run_now:
|
|
154
|
-
host = input(f"{colored('[$]','green')}Host-->")
|
|
155
|
-
if "-check" in host:
|
|
156
|
-
host = host.strip("-check")
|
|
157
|
-
host = host.strip()
|
|
158
|
-
Check_network(host)
|
|
159
|
-
continue
|
|
160
|
-
if "-v" in host:
|
|
161
|
-
print(f"Build_{__version__}")
|
|
162
|
-
continue
|
|
163
|
-
if "-help" in host:
|
|
164
|
-
host = host.strip("-help")
|
|
165
|
-
host = host.strip()
|
|
166
|
-
if host == "port":
|
|
167
|
-
print("Port:|-s port,-t|")
|
|
168
|
-
if host:
|
|
169
|
-
pass
|
|
170
|
-
else:
|
|
171
|
-
print("Host:|host -check,host -i,-l,-v|")
|
|
172
|
-
continue
|
|
173
|
-
if "-i" in host:
|
|
174
|
-
host = host.strip("-i").strip()
|
|
175
|
-
print("".center(60, "-"))
|
|
176
|
-
try:
|
|
177
|
-
host = socket.gethostbyname(host)
|
|
178
|
-
except Exception as e:
|
|
179
|
-
print(e)
|
|
180
|
-
print("".center(60, "^"))
|
|
181
|
-
print("".center(60, "-"))
|
|
182
|
-
continue
|
|
183
|
-
hosting = ""
|
|
184
|
-
hosting = host.split(".")
|
|
185
|
-
hosting[len(hosting) - 1] = "0"
|
|
186
|
-
network = ""
|
|
187
|
-
for i in range(len(hosting) - 1):
|
|
188
|
-
network += hosting[i] + "."
|
|
189
|
-
network += "0"
|
|
190
|
-
network += "/24"
|
|
191
|
-
hosting = network
|
|
192
|
-
ip_obj = ipaddress.ip_address(host)
|
|
193
|
-
print(f"Type IP: {type(ip_obj)}")
|
|
194
|
-
print(f"Version IP: {ip_obj.version}")
|
|
195
|
-
network_obj = ipaddress.ip_network(network)
|
|
196
|
-
print(f"Network: {network_obj}")
|
|
197
|
-
print(f"Subnet mask: {network_obj.netmask}")
|
|
198
|
-
try:
|
|
199
|
-
hostname = socket.gethostbyaddr(host)
|
|
200
|
-
print(f"Host:{hostname[0]}")
|
|
201
|
-
except:
|
|
202
|
-
hostname = "Undefined"
|
|
203
|
-
print(f"Host:{hostname}")
|
|
204
|
-
try:
|
|
205
|
-
print(f"IP:{socket.gethostbyname(host)}")
|
|
206
|
-
except Exception as e:
|
|
207
|
-
print(f"IP:{e}")
|
|
208
|
-
continue
|
|
209
|
-
finally:
|
|
210
|
-
print("".center(60, "-"))
|
|
211
|
-
continue
|
|
212
|
-
if host.startswith("http://"):
|
|
213
|
-
host = host.strip()
|
|
214
|
-
host = host.split("http:")
|
|
215
|
-
host = host[1].strip("//")
|
|
216
|
-
for i in range(len(host)):
|
|
217
|
-
if host[i] == "/":
|
|
218
|
-
host = host[0:i]
|
|
219
|
-
if host.startswith("https://"):
|
|
220
|
-
host = host.strip()
|
|
221
|
-
host = host.split("https:")
|
|
222
|
-
host = host[1].strip("//")
|
|
223
|
-
for i in range(len(host)):
|
|
224
|
-
if host[i] == "/":
|
|
225
|
-
host = host[0:i]
|
|
226
|
-
if host == "Exit".lower():
|
|
227
|
-
break
|
|
228
|
-
if host == "":
|
|
229
|
-
while True:
|
|
230
|
-
print(f"{colored('Host','green')}{colored('[X]:Empty value','red')}")
|
|
231
|
-
host = input(f"{colored('[$]','green')}Host-->")
|
|
232
|
-
if host:
|
|
233
|
-
break
|
|
234
|
-
if "-l" in host:
|
|
235
|
-
local = ""
|
|
236
|
-
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
237
|
-
try:
|
|
238
|
-
s.connect(("10.255.255.255", 1))
|
|
239
|
-
local = s.getsockname()[0]
|
|
240
|
-
except Exception as e:
|
|
241
|
-
local = f"127.0.0.1:{e}"
|
|
242
|
-
finally:
|
|
243
|
-
s.close()
|
|
244
|
-
print(local)
|
|
245
|
-
continue
|
|
246
|
-
port_user = input(f"{colored('[$]','green')}Port-->")
|
|
247
|
-
if port_user == "":
|
|
248
|
-
while True:
|
|
249
|
-
print(f"{colored('Port','green')}{colored('[X]:Empty value','red')}")
|
|
250
|
-
port_user = input(f"{colored('[$]','green')}Port-->")
|
|
251
|
-
if port_user:
|
|
252
|
-
break
|
|
253
|
-
port_single = port_user
|
|
254
|
-
if port_user == "Exit".lower():
|
|
255
|
-
break
|
|
256
|
-
if port_user:
|
|
257
|
-
try:
|
|
258
|
-
length = int(port_user)
|
|
259
|
-
except:
|
|
260
|
-
if "-t" in str(port_user):
|
|
261
|
-
print(f"Thread".center(60, "-"))
|
|
262
|
-
for port in ports.keys():
|
|
263
|
-
t = Thread(
|
|
264
|
-
target=is_port_open_threads,
|
|
265
|
-
kwargs={"host": host, "port": port},
|
|
266
|
-
)
|
|
267
|
-
threads.append(t)
|
|
268
|
-
t.start()
|
|
269
|
-
for t in threads:
|
|
270
|
-
t.join()
|
|
271
|
-
|
|
272
|
-
else:
|
|
273
|
-
if "-t" in port_user:
|
|
274
|
-
continue
|
|
275
|
-
port_user = "100"
|
|
276
|
-
print(f"{colored('[!]','red')}Port:invalid value")
|
|
277
|
-
for i in range(0, len(port_user)):
|
|
278
|
-
if port_user[i] == " ":
|
|
279
|
-
port_user = 100
|
|
280
|
-
break
|
|
281
|
-
port_user = int(port_user)
|
|
282
|
-
length = port_user
|
|
283
|
-
else:
|
|
284
|
-
print(f"{colored('|*|','blue')}100")
|
|
285
|
-
port_user = 100
|
|
286
|
-
length = port_user
|
|
287
|
-
print(f"{colored('|!|','red')}Listening {host} please wait...")
|
|
288
|
-
# |----------------starting---------------------|
|
|
289
|
-
rangeports, port_user = Ports(port_user)
|
|
290
|
-
for i in range(len(port_user)):
|
|
291
|
-
port_user[i] = int(port_user[i])
|
|
292
|
-
for port in range(len(port_user)):
|
|
293
|
-
if is_port_open(host, port_user[port]):
|
|
294
|
-
print(
|
|
295
|
-
f"Open{colored('|√|','green')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
|
|
296
|
-
)
|
|
297
|
-
else:
|
|
298
|
-
try:
|
|
299
|
-
print(
|
|
300
|
-
f"Closed{colored('|X|','red')}{host}-->{ports[port_user[port]]}|{port_user[port]}|"
|
|
301
|
-
)
|
|
302
|
-
except:
|
|
303
|
-
print(f"Closed{colored('|X|','red')}{host}-->|{port_user[port]}|")
|
|
304
|
-
for port in tqdm(range(int(rangeports[0]), int(rangeports[1]) + 1)):
|
|
305
|
-
if is_port_open(host, port):
|
|
306
|
-
for name in ports:
|
|
307
|
-
if port == name:
|
|
308
|
-
OpenPorts = [port]
|
|
309
|
-
portsopen += 1
|
|
310
|
-
else:
|
|
311
|
-
portsclosed += 1
|
|
312
|
-
if OpenPorts:
|
|
313
|
-
for i in OpenPorts:
|
|
314
|
-
print(f"Open{colored('|√|','green')}-->{ports[i]}|{i}|")
|
|
315
|
-
print(f"{host}".center(60, "-"))
|
|
316
|
-
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
317
|
-
portsclosed = 0
|
|
318
|
-
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
319
|
-
portsopen = 0
|
|
320
|
-
print("-" * 60)
|
|
321
|
-
else:
|
|
322
|
-
print(f"{host}".center(60, "-"))
|
|
323
|
-
print(f"Closed{colored('|X|','red')}:{portsclosed}")
|
|
324
|
-
portsclosed = 0
|
|
325
|
-
print(f"Open{colored('|√|','green')}:{portsopen}")
|
|
326
|
-
portsopen = 0
|
|
327
|
-
print("-" * 60)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|