From a920508c8474d80cadb07ab26ce4578927dbdbac Mon Sep 17 00:00:00 2001 From: ziirish Date: Thu, 2 Oct 2014 18:09:48 +0200 Subject: [PATCH] add: gunicorn support --- README.rst | 27 ++++++++++++++++++++++++++- bin/burp-ui | 22 ++-------------------- burpui/__init__.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 2b15e480..20959049 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,7 @@ Build Status .. image:: http://ci.ziirish.me/projects/1/status.png?ref=master :target: http://ci.ziirish.me/projects/1?ref=master + Requirements ------------ @@ -29,7 +30,7 @@ Then we install the module itself: Installation ------------ -Burp-UI is written in Python with the `Flask`_ micro-framework. +``Burp-UI`` is written in Python with the `Flask`_ micro-framework. The easiest way to install Flask is to use ``pip``. On Debian, you can install ``pip`` with the following command: @@ -58,6 +59,27 @@ By default, ``burp-ui`` listens on all interfaces (including IPv6) on port 5000. You can then point your browser to http://127.0.0.1:5000/ + +Gunicorn +-------- + +``Burp-UI`` now supports `Gunicorn `_ in order to handle +multiple users simultaneously. + +You need to install ``gunicorn`` and ``eventlet``: + +:: + + pip install eventlet + pip install gunicorn + +You will then be able to launch ``Burp-UI`` this way: + +:: + + gunicorn -k eventlet -w 4 'burpui:init(conf="/path/to/burpui.cfg")' + + Instructions ------------ @@ -74,6 +96,7 @@ you need to check a few things: restore files of other clients (option *restore_client* in burp-server configuration) + Notes ----- @@ -89,6 +112,7 @@ TODO Also note that in the future, I'd like to write a burp-client GUI. But I didn't think yet of what to do. + Changelog --------- @@ -133,6 +157,7 @@ But this project is built on top of other tools listed here: Also note that this project is made with the Awesome `Flask`_ micro-framework. + Thanks ------ diff --git a/bin/burp-ui b/bin/burp-ui index d457d9b5..bf162e5e 100755 --- a/bin/burp-ui +++ b/bin/burp-ui @@ -2,12 +2,11 @@ # -*- coding: utf8 -*- import sys import os -import os.path from optparse import OptionParser sys.path.append('{0}/..'.format(os.path.join(os.path.dirname(os.path.realpath(__file__))))) -from burpui import app, bui +from burpui import bui, init if __name__ == '__main__': """ @@ -19,25 +18,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args() d = options.log - app.config['DEBUG'] = d - if d: - app.config['TESTING'] = True - if options.config: - if os.path.isfile(options.config): - conf = options.config - app.config['CFG'] = conf - else: - raise IOError('File not found: \'{0}\''.format(options.config)) - else: - conf_files = ['/etc/burp/burpui.cfg', os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'share', 'burpui', 'etc', 'burpui.cfg')] - for p in conf_files: - app.logger.debug('Trying file \'%s\'', p) - if os.path.isfile(p): - app.config['CFG'] = p - app.logger.debug('Using file \'%s\'', p) - break + init(options.config, d, False) - bui.setup(app.config['CFG']) bui.run(d) diff --git a/burpui/__init__.py b/burpui/__init__.py index c2e4c235..60daa7c2 100644 --- a/burpui/__init__.py +++ b/burpui/__init__.py @@ -7,6 +7,7 @@ __title__ = 'burp-ui' __author__ = 'Benjamin SANS (Ziirish)' __license__ = 'BSD 3-clause' +import os from flask import Flask from flask.ext.login import LoginManager @@ -31,3 +32,30 @@ login_manager.login_message_category = 'info' # Then we load our routes import burpui.routes + +def init(conf=None, debug=False, gunicorn=True): + app.config['DEBUG'] = debug + if debug: + app.config['TESTING'] = True + + if conf: + if os.path.isfile(conf): + app.config['CFG'] = conf + else: + raise IOError('File not found: \'{0}\''.format(conf)) + else: + conf_files = ['/etc/burp/burpui.cfg', os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', '..', 'share', 'burpui', 'etc', 'burpui.cfg')] + for p in conf_files: + app.logger.debug('Trying file \'%s\'', p) + if os.path.isfile(p): + app.config['CFG'] = p + app.logger.debug('Using file \'%s\'', p) + break + + bui.setup(app.config['CFG']) + + if gunicorn: + from werkzeug.contrib.fixers import ProxyFix + app.wsgi_app = ProxyFix(app.wsgi_app) + + return app