MCPcopy Index your code
hub / github.com/geekcomputers/Python / portScan

Function portScan

portscanner.py:35–49  ·  view source on GitHub ↗
(tgtHost, tgtPorts)

Source from the content-addressed store, hash-verified

33
34
35def 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
52def main():

Callers 1

mainFunction · 0.85

Calls 1

startMethod · 0.80

Tested by

no test coverage detected