diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..44585e3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include *.txt *.ini *.cfg *.rst +recursive-include honeypot *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 diff --git a/Pipfile b/Pipfile index 7a9e19a..ea1b6fd 100644 --- a/Pipfile +++ b/Pipfile @@ -4,6 +4,7 @@ verify_ssl = true name = "pypi" [packages] +"e1839a8" = {path = ".", editable = true} [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..12c1151 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,116 @@ +{ + "_meta": { + "hash": { + "sha256": "a166821031f60007a08b6fec9ba3caa9dc601786a8eb3ed72bbd9342668d2b3d" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "e1839a8": { + "editable": true, + "path": "." + }, + "hupper": { + "hashes": [ + "sha256:20387760e4d32bd4813c2cabc8e51d92b2c22c546102a0af182c33c152cd7ede", + "sha256:6b8133e9c5cc0a8ec422a29ef3b38aea2c49a809a0af73f419a78a7015b32615" + ], + "version": "==1.3" + }, + "pastedeploy": { + "hashes": [ + "sha256:39973e73f391335fac8bc8a8a95f7d34a9f42e2775600ce2dc518d93b37ef943", + "sha256:d5858f89a255e6294e63ed46b73613c56e3b9a2d82a42f1df4d06c8421a9e3cb" + ], + "version": "==1.5.2" + }, + "plaster": { + "hashes": [ + "sha256:215c921a438b5349931fd7df9a5a11a3572947f20f4bc6dd622ac08f1c3ba249", + "sha256:8351c7c7efdf33084c1de88dd0f422cbe7342534537b553c49b857b12d98c8c3" + ], + "version": "==1.0" + }, + "plaster-pastedeploy": { + "hashes": [ + "sha256:25cc239d767c5fab0afa44b1ed3c1a33a3d7ec6302ff2e599aec674b77ff6667", + "sha256:70a3185b2a3336996a26e9987968cf35e84cf13390b7e8a0a9a91eb8f6f85ba9" + ], + "version": "==0.5" + }, + "pyramid": { + "hashes": [ + "sha256:600f12e0d11211a55c2da970120af33214f77607ed45caba6af6c891afeaa771", + "sha256:cf89a48cb899291639686bf3d4a883b39e496151fa4871fb83cc1a3200d5b925" + ], + "version": "==1.9.2" + }, + "repoze.lru": { + "hashes": [ + "sha256:0429a75e19380e4ed50c0694e26ac8819b4ea7851ee1fc7583c8572db80aff77", + "sha256:f77bf0e1096ea445beadd35f3479c5cff2aa1efe604a133e67150bc8630a62ea" + ], + "version": "==0.7" + }, + "translationstring": { + "hashes": [ + "sha256:4ee44cfa58c52ade8910ea0ebc3d2d84bdcad9fa0422405b1801ec9b9a65b72d", + "sha256:e26c7bf383413234ed442e0980a2ebe192b95e3745288a8fd2805156d27515b4" + ], + "version": "==1.3" + }, + "venusian": { + "hashes": [ + "sha256:757162c5f907e18571b6ab41b7673e5bf18cc8715abf8164292eaef4f1610668", + "sha256:9902e492c71a89a241a18b2f9950bea7e41d025cc8f3af1ea8d8201346f8577d" + ], + "version": "==1.1.0" + }, + "waitress": { + "hashes": [ + "sha256:40b0f297a7f3af61fbfbdc67e59090c70dc150a1601c39ecc9f5f1d283fb931b", + "sha256:d33cd3d62426c0f1b3cd84ee3d65779c7003aae3fc060dee60524d10a57f05a9" + ], + "version": "==1.1.0" + }, + "webob": { + "hashes": [ + "sha256:1771899117c8851153f6f91e8b8a86236972aa8a1b6bd69ad0a36a9879ea2cd7", + "sha256:54f35073d2fdcddd7a98c2a1dedeede49739150737164a787220f30283139ba6" + ], + "version": "==1.8.1" + }, + "zope.deprecation": { + "hashes": [ + "sha256:7d52e134bbaaa0d72e1e2bc90f0587f1adc116c4bdf15912afaf2f1e8856b224", + "sha256:c83cfef3085d10dcb07de5a59a2d95713865befa46e0e88784c5648610fba789" + ], + "version": "==4.3.0" + }, + "zope.interface": { + "hashes": [ + "sha256:21506674d30c009271fe68a242d330c83b1b9d76d62d03d87e1e9528c61beea6", + "sha256:3d184aff0756c44fff7de69eb4cd5b5311b6f452d4de28cb08343b3f21993763", + "sha256:467d364b24cb398f76ad5e90398d71b9325eb4232be9e8a50d6a3b3c7a1c8789", + "sha256:57c38470d9f57e37afb460c399eb254e7193ac7fb8042bd09bdc001981a9c74c", + "sha256:9ada83f4384bbb12dedc152bcdd46a3ac9f5f7720d43ac3ce3e8e8b91d733c10", + "sha256:a1daf9c5120f3cc6f2b5fef8e1d2a3fb7bbbb20ed4bfdc25bc8364bc62dcf54b", + "sha256:e6b77ae84f2b8502d99a7855fa33334a1eb6159de45626905cb3e454c023f339", + "sha256:e881ef610ff48aece2f4ee2af03d2db1a146dc7c705561bd6089b2356f61641f", + "sha256:f41037260deaacb875db250021fe883bf536bf6414a4fd25b25059b02e31b120" + ], + "version": "==4.5.0" + } + }, + "develop": {} +} diff --git a/development.ini b/development.ini new file mode 100644 index 0000000..c78b528 --- /dev/null +++ b/development.ini @@ -0,0 +1,57 @@ +### +# app configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +### + +[app:main] +use = egg:honeypot + +pyramid.reload_templates = true +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en + +# By default, the toolbar only appears for clients from IP addresses +# '127.0.0.1' and '::1'. +# debugtoolbar.hosts = 127.0.0.1 ::1 + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +listen = localhost:6543 + +### +# logging configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, honeypot + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = INFO +handlers = console + +[logger_honeypot] +level = DEBUG +handlers = +qualname = honeypot + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/honeypot/__init__.py b/honeypot/__init__.py new file mode 100644 index 0000000..ae6830a --- /dev/null +++ b/honeypot/__init__.py @@ -0,0 +1,61 @@ +import pprint + +from collections import OrderedDict +from pyramid.config import Configurator +from pyramid.response import Response +from pyramid.view import view_config + + +class RootResource: + ''' A simple 'catch all' resource ''' + + def __init__(self, request): + ''' initialization ''' + pass + + def __getitem__(self, key): + ''' no child resource lookup, only one view used''' + return self + + +def _dict_helper(dict_like): + return [f' {k}: {v}' for k, v in dict_like.items()] + + +@view_config(context=RootResource) +def the_view(context, request): + + body = [ + 'Someone Wanted Some Sweet Honey', + '-------------------------------', + '', + f'requested url: {request.url}', + f'request method: {request.method}', + f'client ip address: {request.client_addr}', + f'remote ip address: {request.remote_addr}', + '', + f'request.authorization: {request.authorization}', + f'request.remote_user: {request.remote_user}', + '', + 'headers:' + ] + + body.extend(_dict_helper(request.headers)) + + body.extend(['', 'cookies:']) + if request.cookies: + body.extend(_dict_helper(request.cookies)) + else: + body.append(' (no cookies)') + + return Response(body='\n'.join(body), content_type='text/plain') + + + +def main(global_config, **settings): + """ This function returns a Pyramid WSGI application. + """ + config = Configurator(settings=settings) + config.set_root_factory(RootResource) + config.scan() + return config.make_wsgi_app() diff --git a/production.ini b/production.ini new file mode 100644 index 0000000..a7aa279 --- /dev/null +++ b/production.ini @@ -0,0 +1,53 @@ +### +# app configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html +### + +[app:main] +use = egg:honeypot + +pyramid.reload_templates = false +pyramid.debug_authorization = false +pyramid.debug_notfound = false +pyramid.debug_routematch = false +pyramid.default_locale_name = en + +### +# wsgi server configuration +### + +[server:main] +use = egg:waitress#main +listen = *:6543 + +### +# logging configuration +# https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html +### + +[loggers] +keys = root, honeypot + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console + +[logger_honeypot] +level = WARN +handlers = +qualname = honeypot + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(asctime)s %(levelname)-5.5s [%(name)s:%(lineno)s][%(threadName)s] %(message)s diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0659866 --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +import os + +from setuptools import setup, find_packages + +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, 'README.md')) as f: + README = f.read() + +requires = [ + 'plaster_pastedeploy', + 'pyramid', + 'waitress', +] + +setup( + name='honeypot', + version='0.0.1', + description='HoneyPot', + long_description=README, + classifiers=[ + 'Programming Language :: Python', + 'Framework :: Pyramid', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', + ], + author='Holger Frey', + author_email='frey@imtek.de', + url='https://git.cpi.imtek.uni-freiburg.de/holgi/honeypot', + keywords='web pyramid pylons', + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=requires, + entry_points={ + 'paste.app_factory': [ + 'main = honeypot:main', + ], + }, +)