ncorbuk / SubZone

SubZone - Subdomains, Dns records, & more! || Python tutorial || Certificate authority abuse || Adavnced || Hacking/Info-Sec ||
MIT License
43 stars 12 forks source link

NameError/UnboundLocalError? #3

Closed 42B closed 5 years ago

42B commented 5 years ago

https://github.com/ncorbuk/SubZone/blob/abcaf21b6a9473cf80cfafe5824180c71b2efa7d/subzone_v2.0.py#L120-L127

>>> def parse_url():
...     try:
...         host = {}['unknown key']
...     except Exception as e:
...         print('parse_url//Error: %s' % (e))
...         pass
...     return host
... 
>>> parse_url()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 7, in parse_url
UnboundLocalError: local variable 'host' referenced before assignment
parse_url//Error: 'unknown key'

>>> try:
...     host = {}['unknown key']
... except Exception as e:
...     print('parse_url//Error: %s' % (e))
...     pass
... print(host)
Traceback (most recent call last):
  File "<input>", line 6, in <module>
NameError: name 'host' is not defined
parse_url//Error: 'unknown key'
ncorbuk commented 5 years ago

Uhm dont get this, so that means you cant run the program?? ive just ran it and got all facebook subdomains etc?

ncorbuk commented 5 years ago

no errors or anything

42B commented 5 years ago

Try an invalid domain...

ncorbuk commented 5 years ago

when you say invalid domain can you give me an example

ncorbuk commented 5 years ago
def parse_url(self):
    #parse host from scheme, to use for certificate transparency abuse
    try:
        host = urllib3.util.url.parse_url(self.domain).host
    except Exception as e:
        print(f'Invalid - Domain, try again...')
        exit(1)
    return host
ncorbuk commented 5 years ago

Just did that if its invalid then tell them exit for them to try again, so i guess its fixed

42B commented 5 years ago

Tabs still?

42B commented 5 years ago

https://docs.python.org/3/library/urllib.parse.html