rework installer and remove external scripts

This commit is contained in:
ziirish 2015-10-19 21:13:13 +02:00
parent 8f2abd78ee
commit 6b6113b236
7 changed files with 192 additions and 146 deletions

96
burpui/__main__.py Normal file
View file

@ -0,0 +1,96 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
import sys
import os
from argparse import ArgumentParser
sys.path.append('{0}/..'.format(os.path.join(os.path.dirname(os.path.realpath(__file__)))))
def parse_args(mode=True, name=None):
if not name:
name = 'burp-ui'
parser = ArgumentParser(prog=name)
parser.add_argument('-v', '--verbose', dest='log', help='increase output verbosity (e.g., -vv is more than -v)', action='count')
parser.add_argument('-d', '--debug', dest='log', help='alias for -v', action='count') # alias for -v
parser.add_argument('-V', '--version', dest='version', help='print version and exit', action='store_true')
parser.add_argument('-c', '--config', dest='config', help='configuration file', metavar='CONFIG')
parser.add_argument('-l', '--logfile', dest='logfile', help='output logs in defined file', metavar='FILE')
if mode:
parser.add_argument('-m', '--mode', dest='mode', help='application mode (server or agent)', metavar='MODE')
options = parser.parse_args()
if options.version:
from burpui import __title__, __version__
print ('{}: v{}'.format(__title__, __version__))
sys.exit(0)
return options
def main():
"""
Main function
"""
options = parse_args(mode=True)
if not options.mode or options.mode == 'server':
server(options)
else:
agent(options)
def server(options=None):
from burpui import bui as server, init, lookup_config
if not options:
options = parse_args(mode=False)
conf = lookup_config()
check_config(conf)
init(conf, options.log, options.logfile, False)
server.run()
def agent(options=None):
from burpui.agent import BUIAgent as Agent
if not options:
options = parse_args(mode=False, name='bui-agent')
conf = None
if options.config:
conf = options.config
else:
root = os.path.join(
sys.prefix,
'share',
'burpui',
'etc'
)
conf_files = [
'/etc/burp/buiagent.cfg',
os.path.join(root, 'buiagent.cfg'),
os.path.join(root, 'buiagent.sample.cfg')
]
for p in conf_files:
if os.path.isfile(p):
conf = p
break
check_config(conf)
agent = Agent(conf, options.log, options.logfile)
agent.run()
def check_config(conf):
if not conf or not os.path.isfile(conf):
raise IOError('File not found: \'{0}\''.format(conf))
if __name__ == '__main__':
main()