-
Notifications
You must be signed in to change notification settings - Fork 0
/
port_scan
33 lines (27 loc) · 912 Bytes
/
port_scan
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
#!/usr/bin/python3
from socket import *
import time
import datetime
print("---------------created by alhassan alharbi--------------- ")
host = input("enter the host/ip ==> ")
start_port = 1
end_port = 90
active_ports = []
start_time = datetime.datetime.now()
print("Starting hassanalhabi 1.0 at", start_time)
print("hassanScan report for", host)
print("Ports range from", start_port, "to", end_port)
print("\n")
for port in range(start_port, end_port):
s = socket(AF_INET, SOCK_STREAM)
result = s.connect_ex((host, port))
if result == 0:
print("port", port ,"is open")
active_ports.append(port)
else:
print("port", port, "is close")
time.sleep(0)
end_time = datetime.datetime.now()
print("\n")
print("The end time is", end_time, "- the open ports are", active_ports)
print("hassan Scan completed successfully")