From 6d696d72c9267d20228f51111ee27982678e5ee4 Mon Sep 17 00:00:00 2001 From: "Mariusz B. / mgeeky" Date: Mon, 29 Mar 2021 14:04:20 +0200 Subject: [PATCH] C3-Client: some fixes --- red-teaming/C3-Client/c3-client.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/red-teaming/C3-Client/c3-client.py b/red-teaming/C3-Client/c3-client.py index 0b8c788..0036709 100644 --- a/red-teaming/C3-Client/c3-client.py +++ b/red-teaming/C3-Client/c3-client.py @@ -462,6 +462,8 @@ def collectRelays(args, nonFatal = False): gateway = getRequest(f'/api/gateway/{_gateway["agentId"]}') + if 'relays' not in gateway.keys() or len(gateway['relays']) == 0: continue + for relay in gateway['relays']: if len(relay_id) > 0: if relay["agentId"].lower() != relay_id.lower() and relay["name"].lower() != relay_id.lower(): @@ -511,14 +513,17 @@ def getCommandIdMapping(gateway, command): return capability['commandIds'][command.lower()] def onPing(args): - if args.keep_pinging > 0: - while True: - print(f'[.] Sending a ping every {args.keep_pinging} seconds.') + try: + if args.keep_pinging > 0: + while True: + print(f'[.] Sending a ping every {args.keep_pinging} seconds.') + _onPing(args) + time.sleep(args.keep_pinging) + else: + print('[.] Pinging only once...') _onPing(args) - time.sleep(args.keep_pinging) - else: - print('[.] Pinging only once...') - _onPing(args) + except KeyboardInterrupt as e: + print('[.] User stopped Pinging process.') def _onPing(args): relays = collectRelays(args) @@ -871,11 +876,10 @@ def collectChannels(args, channelName): if name.lower() != channelName.lower(): continue - Logger.dbg(f'Adding channel {c["iid"]} in Relay {relay["name"]}.') + Logger.dbg(f'Adding channel {channel["iid"]} in Gateway {gateway["name"]}.') channels.append({ - 'url' : f'/api/gateway/{gateway["agentId"]}/relay/{relay["agentId"]}/channel/{channel["iid"]}/command', + 'url' : f'/api/gateway/{gateway["agentId"]}/channel/{channel["iid"]}/command', 'gateway' : gateway, - 'relay' : relay, 'channelId' : channel['iid'], })