-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPortscanner.py
More file actions
44 lines (22 loc) · 783 Bytes
/
Copy pathPortscanner.py
File metadata and controls
44 lines (22 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import socket
import termcolor
def scan(target,ports):
print('\n' + "Starting scan of " + str(target))
for port in range(1,ports):
scan_port(target, port)
def scan_port(ipaddress, port):
try:
sock = socket.socket()
sock.connect((ipaddress, port))
print("[+]Port connected " + str(port))
socket.close()
except:
pass
targets = input("[*]Enter IP addresses of targets to be scanned (split them by ,): ")
ports = int(input("[*]Enter number of ports to be scanned: "))
if ',' in targets:
print(termcolor.colored(("[*]Scanning multiple targets....."),'green'))
for ip_addr in targets.split(','):
scan(ip_addr.strip(' '), ports)
else:
scan(targets,ports)