Refactored textarea from console, eventlog and buildlog into a separate widget to reduce code duplication.

This commit is contained in:
Jakob Friedl
2025-10-13 21:55:29 +02:00
parent 756ee09eeb
commit d9372dc880
10 changed files with 179 additions and 329 deletions

View File

@@ -27,7 +27,7 @@ when (MODULES == cast[uint32](MODULE_ALL)):
bof,
dotnet,
screenshot,
situationalAwareness
systeminfo
registerModule(sleep.module)
registerModule(shell.module)
registerModule(bof.module)
@@ -35,7 +35,7 @@ when (MODULES == cast[uint32](MODULE_ALL)):
registerModule(filesystem.module)
registerModule(filetransfer.module)
registerModule(screenshot.module)
registerModule(situationalAwareness.module)
registerModule(systeminfo.module)
# Import modules individually
when ((MODULES and cast[uint32](MODULE_SLEEP)) == cast[uint32](MODULE_SLEEP)):
@@ -60,8 +60,8 @@ when ((MODULES and cast[uint32](MODULE_SCREENSHOT)) == cast[uint32](MODULE_SCREE
import screenshot
registerModule(screenshot.module)
when ((MODULES and cast[uint32](MODULE_SITUATIONAL_AWARENESS)) == cast[uint32](MODULE_SITUATIONAL_AWARENESS)):
import situationalAwareness
registerModule(situationalAwareness.module)
import systeminfo
registerModule(systeminfo.module)
proc getCommandByType*(cmdType: CommandType): Command =
return manager.commandsByType[cmdType]

View File

@@ -3,11 +3,10 @@ import ../common/[types, utils]
# Declare function prototypes
proc executePs(ctx: AgentCtx, task: Task): TaskResult
proc executeEnv(ctx: AgentCtx, task: Task): TaskResult
proc executeWhoami(ctx: AgentCtx, task: Task): TaskResult
# Module definition
let module* = Module(
name: protect("situational-awareness"),
name: protect("systeminfo"),
description: protect("Retrieve information about the target system and environment."),
moduleType: MODULE_SITUATIONAL_AWARENESS,
commands: @[
@@ -26,14 +25,6 @@ let module* = Module(
example: protect("env"),
arguments: @[],
execute: executeEnv
),
Command(
name: protect("whoami"),
commandType: CMD_WHOAMI,
description: protect("Get user information."),
example: protect("whoami"),
arguments: @[],
execute: executeWhoami
)
]
)
@@ -42,7 +33,6 @@ let module* = Module(
when not defined(agent):
proc executePs(ctx: AgentCtx, task: Task): TaskResult = nil
proc executeEnv(ctx: AgentCtx, task: Task): TaskResult = nil
proc executeWhoami(ctx: AgentCtx, task: Task): TaskResult = nil
when defined(agent):
@@ -144,17 +134,5 @@ when defined(agent):
return createTaskResult(task, STATUS_COMPLETED, RESULT_STRING, string.toBytes(output))
except CatchableError as err:
return createTaskResult(task, STATUS_FAILED, RESULT_STRING, string.toBytes(err.msg))
proc executeWhoami(ctx: AgentCtx, task: Task): TaskResult =
echo protect(" [>] Getting user information.")
try:
let output = protect("Not implemented")
return createTaskResult(task, STATUS_FAILED, RESULT_STRING, string.toBytes(output))
except CatchableError as err:
return createTaskResult(task, STATUS_FAILED, RESULT_STRING, string.toBytes(err.msg))