From 18bbf8e56dcc3aa689ef33809f724781c6adb792 Mon Sep 17 00:00:00 2001 From: Justino Vasquez Date: Sun, 7 Jun 2020 16:15:13 -0500 Subject: [PATCH 1/3] added library for json IO --- scanner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scanner.py b/scanner.py index b135557..97820d6 100644 --- a/scanner.py +++ b/scanner.py @@ -3,6 +3,7 @@ import subprocess import sys from datetime import datetime +import json # Clear the screen subprocess.call('clear', shell=True) From 8db37d9e7aa57f92c32bf4a4d69b824932122c9e Mon Sep 17 00:00:00 2001 From: Justino Vasquez Date: Sun, 7 Jun 2020 16:16:34 -0500 Subject: [PATCH 2/3] Added port range input read from config.json --- scanner.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scanner.py b/scanner.py index 97820d6..3c09cc9 100644 --- a/scanner.py +++ b/scanner.py @@ -8,6 +8,13 @@ # Clear the screen subprocess.call('clear', shell=True) +# Pull port range from config.json +with open("config.json") as json_file: + data = json.load(json_file) + loRange = int(data['range']['low']) + hiRange = int(data['range']['high']) + + # Ask for input remoteServer = raw_input("Enter a remote host to scan: ") remoteServerIP = socket.gethostbyname(remoteServer) From 1fc0aedf701834d652ca06ba9a2fe8c61a7f0630 Mon Sep 17 00:00:00 2001 From: Justino Vasquez Date: Sun, 7 Jun 2020 16:17:21 -0500 Subject: [PATCH 3/3] updated syntax for Python 3.8.3 --- scanner.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scanner.py b/scanner.py index 3c09cc9..f173c6d 100644 --- a/scanner.py +++ b/scanner.py @@ -16,37 +16,37 @@ # Ask for input -remoteServer = raw_input("Enter a remote host to scan: ") +remoteServer = input("Enter a remote host to scan: ") remoteServerIP = socket.gethostbyname(remoteServer) # Print a nice banner with information on which host we are about to scan -print "-" * 60 -print "Please wait, scanning remote host....", remoteServerIP -print "-" * 60 +print ("-" * 60) +print ("Please wait, scanning remote host....", remoteServerIP) +print ("-" * 60) # Check what time the scan started t1 = datetime.now() -# scanning the port only in range of (1, 8888) +# scanning the port in range specified in config.json try: - for port in range(1,8888): + for port in range(loRange,hiRange): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) result = sock.connect_ex((remoteServerIP, port)) if result == 0: - print "Port {}: Open".format(port) + print("Port {}: Open".format(port)) sock.close() except KeyboardInterrupt: - print "You pressed Ctrl+C" + print("You pressed Ctrl+C") sys.exit() except socket.gaierror: - print 'Hostname could not be resolved. Exiting' + print ("Hostname could not be resolved. Exiting") sys.exit() except socket.error: - print "Couldn't connect to server" + print ("Couldn't connect to server") sys.exit() # Checking the time again @@ -56,4 +56,4 @@ total = t2 - t1 # Printing the information to screen -print 'Scanning Completed in: ', total +print ('Scanning Completed in: ', total)