File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import socket
2+ from datetime import datetime
3+
4+ # Target to scan
5+ target = input ("Enter target IP or domain: " )
6+
7+ # Banner
8+ print ("-" * 50 )
9+ print (f"Scanning Target: { target } " )
10+ print ("Scanning started at: " + str (datetime .now ()))
11+ print ("-" * 50 )
12+
13+ try :
14+ for port in range (1 , 1025 ): # You can change the port range
15+ s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
16+ socket .setdefaulttimeout (1 )
17+ result = s .connect_ex ((target , port ))
18+ if result == 0 :
19+ print (f"Port { port } is open" )
20+ s .close ()
21+
22+ except KeyboardInterrupt :
23+ print ("\n Exiting Program." )
24+ except socket .gaierror :
25+ print ("\n Hostname Could Not Be Resolved." )
26+ except socket .error :
27+ print ("\n Server not responding." )
28+
You can’t perform that action at this time.
0 commit comments