Skip to content

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

Description

@michalmikulasi

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions