mushorg / glastopf

Web Application Honeypot
http://glastopf.org
560 stars 168 forks source link

rules for using own templates? #148

Closed gnusshall closed 10 years ago

gnusshall commented 10 years ago

hi,

i tried to put my own html files in /opt/myglas/data/templates/, respectively to replace the base.html but during the startup i get the following error:

root@debian:/opt/myglas# glastopf-runner
2014-01-15 15:59:48,085 (glastopf.glastopf) Initializing Glastopf 3.0.8 using "/opt/myglas" as work directory.
2014-01-15 15:59:48,086 (glastopf.glastopf) Connecting to main database with: sqlite:///db/glastopf.db
2014-01-15 15:59:48,099 (glastopf.glastopf) Generating initial dork pages - this can take a while.
Traceback (most recent call last):
  File "/usr/local/bin/glastopf-runner", line 78, in <module>
    honeypot = GlastopfHoneypot(work_dir=args.workdir)
  File "/usr/local/lib/python2.7/dist-packages/glastopf/glastopf.py", line 77, in __init__
    self.dork_generator.regular_generate_dork(0)
  File "/usr/local/lib/python2.7/dist-packages/glastopf/modules/handlers/emulators/dork_list/dork_page_generator.py", line 127, in regular_generate_dork
    self.generate_dork_pages()
  File "/usr/local/lib/python2.7/dist-packages/glastopf/modules/handlers/emulators/dork_list/dork_page_generator.py", line 103, in generate_dork_pages
    page_md5 = hashlib.md5(dork_page).hexdigest()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 6312: ordinal not in range(128)

are there any specific rules to follow? currently i am using 3.0.8 (until the 3.0.9-dev is fixed).

thanks!

Gernot

glaslos commented 10 years ago

Quick fix would be removing the ä from your custom template I guess :)

glaslos commented 10 years ago

I assume hashlib.md5() wants to decode the page content but doesn't know with which codes and takes ascii. Correct solution would be to read the content, try to decode it properly to unicode and then hand it over to hashlib (I might be wrong...)

gnusshall commented 10 years ago

that´s what i figured also. i removed all ä etc etc, the server starts now properly, at least without error but when i try to access it i get an "internal server error" in my browser and on the glastopf console is the following happening:

2014-01-15 16:33:00,506 (glastopf.glastopf) Initializing Glastopf 3.0.8 using "/opt/myglas" as work directory.
2014-01-15 16:33:00,507 (glastopf.glastopf) Connecting to main database with: sqlite:///db/glastopf.db
2014-01-15 16:33:00,519 (glastopf.glastopf) Generating initial dork pages - this can take a while.
2014-01-15 16:33:00,775 (pyhpfeeds) connecting to hpfriends.honeycloud.net:20000
2014-01-15 16:33:01,116 (pyhpfeeds) info message name: hpfriends, rand: '_\x9c\xdd\x91'
2014-01-15 16:33:01,130 (glastopf.glastopf) Glastopf started and privileges dropped.
2014-01-15 16:33:38,498 (glastopf.glastopf) 192.168.116.1 requested GET / on 192.168.116.146
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 508, in handle_one_response
    self.run_application()
  File "/usr/local/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/wsgi_wrapper.py", line 44, in application
    remote_addr, None)
  File "/usr/local/lib/python2.7/dist-packages/glastopf/glastopf.py", line 309, in handle_request
    emulator.handle(attack_event)
  File "/usr/local/lib/python2.7/dist-packages/glastopf/modules/handlers/emulators/unknown.py", line 57, in handle
    template, display_comments = self._get_template(attack_event)
  File "/usr/local/lib/python2.7/dist-packages/glastopf/modules/handlers/emulators/unknown.py", line 41, in _get_template
    self.dork_page = os.path.join(pages_path, choice(dork_page_list))
  File "/usr/lib/python2.7/random.py", line 274, in choice
    return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty
IndexError: list index out of range

(Duplicate info removed)

glaslos commented 10 years ago

This is the same issue as #147 I'll close this one (and open an issue for proper template decoding) and continue on the other.

gnusshall commented 10 years ago

are you sure that this is the same issue(?), because i am using stable 3.0.8 with those tests....

glaslos commented 10 years ago

Yes, same exception.