diff --git a/burpui/agent.py b/burpui/agent.py index eb937fc2..c26fc484 100644 --- a/burpui/agent.py +++ b/burpui/agent.py @@ -1,6 +1,5 @@ # -*- coding: utf8 -*- import os -import sys import struct import select import json @@ -66,7 +65,8 @@ class BUIAgent: 'get_client': self.backend.get_client, 'get_tree': self.backend.get_tree, 'restore_files': self.backend.restore_files, - 'read_conf': self.backend.read_conf + 'read_conf': self.backend.read_conf, + 'get_parser_attr': self.backend.get_parser_attr } self.server = AgentServer((self.bind, self.port), AgentTCPHandler, self) diff --git a/burpui/misc/backend/burp1.py b/burpui/misc/backend/burp1.py index f24e8fa6..c500c91e 100644 --- a/burpui/misc/backend/burp1.py +++ b/burpui/misc/backend/burp1.py @@ -699,4 +699,11 @@ class Burp(BUIbackend): return zip_file def read_conf(self, agent=None): + if not self.parser: + return None return self.parser.readfile() + + def get_parser_attr(self, attr=None, agent=None): + if not attr or not self.parser: + return None + return self.parser.getkey(attr) diff --git a/burpui/misc/backend/interface.py b/burpui/misc/backend/interface.py index 9d792fe0..538697a8 100644 --- a/burpui/misc/backend/interface.py +++ b/burpui/misc/backend/interface.py @@ -33,6 +33,9 @@ class BUIbackend: def restore_files(self, name=None, backup=None, files=None, strip=None, agent=None): raise NotImplementedError("Sorry, the current Backend does not implement this method!") + def def get_parser_attr(self, attr=None, agent=None): + raise NotImplementedError("Sorry, the current Backend does not implement this method!") + class BUIserverException(Exception): pass diff --git a/burpui/misc/backend/multi.py b/burpui/misc/backend/multi.py index 0c59f981..9d5663c6 100644 --- a/burpui/misc/backend/multi.py +++ b/burpui/misc/backend/multi.py @@ -115,6 +115,9 @@ class Burp(BUIbackend): def read_conf(self, agent=None): return self.servers[agent].read_conf() + def get_parser_attr(self, attr=None, agent=None): + return self.servers[agent].get_parser_attr(attr) + class NClient(BUIbackend): def __init__(self, app=None, host=None, port=None, password=None, ssl=None): @@ -277,3 +280,7 @@ class NClient(BUIbackend): def read_conf(self, agent=None): data = {'func': 'read_conf', 'args': None} return json.loads(self.do_command(data)) + + def get_parser_attr(self, attr=None, agent=None): + data = {'func': 'get_parser_attr', 'args': {'attr': attr}} + return json.loads(self.do_command(data)) diff --git a/burpui/misc/parser/burp1.py b/burpui/misc/parser/burp1.py index acb4fa88..e6e9f5d3 100644 --- a/burpui/misc/parser/burp1.py +++ b/burpui/misc/parser/burp1.py @@ -261,3 +261,9 @@ class Parser(BUIparser): break return res + + def getkey(self, key): + try: + return getattr(self, key) + except: + return None diff --git a/burpui/misc/parser/interface.py b/burpui/misc/parser/interface.py index d7a14990..17cdefaf 100644 --- a/burpui/misc/parser/interface.py +++ b/burpui/misc/parser/interface.py @@ -6,4 +6,7 @@ class BUIparser: self.conf = conf def readfile(self): - raise NotImplementedError("Sorry, the current Backend does not implement this method!") + raise NotImplementedError("Sorry, the current Parser does not implement this method!") + + def getkey(self, key): + raise NotImplementedError("Sorry, the current Parser does not implement this method!") diff --git a/burpui/routes.py b/burpui/routes.py index e2fe6dcd..8b899321 100644 --- a/burpui/routes.py +++ b/burpui/routes.py @@ -29,7 +29,7 @@ def settings(server=None): @app.route('/api//srvconfig') @login_required def read_conf_srv(server=None): - r = bui.cli.read_conf() + r = bui.cli.read_conf(server) return jsonify(results=r,boolean=bui.cli.parser.boolean) @app.route('/api/restore//', methods=['POST'])