Fix agent last-seen issue with other listeners, decrease verbosity of error messages

3.0-Beta
mr64bit 2018-03-14 15:47:48 -04:00
parent 14468216b7
commit 4281e98c24
2 changed files with 9 additions and 7 deletions

View File

@ -1362,7 +1362,7 @@ class Agents:
dispatcher.send("[!] Invalid staging request packet from %s at %s : %s" % (sessionID, clientIP, meta), sender='Agents')
def handle_agent_data(self, stagingKey, routingPacket, listenerOptions, clientIP='0.0.0.0', update_lastseen=False):
def handle_agent_data(self, stagingKey, routingPacket, listenerOptions, clientIP='0.0.0.0', update_lastseen=True):
"""
Take the routing packet w/ raw encrypted data from an agent and
process as appropriately.

View File

@ -533,7 +533,7 @@ class Listener:
params = {'@microsoft.graph.conflictBehavior': 'rename', 'folder': {}, 'name': base_folder}
base_object = s.post("%s/drive/items/root/children" % base_url, json=params)
else:
print helpers.color("[*] %s folder already exists" % base_folder)
dispatcher.send("[*] %s folder already exists" % base_folder, sender="listeners/onedrive")
for item in [staging_folder, taskings_folder, results_folder]:
item_object = s.get("%s/drive/root:/%s/%s" % (base_url, base_folder, item))
@ -542,7 +542,7 @@ class Listener:
params = {'@microsoft.graph.conflictBehavior': 'rename', 'folder': {}, 'name': item}
item_object = s.post("%s/drive/items/%s/children" % (base_url, base_object.json()['id']), json=params)
else:
print helpers.color("[*] %s/%s already exists" % (base_folder, item))
dispatcher.send("[*] %s/%s already exists" % (base_folder, item), sender="listeners/onedrive")
def upload_launcher():
ps_launcher = self.mainMenu.stagers.generate_launcher(listener_name, language='powershell', encode=False, userAgent='none', proxy='none', proxyCreds='none')
@ -572,7 +572,7 @@ class Listener:
else:
print helpers.color("[!] Something went wrong uploading stager")
print r.json()
dispatcher.send(r.content, sender="listeners/onedrive")
listener_options = copy.deepcopy(listenerOptions)
@ -659,7 +659,8 @@ class Listener:
s.delete("%s/drive/items/%s" % (base_url, item['id']))
except Exception, e:
print(traceback.format_exc())
print helpers.color("[!] Could not handle agent staging for listener %s, continuing" % listener_name)
dispatcher.send(traceback.format_exc(), sender="listeners/onedrive")
agent_ids = self.mainMenu.agents.get_agents_for_listener(listener_name)
for agent_id in agent_ids: #Upload any tasks for the current agents
@ -682,7 +683,7 @@ class Listener:
try:
agent_id = item['name'].split(".")[0]
if not agent_id in agent_ids: #If we don't recognize that agent, upload a message to restage
dispatcher.send("[*] Invalid agent, deleting %s/%s and restaging" % (results_folder, item['name']), sender="listeners/onedrive")
print helpers.color("[*] Invalid agent, deleting %s/%s and restaging" % (results_folder, item['name']))
s.put("%s/drive/root:/%s/%s/%s.txt:/content" % (base_url, base_folder, taskings_folder, agent_id), data = "RESTAGE")
s.delete("%s/drive/items/%s" % (base_url, item['id']))
continue
@ -705,7 +706,8 @@ class Listener:
dispatcher.send("[!] Error handling agent results for %s, %s" % (item['name'], e), sender="listeners/onedrive")
except Exception, e:
print(traceback.format_exc())
print helpers.color("[!] Something happened in listener %s: %s, continuing" % (listener_name, e))
dispatcher.send(traceback.format_exc(), sender="listeners/onedrive")
s.close()