From 9be4666773d8504cb49b549c7294876d62f551d8 Mon Sep 17 00:00:00 2001 From: cclauss Date: Sat, 2 Jun 2018 09:43:44 -0400 Subject: [PATCH] Define raw_input() for Python 3 In Python 3, __raw_input()__ has been replaced with __input()__ * Also added __.strip()__ to input statements to deal gracefully with leading or trailing spaces. --- python/quick_scanner.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/quick_scanner.py b/python/quick_scanner.py index 9abf432..af06cb6 100644 --- a/python/quick_scanner.py +++ b/python/quick_scanner.py @@ -9,6 +9,11 @@ from __future__ import print_function import socket, subprocess, sys +try: + raw_input # Python 2 +except NameError: + raw_input = input # Python 3 + subprocess.call('clear', shell=True) print('''\t @@ -25,9 +30,9 @@ 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")) +target_ip = raw_input("\t Please enter the IP address of the target host:").strip() +port_1 = int(raw_input("\t Enter the first port to scan:\t").strip()) +port_2 = int(raw_input("\t Enter the last port to scan:\t").strip()) print("~"*50) print("\n ...scanning target now. ", target_ip) print("~"*50)