mdns
parent
8c73b8dd05
commit
670e6a11d9
|
@ -535,7 +535,7 @@ function Get-FilePart {
|
|||
function Start-DownloadJob {
|
||||
param($ScriptString, $type, $Path, $ResultID, $ChunkSize)
|
||||
|
||||
$RandName = -join("ABCDEFGHKLMNPRSTUVWXYZ123456789".ToCharArray()|Get-Random -Count 6)
|
||||
$RandName = Split-Path -Path $Path -Leaf
|
||||
# create our new AppDomain
|
||||
$AppDomain = [AppDomain]::CreateDomain($RandName)
|
||||
|
||||
|
@ -1058,8 +1058,8 @@ function Get-FilePart {
|
|||
|
||||
# return the currently running jobs
|
||||
elseif($type -eq 50) {
|
||||
$RunningJobs = $Script:Jobs.Keys -join "`n"
|
||||
Encode-Packet -data ("Running Jobs:`n$RunningJobs") -type $type -ResultID $ResultID
|
||||
$Downloads = $Script:Jobs.Keys -join "`n"
|
||||
Encode-Packet -data ("Running Jobs:`n$Downloads") -type $type -ResultID $ResultID
|
||||
}
|
||||
|
||||
# stop and remove a specific job if it's running
|
||||
|
@ -1080,6 +1080,27 @@ function Get-FilePart {
|
|||
}
|
||||
}
|
||||
|
||||
#return downloads
|
||||
elseif($type -eq 52) {
|
||||
$RunningDownloads = $Script:Downloads.Keys -join "`n"
|
||||
Encode-Packet -data ("Downloads:`n$RunningDownloads") -type $type -ResultID $ResultID
|
||||
}
|
||||
|
||||
#Cancel a download
|
||||
elseif($type -eq 53) {
|
||||
$JobName = $data
|
||||
$JobResultID = $ResultIDs[$JobName]
|
||||
|
||||
try {
|
||||
$Results = Stop-DownloadJob -JobName $JobName
|
||||
|
||||
Encode-Packet -type 53 -data "Download of $JobName stopped" -ResultID $JobResultID
|
||||
}
|
||||
catch {
|
||||
Encode-Packet -type 0 -data "[!] Error in stopping Download: $JobName" -ResultID $JobResultID
|
||||
}
|
||||
}
|
||||
|
||||
# dynamic code execution, wait for output, don't save output
|
||||
elseif($type -eq 100) {
|
||||
$ResultData = IEX $data
|
||||
|
|
|
@ -1608,6 +1608,19 @@ class Agents:
|
|||
msg = "file download: %s, part: %s" % (path, index)
|
||||
self.save_agent_log(sessionID, msg)
|
||||
|
||||
elif responseName == "TASK_GETDOWNLOADS":
|
||||
if not data or data.strip().strip() == "":
|
||||
data = "[*] No active downloads"
|
||||
|
||||
self.update_agent_results_db(sessionID, data)
|
||||
#update the agent log
|
||||
self.save_agent_log(sessionID, data)
|
||||
|
||||
elif responseName == "TASK_STOPDOWNLOAD":
|
||||
# download kill response
|
||||
self.update_agent_results_db(sessionID, data)
|
||||
#update the agent log
|
||||
self.save_agent_log(sessionID, data)
|
||||
|
||||
elif responseName == "TASK_UPLOAD":
|
||||
pass
|
||||
|
|
|
@ -1529,6 +1529,23 @@ class PowerShellAgentMenu(cmd.Cmd):
|
|||
# update the agent log
|
||||
self.mainMenu.agents.save_agent_log(self.sessionID, "Tasked agent to stop job " + str(jobID))
|
||||
|
||||
def do_downloads(self, line):
|
||||
"Return downloads or kill a download job"
|
||||
|
||||
parts = line.split(' ')
|
||||
|
||||
if len(parts) == 1:
|
||||
if parts[0] == '':
|
||||
self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_GETDOWNLOADS")
|
||||
#update the agent log
|
||||
self.mainMenu.agents.save_agent_log(self.sessionID, "Tasked agent to get downloads")
|
||||
else:
|
||||
print helpers.color("[!] Please use for m 'downloads kill DOWNLOAD_ID'")
|
||||
elif len(parts) == 2:
|
||||
jobID = parts[1].strip()
|
||||
self.mainMenu.agents.add_agent_task_db(self.sessionID, "TASK_STOPDOWNLOAD", jobID)
|
||||
#update the agent log
|
||||
self.mainMenu.agents.save_agent_log(self.sessionID, "Tasked agent to stop download " + str(jobID))
|
||||
|
||||
def do_sleep(self, line):
|
||||
"Task an agent to 'sleep interval [jitter]'"
|
||||
|
|
|
@ -98,6 +98,9 @@ PACKET_NAMES = {
|
|||
"TASK_GETJOBS" : 50,
|
||||
"TASK_STOPJOB" : 51,
|
||||
|
||||
"TASK_GETDOWNLOADS" : 52,
|
||||
"TASK_STOPDOWNLOAD" : 53,
|
||||
|
||||
"TASK_CMD_WAIT" : 100,
|
||||
"TASK_CMD_WAIT_SAVE" : 101,
|
||||
"TASK_CMD_JOB" : 110,
|
||||
|
|
Loading…
Reference in New Issue