From 1c160e4544e36963b0e2ae5ffeffb93b3189814a Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 2 Jun 2018 09:34:19 -0400 Subject: [PATCH] print() is a function in Python 3 --- python/quick_scanner.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/python/quick_scanner.py b/python/quick_scanner.py index a4043c7..9abf432 100644 --- a/python/quick_scanner.py +++ b/python/quick_scanner.py @@ -5,12 +5,13 @@ # basic TCP port scanner using python. ##################################################################### +from __future__ import print_function -import socket, subprocess,sys +import socket, subprocess, sys -subprocess.call('clear',shell=True) +subprocess.call('clear', shell=True) -print '''\t +print('''\t ___ __ __ _ ___ _ ___ / _ \| \/ | /_\ | _ ( ) __| | (_) | |\/| |/ _ \| //\__ \ @@ -22,35 +23,35 @@ print '''\t \__ \ (__ / _ \| .` | .` | _|| / |___/\___/_/ \_\_|\_|_|\_|___|_|_\\ -''' +''') target_ip = raw_input("\t Please enter the IP address of the target host:") port_1 = int(raw_input("\t Enter the first port to scan:\t")) -port_2 = int (raw_input("\t Enter the last port to scan:\t")) -print "~"*50 -print "\n ...scanning target now. ",target_ip -print "~"*50 +port_2 = int(raw_input("\t Enter the last port to scan:\t")) +print("~"*50) +print("\n ...scanning target now. ", target_ip) +print("~"*50) try: - for port in range(port_1,port_2): - sock= socket.socket(socket.AF_INET,socket.SOCK_STREAM) + for port in range(port_1, port_2): + sock= socket.socket(socket.AF_INET, socket.SOCK_STREAM) socket.setdefaulttimeout(1) - result = sock.connect_ex((target_ip,port)) + result = sock.connect_ex((target_ip, port)) if result==0: - print "Found open port:\t", port + print("Found open port:\t", port) sock.close() except KeyboardInterrupt: - print "[!] Scan stopped by user... " + print("[!] Scan stopped by user... ") sys.exit() except socket.gaierror: - print "[!] The target's hostname could not be resolved..." + print("[!] The target's hostname could not be resolved...") sys.exit() except socket.error: - print "[!] Target is unreachable..." + print("[!] Target is unreachable...") sys.exit() -print "The scan is complete. Happy hacking!" +print("The scan is complete. Happy hacking!")