mushorg / glastopf

Web Application Honeypot
http://glastopf.org
550 stars 170 forks source link

Internal Server Error - UnicodeEncodeError #231

Closed alanlee02 closed 9 years ago

alanlee02 commented 9 years ago

I've got the 'Internal Server Error' all of a sudden today. Not sure what's going on.

2015-04-21 23:04:38,245 (glastopf.glastopf) xxx.xxx.xxx.xxx requested GET / on ip-xxx-xx-xx-xxx.us-west-2.compute.internal:80
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 508, in handle_one_response
    self.run_application()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 494, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/usr/local/lib/python2.7/dist-packages/Glastopf-3.1.3_dev-py2.7.egg/glastopf/wsgi_wrapper.py", line 50, in application
    remote_addr, sensor_addr)
  File "/usr/local/lib/python2.7/dist-packages/Glastopf-3.1.3_dev-py2.7.egg/glastopf/glastopf.py", line 268, in handle_request
    emulator.handle(attack_event)
  File "/usr/local/lib/python2.7/dist-packages/Glastopf-3.1.3_dev-py2.7.egg/glastopf/modules/handlers/emulators/unknown.py", line 52, in handle
    template, display_comments = self._get_template(attack_event)
  File "/usr/local/lib/python2.7/dist-packages/Glastopf-3.1.3_dev-py2.7.egg/glastopf/modules/handlers/emulators/unknown.py", line 45, in _get_template
    display_comments = '' + str(general_comments)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 931: ordinal not in range(128)
{'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.5',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'dancer.session=VTSV5H8KzLMdLBm7YkPuglyF0ai4lgaf',
 'HTTP_HOST': 'xx.xx.xx.xx',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0',
 'PATH_INFO': '/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': 'xx.xx.xx.xx',
 'REMOTE_PORT': '50377',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'ip-xx-xx-xx-xx.us-west-2.compute.internal',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fbc81ebb1e0>,
 'wsgi.input': <gevent.pywsgi.Input object at 0x7fbc79d0a0d0>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)} failed with UnicodeEncodeError
alanlee02 commented 9 years ago

Managed to fix it by changing /usr/local/lib/python2.7/dist-packages/Glastopf-3.1.3_dev-py2.7.egg/glastopf/modules/handlers/emulators/unknown.py

display_comments = '' + str(general_comments)

display_comments = u''.join(general_comments).encode('utf-8')

glaslos commented 9 years ago

Would you mind sending a pull request for that issue?