| 33 | |
| 34 | |
| 35 | def portScan(tgtHost, tgtPorts): # Start of the function |
| 36 | try: |
| 37 | tgtIP = gethostbyname(tgtHost) # Get the IP from the hostname |
| 38 | except: |
| 39 | print("[-] Cannot resolve '%s': Unknown host" % tgtHost) |
| 40 | return |
| 41 | try: |
| 42 | tgtName = gethostbyaddr(tgtIP) # Get hostname from IP |
| 43 | print("\n[+] Scan Results for: " + tgtName[0]) |
| 44 | except: |
| 45 | print("\n[+] Scan Results for: " + tgtIP) |
| 46 | setdefaulttimeout(1) |
| 47 | for tgtPort in tgtPorts: # Scan host and ports |
| 48 | t = Thread(target=connScan, args=(tgtHost, int(tgtPort))) |
| 49 | t.start() |
| 50 | |
| 51 | |
| 52 | def main(): |