From 280bf9135911f210e041ffcc29c5fbc48e7f6921 Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Thu, 22 Aug 2019 15:46:36 +0200 Subject: [PATCH] compatible with new beroot version (check readme) --- pupy/modules/beroot.py | 81 +++++++++++------------------------------- 1 file changed, 21 insertions(+), 60 deletions(-) diff --git a/pupy/modules/beroot.py b/pupy/modules/beroot.py index 4230a051..355f42a2 100644 --- a/pupy/modules/beroot.py +++ b/pupy/modules/beroot.py @@ -14,7 +14,7 @@ class Beroot(PupyModule): 'beroot' ], 'windows': [ - 'pyexpat', 'xml', '_elementtree', 'xml.etree', 'impacket', 'impacket.examples', 'beroot' + 'pyexpat', 'xml', '_elementtree', 'xml.etree', 'win32net', 'beroot' ] } @@ -32,71 +32,32 @@ class Beroot(PupyModule): header += '|====================================================================|\n\n' cls.arg_parser = PupyArgumentParser(prog="beroot", description=header + cls.__doc__) - cls.arg_parser.add_argument("-c", "--cmd", action="store", default="whoami", help="Windows only: cmd to execute for the webclient check (default: whoami)") + cls.arg_parser.add_argument("-p", "--password", action="store", default=None, help="if no NOPASSWD in sudoers, " + "sudo -ll needs user " + "password (Linux only)") def run(self, args): run_beroot = self.client.remote('beroot.run', 'run') if self.client.is_windows(): - results = run_beroot(args.cmd) - for r in results: - self.windows_output(r) - else: results = run_beroot() - for r in results: - self.linux_output(level=r[0], msg=r[1]) + if results: + for r in results: + self.windows_output(r) + else: + self.log('Nothing found.') + else: + results = run_beroot(args.password, to_print=False) + self.log(results) def windows_output(self, output): - to_print = True - if 'NotPrint' in output: - to_print = False - - st = '\n-------------- %s --------------\n' % output['Category'] - if 'list' in str(type(output['All'])): - for results in output['All']: - st += '\n[!] %s\n' % results['Function'].capitalize() - - results = results['Results'] - - # return only one result (True or False) - if 'bool' in str(type(results)): - st += '%s\n' % str(results) - - elif 'dict' in str(type(results)): - for result in results: - if 'list' in str(type(results[result])): - st += '%s\n' % str(result) - for w in results[result]: - st += '\t- %s\n' % w - st += '\n' - - elif 'list' in str(type(results)): - for result in results: - if 'str' in str(type(result)): - st += '%s\n' % result - else: - for r in sorted(result, key=result.get, reverse=True): - if 'list' in str(type(result[r])): - st += '%s:\n' % r - for w in result[r]: - st += '\t- %s\n' % w - else: - st += '%s: %s\n' % (r, str(result[r])) - st += '\n' - elif 'str' in str(type(output['All'])): - st += output['All'] - - if to_print: - self.log(st) - - def linux_output(self, level='', msg=''): - if level == 'ok': - self.success(msg) - elif level == 'error': - self.error(msg) - elif level == 'info': - self.log('[!] {msg}'.format(msg=msg)) - elif level == 'debug': - self.log('[?] {msg}'.format(msg=msg)) + st = '\n################ {category} ################\n'.format(category=output['category']) + if output.get('error'): + st += output.get('error') else: - self.log(msg) + for desc, result in output.get('results'): + if result: + st += '\n# %s\n' % desc + st += '%s\n' % result + + self.log(st)