Skip to content

Commit

Permalink
fix a couple of the errors in onedrive listener (#600)
Browse files Browse the repository at this point in the history
* fix a couple of the errors in onedrive listener

* more fixes
  • Loading branch information
vinnybod authored Apr 29, 2023
1 parent 8cb2d93 commit 47efe1a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed issue with install path not being used properly when switching empire location (@Vinnybod)
- Lock nim version in the install script (@Vinnybod)
- Fixes for the onedrive listener that broke with 5.0 (@Vinnybod)

## [5.2.0] - 2023-03-31

Expand Down
8 changes: 1 addition & 7 deletions empire/server/common/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,7 @@ def get_agents_for_listener(self, listener_name):
.all()
)

if agents:
# make sure names all ascii encoded
results = [r[0].encode("ascii", "ignore") for r in agents]
else:
results = []

return results
return [a[0] for a in agents]

def get_autoruns_db(self):
"""
Expand Down
3 changes: 0 additions & 3 deletions empire/server/listeners/dbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,6 @@ def delete_file(dbx, path):

# get any taskings applicable for agents linked to this listener
sessionIDs = self.mainMenu.agents.get_agents_for_listener(listenerName)
for x in range(len(sessionIDs)):
if isinstance(sessionIDs[x], bytes):
sessionIDs[x] = sessionIDs[x].decode("UTF-8")

for sessionID in sessionIDs:
taskingData = self.mainMenu.agents.handle_agent_request(
Expand Down
6 changes: 2 additions & 4 deletions empire/server/listeners/onedrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,6 @@ def upload_stager():
try:
agent_id = item["name"].split(".")[0]

for i in range(len(agent_ids)):
agent_ids[i] = agent_ids[i].decode("UTF-8")

if (
agent_id not in agent_ids
): # If we don't recognize that agent, upload a message to restage
Expand All @@ -868,7 +865,8 @@ def upload_stager():
s.delete("%s/drive/items/%s" % (base_url, item["id"]))
continue

self.mainMenu.agents.update_agent_lastseen_db(agent_id)
with SessionLocal() as db:
self.mainMenu.agents.update_agent_lastseen_db(agent_id, db)

# If the agent is just checking in, the file will only be 1 byte, so no results to fetch
if item["size"] > 1:
Expand Down

0 comments on commit 47efe1a

Please sign in to comment.