diff --git a/src/ipscanner.py b/src/ipscanner.py index 09775ca..2055462 100644 --- a/src/ipscanner.py +++ b/src/ipscanner.py @@ -5,15 +5,15 @@ from multi.scanner_thread import split_processing # Ask for input -net1 = raw_input('Enter the IP address: ') +net1 = input('Enter the IP address: ') net2 = net1.split('.') a = '.' net3 = net2[0] + a + net2[1] + a + net2[2] + a # Print a nice banner with information on which host we are about to scan -print "-" * 60 -print "Please wait, scanning IP address....", net3+"XXX" -print "-" * 60 +print ("-" * 60) +print ("Please wait, scanning IP address....", net3+"XXX") +print ("-" * 60) # Resolves the relative path to absolute path # [BUG]: https://github.com/vinitshahdeo/PortScanner/issues/19 @@ -67,7 +67,7 @@ def run1(ips, range_low, range_high): addr = net3+str(ip) # gets full address if (scan(addr)): - print addr + " is live\n" + print (addr + " is live\n") # calling function from scanner_thread.py for multithreading @@ -77,4 +77,4 @@ def run1(ips, range_low, range_high): # Calculates the difference of time, to see how long it took to run the script total = td2-td1 # Printing the information to screen -print "Scanning completed in ", total +print ("Scanning completed in ", total) diff --git a/src/mainScanner.py b/src/mainScanner.py index fdc44eb..2d05503 100644 --- a/src/mainScanner.py +++ b/src/mainScanner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import socket import subprocess import sys @@ -6,7 +6,7 @@ import json import os import threading -import __builtin__ +import builtins from multi.scanner_thread import split_processing import logging from flask import Flask, render_template, request, redirect, url_for @@ -19,7 +19,7 @@ def homepage(): return render_template('index.html') -exc = getattr(__builtin__, "IOError", "FileNotFoundError") +exc = getattr(__builtins__, "IOError", "FileNotFoundError") # Clear the screen # subprocess.call('clear', shell=True) @@ -37,9 +37,9 @@ def input(): return EnvironmentError # 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) # Resolves the relative path to absolute path # [BUG]: https://github.com/vinitshahdeo/PortScanner/issues/19 @@ -56,7 +56,7 @@ def get_absolute_path(relative_path): try: with open(get_absolute_path('../config.json')) as config_file: config = json.load(config_file) - print get_absolute_path('../config.json') + print (get_absolute_path('../config.json')) # defining number of threads running concurrently CONST_NUM_THREADS = int(config['thread']['count']) @@ -76,20 +76,20 @@ def scan(ports, range_low, range_high): 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)) portnum.append("Port "+str(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() # calling function from scanner_thread.py for multithreading @@ -102,7 +102,7 @@ def scan(ports, range_low, range_high): total = t2 - t1 # Printing the information to screen - print 'Scanning Completed in: ', total + print ('Scanning Completed in: ', total) return render_template('index.html', portnum=portnum, host=remoteServerIP, range_low=range_low, range_high=range_high, total=total) diff --git a/src/scanner.py b/src/scanner.py old mode 100644 new mode 100755 index 1cdf98b..c026dcc --- a/src/scanner.py +++ b/src/scanner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import socket import subprocess import sys @@ -6,22 +6,22 @@ import json import os import threading -import __builtin__ +import builtins from multi.scanner_thread import split_processing -exc = getattr(__builtin__, "IOError", "FileNotFoundError") +exc = getattr(__builtins__, "IOError", "FileNotFoundError") # Clear the screen subprocess.call('clear', shell=True) # 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) # Resolves the relative path to absolute path # [BUG]: https://github.com/vinitshahdeo/PortScanner/issues/19 @@ -38,7 +38,7 @@ def get_absolute_path(relative_path): try: with open(get_absolute_path('../config.json')) as config_file: config = json.load(config_file) - print get_absolute_path('../config.json') + print( get_absolute_path('../config.json')) range_high = int(config['range']['high']) range_low = int(config['range']['low']) # defining number of threads running concurrently @@ -58,19 +58,19 @@ def scan(ports, range_low, range_high): 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() @@ -84,4 +84,4 @@ def scan(ports, range_low, range_high): total = t2 - t1 # Printing the information to screen -print 'Scanning Completed in: ', total +print ('Scanning Completed in: ', total) diff --git a/src/single/scanner.py b/src/single/scanner.py old mode 100644 new mode 100755 index b135557..42122d3 --- a/src/single/scanner.py +++ b/src/single/scanner.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import socket import subprocess import sys @@ -8,13 +8,13 @@ subprocess.call('clear', shell=True) # 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() @@ -26,19 +26,19 @@ 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 @@ -48,4 +48,4 @@ total = t2 - t1 # Printing the information to screen -print 'Scanning Completed in: ', total +print ('Scanning Completed in: ', total)