003random / 003Recon

Some tools to automate recon - 003random
https://poc-server.com/
294 stars 74 forks source link

bug in try-except clause makes header_scan.py impossible to use #16

Open michalmikulasi opened 4 years ago

michalmikulasi commented 4 years ago

in header_scan.py is this code snippet:

for domain in domains:
        if domain != "":
                try:
                        **_r = requests.head("https://"+domain, timeout=5)_**
                except:
                        print("[-]Error on https://"+domain)
                headers_found = []
                for header in headers:
                        _**current_header = r.headers.get(header.lower())**_
                        if current_header != None and "nginx" not in current_header.lower():
                                headers_found.append(str(current_header))
                if headers_found != []:
                        if is_closed:
                                file = open(output_file,"w+")
                                is_closed = False
                        print("[+]"+domain+" - "+str(headers_found))
                        file.write(domain+" - "+str(headers_found)+"\n")
                else:
                        print("[-]"+domain+" - "+str(headers_found))
        else:

So there is defined variable "r" and the variable is in try-except clause. Later the same variable is referenced again. The problem is, that if the TRY fails, the variable "r" is not defined, and therefore we get error(on the right side of the picture), we get "NameError: name 'r' is not defined"

try-except-error