1
+ from __future__ import print_function
1
2
# Script Name : portscanner.py
2
3
# Author : Craig Richards
3
4
# Created : 20 May 2013
@@ -21,11 +22,11 @@ def connScan(tgtHost, tgtPort): # Start of the function
21
22
connSkt .send ('' )
22
23
results = connSkt .recv (100 )
23
24
screenLock .acquire () # Acquire the lock
24
- print '[+] %d/tcp open' % tgtPort
25
- print '[+] ' + str (results )
25
+ print ( '[+] %d/tcp open' % tgtPort )
26
+ print ( '[+] ' + str (results ) )
26
27
except :
27
28
screenLock .acquire ()
28
- print '[-] %d/tcp closed ' % tgtPort
29
+ print ( '[-] %d/tcp closed ' % tgtPort )
29
30
finally :
30
31
screenLock .release ()
31
32
connSkt .close ()
@@ -34,13 +35,13 @@ def portScan(tgtHost, tgtPorts): # Start of the function
34
35
try :
35
36
tgtIP = gethostbyname (tgtHost ) # Get the IP from the hostname
36
37
except :
37
- print "[-] Cannot resolve '%s': Unknown host" % tgtHost
38
+ print ( "[-] Cannot resolve '%s': Unknown host" % tgtHost )
38
39
return
39
40
try :
40
41
tgtName = gethostbyaddr (tgtIP ) # Get hostname from IP
41
- print '\n [+] Scan Results for: ' + tgtName [0 ]
42
+ print ( '\n [+] Scan Results for: ' + tgtName [0 ])
42
43
except :
43
- print '\n [+] Scan Results for: ' + tgtIP
44
+ print ( '\n [+] Scan Results for: ' + tgtIP )
44
45
setdefaulttimeout (1 )
45
46
for tgtPort in tgtPorts : # Scan host and ports
46
47
t = Thread (target = connScan , args = (tgtHost , int (tgtPort )))
@@ -54,7 +55,7 @@ def main():
54
55
tgtHost = options .tgtHost
55
56
tgtPorts = str (options .tgtPort ).split (',' )
56
57
if (tgtHost == None ) | (tgtPorts [0 ] == None ):
57
- print parser .usage
58
+ print ( parser .usage )
58
59
exit (0 )
59
60
portScan (tgtHost , tgtPorts )
60
61
if __name__ == '__main__' :
0 commit comments