11import socket
22from IPy import IP
3+ import subprocess
4+ import sys
5+ import asyncio
6+ from datetime import datetime
37
8+ subprocess .call ('cls' , shell = True )
49
510print (
611 """
712You are using the DOOM Port scanner.
813
9-
10- 1. You can change the range of the ports you want to scan.
11- 2. You can change the speedof the scan
12- 3. you can scan a list of targets by using ', ' after each target
13- 4. You can scan both URL links and both IP's
14-
15-
16- """
14+ 1. Fast scanning to provide the open ports
15+ 2. You can scan both URL links and both IP's
16+ 3. Gives Total scanning time
1717)
1818# ip adresess
1919targets = input("enter targets or URL's ")
3131 )
3232except:
3333 speed = 0.1
34+ """ )
35+ # Ask for input
36+ remoteServer = input ("Enter a remote host to scan: " )
37+ remoteServerIP = socket .gethostbyname (remoteServer )
38+
39+ # Print a nice banner with information on which host we are about to scan
40+ print ("-" * 60 )
41+ print ("Please wait, scanning remote host" , remoteServerIP )
42+ print ("-" * 60 )
43+
44+ # Check what time the scan started
45+ t1 = datetime .now ()
46+
47+ async def scan_port (port ):
48+ sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
49+ sock .setblocking (False )
50+ try :
51+ await asyncio .wait_for (
52+ asyncio .get_event_loop ().sock_connect (sock , (remoteServerIP , port )),
53+ timeout = 1
54+ )
55+ print ("Port {}: Open" .format (port ))
56+ except (socket .timeout , ConnectionRefusedError ):
57+ pass
58+ finally :
59+ sock .close ()
60+
61+ async def main ():
62+ tasks = []
63+ for port in range (1 , 1025 ):
64+ tasks .append (scan_port (port ))
65+ await asyncio .gather (* tasks )
3466
67+ try :
68+ asyncio .run (main ())
69+ except KeyboardInterrupt :
70+ print ("You pressed Ctrl+C" )
71+ sys .exit ()
72+
73+ except socket .gaierror :
74+ print ('Hostname could not be resolved. Exiting' )
75+ sys .exit ()
3576
3677def multi_targets (ip ):
3778 converted_ip = check_ip (ip )
@@ -79,3 +120,15 @@ def scan_port(ip, port):
79120 multi_targets (ip_add .strip (" " ))
80121else :
81122 multi_targets (targets )
123+
124+ except socket .error :
125+ print ("Couldn't connect to server" )
126+ sys .exit ()
127+
128+ # Checking the time again
129+ t2 = datetime .now ()
130+
131+ # Calculates the difference of time, to see how long it took to run the script
132+ total = t2 - t1
133+
134+ print ('Scanning Completed in:' , total )
0 commit comments