GhostManager / Shepherd

A Django application to help red team operators manage a library of domain names
https://medium.com/@cmaddy/being-a-good-domain-shepherd-part-2-5e8597c3fe63
161 stars 37 forks source link

"Update Categories" fails when using unicode domains #11

Closed ghost closed 1 year ago

ghost commented 5 years ago

The application fails to update domain categories when it is tracking a unicode domain. The following error is displayed in the console:

[+] Starting update of $UNICODE_DOMAIN
20:01:16 [Q] ERROR Failed [autumn-three-steak-earth] - name 'error' is not defined : Traceback (most recent call last):
  File "/home/USER/Code/Shepherd/modules/review.py", line 126, in check_ibm_xforce
    req = self.session.get(xforce_api_uri, headers=headers, verify=False)
  File "/home/USER/.local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/home/USER/.local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/USER/.local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/USER/.local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/home/USER/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/home/USER/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 355, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1270, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.7/http/client.py", line 1202, in putheader
    values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 54-55: ordinal not in range(256)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/USER/.local/lib/python3.7/site-packages/django_q/cluster.py", line 381, in worker
    res = f(*task['args'], **task['kwargs'])
  File "/home/USER/Code/Shepherd/tasks.py", line 105, in check_domains
    lab_results = domain_review.check_domain_status()
  File "/home/USER/Code/Shepherd/modules/review.py", line 450, in check_domain_status
    xforce_results = self.check_ibm_xforce(domain_name)
  File "/home/USER/Code/Shepherd/modules/review.py", line 143, in check_ibm_xforce
    print('[!] IBM X-Force request failed: {}'.format(error))
NameError: name 'error' is not defined
chrismaddalena commented 5 years ago

Of course, that makes sense. I'll look into this and see what we can do.

The good news, for now, is the code tries to handle these failures. It's just that the error handling is apparently broken. Oops! I'll get that fixe din this next update I'm preparing and then work on handling unicode domains.

Thanks for heads up!