glastopf/conpot — pull request #63 by creolis (2013-07-08 20:00:02+00:00)
Title: Implemented advanced ( highly configurable ) HTTP support

A sneak preview of my highly configurable HMI module / HTTP Server is available at 0d30c07. It should allow to replicate interfaces with a high grade of detail.

A running example, featuring a low-interaction copy of a PLC-1500, is available here for
your reference: http://91.219.68.113:8000/ - it will be disabled after you had a look at it.
Please note that some fields are pulled dynamically from SNMP ( Station Name, Module Uptime )
and evals ( Time and Date on the upper right ). The interfaces values are automatically updated
every 10 seconds ( this is a feature of the templated Siemens HMI, not a feature of my module ).

The commit is full of debug outputs for now, of course they are going to be removed.
The source code is heavily documented to increase readability.

FEATURES:

* Fully customizable headers ( per-server and per-file configurable )
* Fully customizable HTTP status code responses
* Support for GET method
* Support for POST method
* Support for HEAD method ( can be disabled in configuration )
* Support for TRACE method ( can be disabled in configuration )
* Dynamic header support ( "Date" response header will be updated at every request )
* Dynamic content support ( Tags found in text/html content type can be replaced with dynamic values gathered from SNMP and Python eval() )
* Backproxy support ( Requests to certain files or even status codes (e.g. 404) can be proxied to a remote HTTP server which is provided with original request data. The unmodified response is then delivered to the client ).
* Path traversal security ( Filesystem is fully specified in template - traversal is not possible ).
* Aliases can be configured ( for files and status codes ).

KNOWN ISSUES:

* chunked-encoding are not supported locally.
* chunked-encoding are modified through Backproxy ( it currently converts chunk-encoded answers to simple ( content-length powered ) answers.
* test cases are not available (yet).
* TRACE method currently modifies header capitalization.
* http module currently does not shut down correctly when conpot quits.

I'm looking forward to hear your opinion.