From df51088361ceedbbce7fa055ee0e5ccc8e673ec1 Mon Sep 17 00:00:00 2001 From: mgeeky Date: Thu, 28 Apr 2022 12:11:36 +0200 Subject: [PATCH] Fixed issue in getOutboundControlled.py --- red-teaming/bloodhound/getOutboundControlled.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/red-teaming/bloodhound/getOutboundControlled.py b/red-teaming/bloodhound/getOutboundControlled.py index e98b237..f1619bf 100644 --- a/red-teaming/bloodhound/getOutboundControlled.py +++ b/red-teaming/bloodhound/getOutboundControlled.py @@ -118,7 +118,7 @@ def opts(args): parser.add_argument('-u', '--user', dest = 'user', help = 'Neo4j User', default = 'neo4j') parser.add_argument('-p', '--password', dest = 'pass', help = 'Neo4j Password', default = 'neo4j1') parser.add_argument('-g', '--include-group-delegated', dest = 'include_group_delegated', action='store_true', help = 'To optimize time the script by default only computes number of first-degree outbound controlled objects. Use this option to include in final results also group-delegated numbers (takes considerable time to evaluate!)') - parser.add_argument('-o', '--output', dest = 'output', help = 'Write output to CSV file specified by this path.', default = '') + parser.add_argument('-o', '--output', default = '', dest = 'output', help = 'Write output to CSV file specified by this path.') parser.add_argument('nodesList', help = 'Path to file containing list of node names to check. Lines starting with "#" will be skipped.') @@ -172,6 +172,8 @@ Usage: ./getOutboundControlled.py [options] totalTime = 0.0 runs = 0 + columns = '' + try: with driver.session() as session: @@ -179,12 +181,13 @@ Usage: ./getOutboundControlled.py [options] output = '' if config['include_group_delegated']: - output = columns2 + '\n' + columns = columns2 else: - output = columns1 + '\n' + columns = columns1 - with open(config['output'], 'w') as f: - f.write(output) + if config['output'] != '': + with open(config['output'], 'w') as f: + f.write(columns + '\n') for a in range(0, len(nodes), nodesToCheckPerStep): b = a + min(nodesToCheckPerStep, len(nodes) - a) @@ -214,6 +217,8 @@ Usage: ./getOutboundControlled.py [options] log(f'\n[+] Nodes checked in {programStop - programStart:.3f} seconds.') if config['output'] == '': + print(columns) + for k, v in results.items(): if config['include_group_delegated']: output += f"{v['name']},{v['first-degree']},{v['group-delegated']}\n"