From 623ba6c8dac19743e38892326b59ba2a83dd8f36 Mon Sep 17 00:00:00 2001 From: Tim Lavoie Date: Mon, 19 Aug 2019 12:14:12 -0700 Subject: [PATCH] Update subprocess calls for python3, fix TypeError --- Reconnoitre/lib/find_dns.py | 2 +- Reconnoitre/lib/hostname_scan.py | 2 +- Reconnoitre/lib/ping_sweeper.py | 3 +-- Reconnoitre/lib/service_scan.py | 6 +++--- Reconnoitre/lib/snmp_walk.py | 3 ++- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Reconnoitre/lib/find_dns.py b/Reconnoitre/lib/find_dns.py index 45dc213..a27dd3c 100644 --- a/Reconnoitre/lib/find_dns.py +++ b/Reconnoitre/lib/find_dns.py @@ -27,7 +27,7 @@ def find_dns(target_hosts, output_directory, quiet): print(" [>] Testing %s for DNS" % ip_address) DNSSCAN = "nmap -n -sV -Pn -vv -p53 %s" % (ip_address) - results = subprocess.check_output(DNSSCAN, shell=True).decode("utf-8") + results = subprocess.check_output(DNSSCAN, shell=True, text=True) lines = results.split("\n") for line in lines: diff --git a/Reconnoitre/lib/hostname_scan.py b/Reconnoitre/lib/hostname_scan.py index 0ac837c..88ea390 100644 --- a/Reconnoitre/lib/hostname_scan.py +++ b/Reconnoitre/lib/hostname_scan.py @@ -18,7 +18,7 @@ def hostname_scan(target_hosts, output_directory, quiet): else: SWEEP = "nbtscan -q %s" % (target_hosts) - results = subprocess.check_output(SWEEP, shell=True).decode("utf-8") + results = subprocess.check_output(SWEEP, shell=True,text=True) lines = results.split("\n") for line in lines: diff --git a/Reconnoitre/lib/ping_sweeper.py b/Reconnoitre/lib/ping_sweeper.py index 1f9db5c..7b20ae5 100644 --- a/Reconnoitre/lib/ping_sweeper.py +++ b/Reconnoitre/lib/ping_sweeper.py @@ -23,8 +23,7 @@ def ping_sweeper(target_hosts, output_directory, quiet): def call_nmap_sweep(target_hosts): SWEEP = "nmap -n -sP %s" % (target_hosts) - results = subprocess.check_output(SWEEP, shell=True) - lines = str(results).encode("utf-8").split("\n") + results = subprocess.check_output(SWEEP, shell=True, text=True) return lines diff --git a/Reconnoitre/lib/service_scan.py b/Reconnoitre/lib/service_scan.py index ff41ca9..1ed4168 100644 --- a/Reconnoitre/lib/service_scan.py +++ b/Reconnoitre/lib/service_scan.py @@ -20,7 +20,7 @@ def nmap_scan( QUICKSCAN = "nmap -sC -sV -Pn --disable-arp-ping %s -oA '%s/%s.quick'" % ( ip_address, output_directory, ip_address) quickresults = subprocess.check_output( - QUICKSCAN, shell=True).decode("utf-8") + QUICKSCAN, shell=True,text=True) write_recommendations(quickresults, ip_address, output_directory) print("[*] TCP quick scans completed for %s" % ip_address) @@ -70,8 +70,8 @@ def nmap_scan( ip_address, output_directory, ip_address) udpresult = "" if no_udp_service_scan is True else subprocess.check_output( - UDPSCAN, shell=True).decode("utf-8") - tcpresults = subprocess.check_output(TCPSCAN, shell=True).decode("utf-8") + UDPSCAN, shell=True, text=True) + tcpresults = subprocess.check_output(TCPSCAN, shell=True, text=True) write_recommendations(tcpresults + udpresult, ip_address, output_directory) print("[*] TCP%s scans completed for %s" % diff --git a/Reconnoitre/lib/snmp_walk.py b/Reconnoitre/lib/snmp_walk.py index 9a16574..d2c71ef 100644 --- a/Reconnoitre/lib/snmp_walk.py +++ b/Reconnoitre/lib/snmp_walk.py @@ -76,7 +76,8 @@ def snmp_scans(ip_address, output_directory): subprocess.check_output( SCAN, stderr=subprocess.STDOUT, - shell=True).decode("utf-8").decode('utf-8') + shell=True, + text=True) except Exception: print("[+] No Response from %s" % ip_address) except subprocess.CalledProcessError: