Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed update agent listener (updatecomms) issue #382

Merged
merged 2 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions data/agent/agent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1027,27 +1027,27 @@ function Invoke-Empire {
try {
IEX $data

Encode-Packet -type $type -data ($CurrentListenerName) -ResultID $ResultID
Encode-Packet -type $type -data "[+] Switched the current listener to: $CurrentListenerName" -ResultID $ResultID
}
catch {

Encode-Packet -type 0 -data ("Unable to update agent comm methods: $_") -ResultID $ResultID
Encode-Packet -type 0 -data ("[!] Unable to update agent comm methods: $_") -ResultID $ResultID
}
}

elseif($type -eq 131) {
# Update the listener name variable
$script:CurrentListenerName = $data

Encode-Packet -type $type -data ("Updated the CurrentListenerName to: $CurrentListenerName") -ResultID $ResultID
Encode-Packet -type $type -data "[+] Updated the CurrentListenerName to: $CurrentListenerName" -ResultID $ResultID
}

else{
Encode-Packet -type 0 -data "invalid type: $type" -ResultID $ResultID
Encode-Packet -type 0 -data "[!] invalid type: $type" -ResultID $ResultID
}
}
catch [System.Exception] {
Encode-Packet -type $type -data "error running command: $_" -ResultID $ResultID
Encode-Packet -type $type -data "[!] error running command: $_" -ResultID $ResultID
}
}

Expand Down
11 changes: 8 additions & 3 deletions lib/common/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,13 +2134,18 @@ def process_agent_packet(self, sessionID, responseName, taskID, data):

elif responseName == "TASK_SWITCH_LISTENER":
# update the agent listener
self.update_agent_listener_db(sessionID, data)
if isinstance(data, bytes):
data = data.decode('UTF-8')

listener_name = data[38:]

self.update_agent_listener_db(sessionID, listener_name)
self.update_agent_results_db(sessionID, data)
# update the agent log
self.save_agent_log(sessionID, data)
message = "[+] Updated comms for {} to {}".format(sessionID, data)
message = "[+] Updated comms for {} to {}".format(sessionID, listener_name)
signal = json.dumps({
'print': True,
'print': False,
'message': message
})
dispatcher.send(signal, sender="agents/{}".format(sessionID))
Expand Down