remove downloads from extenders

This commit is contained in:
Ralf
2025-07-18 10:03:13 +03:00
parent 29f8f6571c
commit 00a945d5fa
11 changed files with 26 additions and 368 deletions
+1 -8
View File
@@ -57,16 +57,12 @@ type Teamserver interface {
TsDownloadAdd(agentId string, fileId string, fileName string, fileSize int) error
TsDownloadUpdate(fileId string, state int, data []byte) error
TsDownloadClose(fileId string, reason int) error
//
TsDownloadSync(fileId string) (string, []byte, error)
TsDownloadDelete(fileId string) error
TsDownloadGetFilepath(fileId string) (string, error)
TsUploadGetFilepath(fileId string) (string, error)
TsUploadGetFileContent(fileId string) ([]byte, error)
//
TsDownloadTaskCancel(fileId string, clientName string) error
TsDownloadTaskResume(fileId string, clientName string) error
TsDownloadTaskPause(fileId string, clientName string) error
TsScreenshotDelete(screenId string) error
TsScreenshotNote(screenId string, note string) error
@@ -183,9 +179,6 @@ func NewTsConnector(ts Teamserver, tsProfile profile.TsProfile, tsResponse profi
connector.Engine.POST(tsProfile.Endpoint+"/download/sync", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDownloadSync)
connector.Engine.POST(tsProfile.Endpoint+"/download/delete", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDownloadDelete)
connector.Engine.POST(tsProfile.Endpoint+"/download/cancel", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDownloadCancel)
connector.Engine.POST(tsProfile.Endpoint+"/download/resume", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDownloadResume)
connector.Engine.POST(tsProfile.Endpoint+"/download/pause", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDownloadPause)
connector.Engine.POST(tsProfile.Endpoint+"/browser/disks", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiDisks)
connector.Engine.POST(tsProfile.Endpoint+"/browser/files", token.ValidateAccessToken(), default404Middleware(tsResponse), connector.TcGuiFiles)
@@ -60,114 +60,3 @@ func (tc *TsConnector) TcGuiDownloadDelete(ctx *gin.Context) {
ctx.JSON(http.StatusOK, answer)
}
func (tc *TsConnector) TcGuiDownloadCancel(ctx *gin.Context) {
var (
downloadFid DownloadFileId
answer gin.H
username string
ok bool
err error
)
err = ctx.ShouldBindJSON(&downloadFid)
if err != nil {
_ = ctx.Error(errors.New("invalid action"))
return
}
value, exists := ctx.Get("username")
if !exists {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: username not found in context", "ok": false})
return
}
username, ok = value.(string)
if !ok {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: invalid username type in context", "ok": false})
return
}
err = tc.teamserver.TsDownloadTaskCancel(downloadFid.File, username)
if err != nil {
answer = gin.H{"message": err.Error(), "ok": false}
} else {
answer = gin.H{"message": "file cancel", "ok": true}
}
ctx.JSON(http.StatusOK, answer)
}
func (tc *TsConnector) TcGuiDownloadResume(ctx *gin.Context) {
var (
downloadFid DownloadFileId
answer gin.H
username string
ok bool
err error
)
err = ctx.ShouldBindJSON(&downloadFid)
if err != nil {
_ = ctx.Error(errors.New("invalid action"))
return
}
value, exists := ctx.Get("username")
if !exists {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: username not found in context", "ok": false})
return
}
username, ok = value.(string)
if !ok {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: invalid username type in context", "ok": false})
return
}
err = tc.teamserver.TsDownloadTaskResume(downloadFid.File, username)
if err != nil {
answer = gin.H{"message": err.Error(), "ok": false}
} else {
answer = gin.H{"message": "file resume", "ok": true}
}
ctx.JSON(http.StatusOK, answer)
}
func (tc *TsConnector) TcGuiDownloadPause(ctx *gin.Context) {
var (
downloadFid DownloadFileId
answer gin.H
username string
ok bool
err error
)
err = ctx.ShouldBindJSON(&downloadFid)
if err != nil {
_ = ctx.Error(errors.New("invalid action"))
return
}
value, exists := ctx.Get("username")
if !exists {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: username not found in context", "ok": false})
return
}
username, ok = value.(string)
if !ok {
ctx.JSON(http.StatusOK, gin.H{"message": "Server error: invalid username type in context", "ok": false})
return
}
err = tc.teamserver.TsDownloadTaskPause(downloadFid.File, username)
if err != nil {
answer = gin.H{"message": err.Error(), "ok": false}
} else {
answer = gin.H{"message": "file pause", "ok": true}
}
ctx.JSON(http.StatusOK, answer)
}
-26
View File
@@ -85,32 +85,6 @@ func (ex *AdaptixExtender) ExAgentBrowserUpload(agentData adaptix.AgentData, pat
return module.AgentBrowserUpload(path, content, agentData)
}
/// Downloads
func (ex *AdaptixExtender) ExAgentDownloadTaskCancel(agentData adaptix.AgentData, fileId string) (adaptix.TaskData, error) {
module, ok := ex.agentModules[agentData.Name]
if !ok {
return adaptix.TaskData{}, errors.New("module not found")
}
return module.AgentTaskDownloadCancel(fileId, agentData)
}
func (ex *AdaptixExtender) ExAgentDownloadTaskResume(agentData adaptix.AgentData, fileId string) (adaptix.TaskData, error) {
module, ok := ex.agentModules[agentData.Name]
if !ok {
return adaptix.TaskData{}, errors.New("module not found")
}
return module.AgentTaskDownloadResume(fileId, agentData)
}
func (ex *AdaptixExtender) ExAgentDownloadTaskPause(agentData adaptix.AgentData, fileId string) (adaptix.TaskData, error) {
module, ok := ex.agentModules[agentData.Name]
if !ok {
return adaptix.TaskData{}, errors.New("module not found")
}
return module.AgentTaskDownloadPause(fileId, agentData)
}
/// Tunnels
func (ex *AdaptixExtender) ExAgentTunnelCallbacks(agentData adaptix.AgentData, tunnelType int) (func(channelId int, address string, port int) adaptix.TaskData, func(channelId int, address string, port int) adaptix.TaskData, func(channelId int, data []byte) adaptix.TaskData, func(channelId int, data []byte) adaptix.TaskData, func(channelId int) adaptix.TaskData, func(tunnelId int, port int) adaptix.TaskData, error) {
-4
View File
@@ -68,10 +68,6 @@ type ExtAgent interface {
AgentBrowserFiles(path string, agentData adaptix.AgentData) (adaptix.TaskData, error)
AgentBrowserUpload(path string, content []byte, agentData adaptix.AgentData) (adaptix.TaskData, error)
AgentTaskDownloadCancel(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error)
AgentTaskDownloadResume(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error)
AgentTaskDownloadPause(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error)
AgentTunnelCallbacks() (func(int, string, int) adaptix.TaskData, func(int, string, int) adaptix.TaskData, func(int, []byte) adaptix.TaskData, func(int, []byte) adaptix.TaskData, func(int) adaptix.TaskData, func(int, int) adaptix.TaskData, error)
AgentTerminalCallbacks() (func(int, string, int, int) (adaptix.TaskData, error), func(int, []byte) (adaptix.TaskData, error), func(int) (adaptix.TaskData, error), error)
-68
View File
@@ -187,74 +187,6 @@ func (ts *Teamserver) TsDownloadDelete(fileId string) error {
///
func (ts *Teamserver) TsDownloadTaskCancel(fileId string, clientName string) error {
value, ok := ts.downloads.Get(fileId)
if !ok {
return errors.New("File not found: " + fileId)
}
downloadData := value.(adaptix.DownloadData)
value, ok = ts.agents.Get(downloadData.AgentId)
if !ok {
return errors.New("Agent not found: " + downloadData.AgentId)
}
agent := value.(*Agent)
taskData, err := ts.Extender.ExAgentDownloadTaskCancel(agent.Data, fileId)
if err != nil {
return err
}
ts.TsTaskCreate(agent.Data.Id, "", clientName, taskData)
return nil
}
func (ts *Teamserver) TsDownloadTaskResume(fileId string, clientName string) error {
value, ok := ts.downloads.Get(fileId)
if !ok {
return errors.New("File not found: " + fileId)
}
downloadData := value.(adaptix.DownloadData)
value, ok = ts.agents.Get(downloadData.AgentId)
if !ok {
return errors.New("Agent not found: " + downloadData.AgentId)
}
agent := value.(*Agent)
taskData, err := ts.Extender.ExAgentDownloadTaskResume(agent.Data, fileId)
if err != nil {
return err
}
ts.TsTaskCreate(agent.Data.Id, "", clientName, taskData)
return nil
}
func (ts *Teamserver) TsDownloadTaskPause(fileId string, clientName string) error {
value, ok := ts.downloads.Get(fileId)
if !ok {
return errors.New("File not found: " + fileId)
}
downloadData := value.(adaptix.DownloadData)
value, ok = ts.agents.Get(downloadData.AgentId)
if !ok {
return errors.New("Agent not found: " + downloadData.AgentId)
}
agent := value.(*Agent)
taskData, err := ts.Extender.ExAgentDownloadTaskPause(agent.Data, fileId)
if err != nil {
return err
}
ts.TsTaskCreate(agent.Data.Id, "", clientName, taskData)
return nil
}
///
func (ts *Teamserver) TsDownloadGetFilepath(fileId string) (string, error) {
value, ok := ts.downloads.Get(fileId)
if !ok {
+20 -7
View File
@@ -7,8 +7,8 @@ exit_menu.addItem(exit_thread_action)
exit_menu.addItem(exit_process_action)
menu.add_session_agent(exit_menu, ["beacon"])
let file_browser_action = menu.create_action("File Browser", function(value) { value.forEach(v => ax.open_browser_files(v)) });
let process_browser_action = menu.create_action("Process Browser", function(value) { value.forEach(v => ax.open_browser_process(v)) });
let file_browser_action = menu.create_action("File Browser", function(value) { value.forEach(v => ax.open_browser_files(v)) });
let process_browser_action = menu.create_action("Process Browser", function(value) { value.forEach(v => ax.open_browser_process(v)) });
menu.add_session_browser(file_browser_action, ["beacon"])
menu.add_session_browser(process_browser_action, ["beacon"])
@@ -16,6 +16,7 @@ let tunnel_access_action = menu.create_action("Create Tunnel", function(value) {
menu.add_session_access(tunnel_access_action, ["beacon"])
let execute_action = menu.create_action("Execute", function(files_list) {
file = files_list[0];
if(file.type != "file"){ return; }
@@ -44,13 +45,13 @@ let execute_action = menu.create_action("Execute", function(files_list) {
if( output_check.isChecked()) { command += "-o "; }
command += text_bin.text() + " " + text_args.text();
ax.execute_command(file.agent, command);
ax.execute_command(file.agent_id, command);
}
});
let download_action = menu.create_action("Download", function(files_list) {
files_list.forEach((file) => {
if(file.type == "file") {
ax.execute_command(file.agent, "download " + file.path + file.name);
ax.execute_command(file.agent_id, "download " + file.path + file.name);
}
});
});
@@ -59,6 +60,18 @@ menu.add_filebrowser(download_action, ["beacon"])
let download_stop_action = menu.create_action("Pause", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent_id, "exfil stop " + file.file_id) ) });
menu.add_download_running(download_stop_action, ["beacon"])
let download_start_action = menu.create_action("Resume", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent_id, "exfil start " + file.file_id) ) });
menu.add_download_stopped(download_start_action, ["beacon"])
let download_cancel_action = menu.create_action("Cancel", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent_id, "exfil cancel " + file.file_id) ) });
menu.add_download_running(download_cancel_action, ["beacon"])
menu.add_download_stopped(download_cancel_action, ["beacon"])
function RegisterCommands(listenerType)
{
let cmd_cat = ax.create_command("cat", "Read first 2048 bytes of the specified file", "cat C:\\file.exe", "Task: read file");
@@ -83,11 +96,11 @@ function RegisterCommands(listenerType)
cmd_execute.addSubCommands([_cmd_execute_bof])
let _cmd_exfil_cancel = ax.create_command("cancel", "Cancels a download", "exfil cancel 1a2b3c4d");
_cmd_exfil_cancel.addArgFile("file_id", true);
_cmd_exfil_cancel.addArgString("file_id", true);
let _cmd_exfil_start = ax.create_command("start", "Resumes a download that's has been stoped", "exfil start 1a2b3c4d");
_cmd_exfil_start.addArgFile("file_id", true);
_cmd_exfil_start.addArgString("file_id", true);
let _cmd_exfil_stop = ax.create_command("stop", "Stops a download that's in-progress", "exfil stop 1a2b3c4d");
_cmd_exfil_stop.addArgFile("file_id", true);
_cmd_exfil_stop.addArgString("file_id", true);
let cmd_exfil = ax.create_command("exfil", "Manage current downloads");
cmd_exfil.addSubCommands([_cmd_exfil_cancel, _cmd_exfil_start, _cmd_exfil_stop])
-32
View File
@@ -1940,38 +1940,6 @@ func BrowserUpload(ts Teamserver, path string, content []byte, agentData adaptix
return PackArray(array)
}
/// DOWNLOADS
func TaskDownloadCancel(fid string) ([]byte, error) {
fileId, err := strconv.ParseInt(fid, 16, 64)
if err != nil {
return nil, err
}
array := []interface{}{COMMAND_EXFIL, DOWNLOAD_STATE_CANCELED, int(fileId)}
return PackArray(array)
}
func TaskDownloadResume(fid string) ([]byte, error) {
fileId, err := strconv.ParseInt(fid, 16, 64)
if err != nil {
return nil, err
}
array := []interface{}{COMMAND_EXFIL, DOWNLOAD_STATE_RUNNING, int(fileId)}
return PackArray(array)
}
func TaskDownloadPause(fid string) ([]byte, error) {
fileId, err := strconv.ParseInt(fid, 16, 64)
if err != nil {
return nil, err
}
array := []interface{}{COMMAND_EXFIL, DOWNLOAD_STATE_STOPPED, int(fileId)}
return PackArray(array)
}
///
func BrowserJobKill(jobId string) ([]byte, error) {
-47
View File
@@ -262,53 +262,6 @@ func (m *ModuleExtender) AgentBrowserUpload(path string, content []byte, agentDa
///
func (m *ModuleExtender) AgentTaskDownloadCancel(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadCancel(fileId)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
func (m *ModuleExtender) AgentTaskDownloadResume(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadResume(fileId)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
func (m *ModuleExtender) AgentTaskDownloadPause(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadPause(fileId)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
///
func (m *ModuleExtender) AgentBrowserJobKill(jobId string) (adaptix.TaskData, error) {
packData, err := BrowserJobKill(jobId)
if err != nil {
+5 -2
View File
@@ -5,7 +5,7 @@ menu.add_session_agent(exit_action, ["gopher"])
let file_browser_action = menu.create_action("File Browser", function(agents_id) { agents_id.forEach(id => ax.open_browser_files(id)) });
let process_browser_action = menu.create_action("Process Browser", function(agents_id) { agents_id.forEach(id => ax.open_browser_process(id)) });
let terminal_browser_action = menu.create_action("Remote Terminal", function(agents_id) { agents_id.forEach(id => ax.open_browser_terminal(id)) });
let terminal_browser_action = menu.create_action("Remote Terminal", function(agents_id) { agents_id.forEach(id => ax.open_remote_terminal(id)) });
menu.add_session_browser(file_browser_action, ["gopher"])
menu.add_session_browser(process_browser_action, ["gopher"])
menu.add_session_browser(terminal_browser_action, ["gopher"])
@@ -13,9 +13,12 @@ menu.add_session_browser(terminal_browser_action, ["gopher"])
let tunnel_access_action = menu.create_action("Create Tunnel", function(agents_id) { ax.open_access_tunnel(agents_id[0], true, true, false, false) });
menu.add_session_access(tunnel_access_action, ["gopher"]);
let download_action = menu.create_action("Download", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent, "download " + file.path + file.name) ) });
let download_action = menu.create_action("Download", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent_id, "download " + file.path + file.name) ) });
menu.add_filebrowser(download_action, ["gopher"])
let cancel_action = menu.create_action("Cancel", function(files_list) { files_list.forEach( file => ax.execute_command(file.agent_id, "job kill " + file.file_id) ) });
menu.add_download_running(cancel_action, ["gopher"])
function RegisterCommands(listenerType)
{
let cmd_cat_win = ax.create_command("cat", "Read a file", "cat C:\\file.exe", "Task: read file");
-16
View File
@@ -1360,22 +1360,6 @@ func BrowserUpload(ts Teamserver, path string, content []byte, agentData adaptix
return msgpack.Marshal(cmd)
}
/// DOWNLOADS
func TaskDownloadCancel(fileId string, agentData adaptix.AgentData) ([]byte, error) {
packerData, _ := msgpack.Marshal(ParamsJobKill{Id: fileId})
cmd := Command{Code: COMMAND_JOB_KILL, Data: packerData}
return msgpack.Marshal(cmd)
}
func TaskDownloadResume(fileId string, agentData adaptix.AgentData) ([]byte, error) {
return nil, errors.New("Function Download Resume not supported")
}
func TaskDownloadPause(fileId string, agentData adaptix.AgentData) ([]byte, error) {
return nil, errors.New("Function Download Pause not supported")
}
///
func BrowserJobKill(jobId string) ([]byte, error) {
-47
View File
@@ -257,53 +257,6 @@ func (m *ModuleExtender) AgentBrowserUpload(path string, content []byte, agentDa
///
func (m *ModuleExtender) AgentTaskDownloadCancel(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadCancel(fileId, agentData)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
func (m *ModuleExtender) AgentTaskDownloadResume(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadResume(fileId, agentData)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
func (m *ModuleExtender) AgentTaskDownloadPause(fileId string, agentData adaptix.AgentData) (adaptix.TaskData, error) {
packData, err := TaskDownloadPause(fileId, agentData)
if err != nil {
return adaptix.TaskData{}, err
}
taskData := adaptix.TaskData{
Type: TYPE_BROWSER,
Data: packData,
Sync: false,
}
return taskData, nil
}
///
func (m *ModuleExtender) AgentBrowserJobKill(jobId string) (adaptix.TaskData, error) {
packData, err := BrowserJobKill(jobId)
if err != nil {