-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanner.py
More file actions
29 lines (22 loc) · 770 Bytes
/
Copy pathscanner.py
File metadata and controls
29 lines (22 loc) · 770 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
import socket
def scan_port(host, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(0.5)
try:
sock.connect((host, port))
return True
except:
return False
finally:
sock.close()
def scan_range(host, start_port, end_port):
print(f"\n[*] Scanning {host} from {start_port} to {end_port}...\n")
for port in range(start_port, end_port + 1):
if scan_port(host, port):
print(f"[+] Port {port} is OPEN")
print("\n[+] Scan completed.\n")
if __name__ == "__main__":
target = input("Enter target host (IP or domain): ")
start = int(input("Start port: "))
end = int(input("End port: "))
scan_range(target, start, end)