Skip to content

Crash scanning a Fritzbox with urllib.error.HTTPError: HTTP Error 404: Not Found #6

@hjgode

Description

@hjgode

Scanning my local network, the tool crashes by testing a Fritzbox 7590

`254 IPs scanned ... done
Exception in Tkinter callback
Traceback (most recent call last):
File "/home/hgode/git/espfinder-python/ef_net.py", line 190, in check80
content = urllib.request.urlopen("http://"+purl, None, 2)
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 523, in open
response = meth(req, response)
File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
response = self.parent.error(
File "/usr/lib/python3.9/urllib/request.py", line 561, in error
return self._call_chain(*args)
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.9/tkinter/init.py", line 1892, in call
return self.func(*args)
File "/home/hgode/git/espfinder-python/espfinder.py", line 196, in searchdevices
pingscan()
File "/home/hgode/git/espfinder-python/espfinder.py", line 110, in pingscan
PING_SWEEP(cb_stationsearch,ownip)
File "/home/hgode/git/espfinder-python/espfinder.py", line 31, in init
self.ping_sweeper()
File "/home/hgode/git/espfinder-python/espfinder.py", line 92, in ping_sweeper
self.callback(1,255)
File "/home/hgode/git/espfinder-python/espfinder.py", line 106, in cb_stationsearch
analyzerange()
File "/home/hgode/git/espfinder-python/espfinder.py", line 131, in analyzerange
analyzeip(hostadr)
File "/home/hgode/git/espfinder-python/espfinder.py", line 162, in analyzeip
attribs[3] = check80(str(par1)+":"+str(tport))
File "/home/hgode/git/espfinder-python/ef_net.py", line 193, in check80
if check_espurna(purl):
File "/home/hgode/git/espfinder-python/ef_net.py", line 600, in check_espurna
if check_port(purl, 80):
File "/home/hgode/git/espfinder-python/ef_net.py", line 156, in check_port
if sock.connect_ex((host, port)) == 0:
socket.gaierror: [Errno -2] Name or service not known
...`

I changed ef_net.py:

def check80(purl): tipus = "Unknown" rescode = 0 try: content = urllib.request.urlopen("http://"+purl, None, 2) httpcode = content.getcode() except: tipus = "HTTP Err: urlopen" return tipus ...

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