Updated directory structure and added simple 'exit' command to terminate an agent.
This commit is contained in:
@@ -30,7 +30,8 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import osproc, strutils, strformat
|
||||
import ../agent/core/[coff, io]
|
||||
import ../agent/core/coff
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import strutils, strformat
|
||||
import ../agent/core/[clr, io]
|
||||
import ../agent/core/clr
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
|
||||
46
src/modules/exit.nim
Normal file
46
src/modules/exit.nim
Normal file
@@ -0,0 +1,46 @@
|
||||
import ../common/[types, utils]
|
||||
|
||||
# Define function prototype
|
||||
proc executeExit(ctx: AgentCtx, task: Task): TaskResult
|
||||
|
||||
# Module definition
|
||||
let commands* = @[
|
||||
Command(
|
||||
name: protect("exit"),
|
||||
commandType: CMD_EXIT,
|
||||
description: protect("Exit the agent process."),
|
||||
example: protect("exit"),
|
||||
arguments: @[
|
||||
],
|
||||
execute: executeExit
|
||||
)
|
||||
]
|
||||
|
||||
# Implement execution functions
|
||||
when not defined(agent):
|
||||
proc executeExit(ctx: AgentCtx, task: Task): TaskResult = nil
|
||||
|
||||
when defined(agent):
|
||||
|
||||
import winim/lean
|
||||
import strutils, strformat
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
type
|
||||
RtlExitUserThread = proc(exitStatus: NTSTATUS): VOID {.stdcall.}
|
||||
RtlExitUserProcess = proc(exitStatus: NTSTATUS): VOID {.stdcall.}
|
||||
|
||||
proc executeExit(ctx: AgentCtx, task: Task): TaskResult =
|
||||
try:
|
||||
let
|
||||
hNtdll = GetModuleHandleA(protect("ntdll"))
|
||||
pRtlExitUserThread = cast[RtlExitUserThread](GetProcAddress(hNtdll, protect("RtlExitUserThread")))
|
||||
pRtlExitUserProcess = cast[RtlExitUserProcess](GetProcAddress(hNtdll, protect("RtlExitUserProcess")))
|
||||
|
||||
print " [>] Exiting."
|
||||
pRtlExitUserProcess(STATUS_SUCCESS)
|
||||
|
||||
except CatchableError as err:
|
||||
return createTaskResult(task, STATUS_FAILED, RESULT_STRING, string.toBytes(err.msg))
|
||||
@@ -101,7 +101,7 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import os, strutils, strformat, times, algorithm, winim
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/utils
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import os, std/paths, strutils, strformat
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
|
||||
@@ -17,6 +17,16 @@ proc registerModule(module: Module) {.discardable.} =
|
||||
manager.commandsByType[cmd.commandType] = cmd
|
||||
manager.commandsByName[cmd.name] = cmd
|
||||
|
||||
proc registerCommands(commands: seq[Command]) {.discardable.} =
|
||||
for cmd in commands:
|
||||
manager.commandsByType[cmd.commandType] = cmd
|
||||
manager.commandsByName[cmd.name] = cmd
|
||||
|
||||
# Modules/commands
|
||||
|
||||
import exit
|
||||
registerCommands(exit.commands)
|
||||
|
||||
# Import all modules
|
||||
when (MODULES == cast[uint32](MODULE_ALL)):
|
||||
import
|
||||
@@ -68,7 +78,6 @@ when ((MODULES and cast[uint32](MODULE_TOKEN)) == cast[uint32](MODULE_TOKEN)):
|
||||
import token
|
||||
registerModule(token.module)
|
||||
|
||||
|
||||
proc getCommandByType*(cmdType: CommandType): Command =
|
||||
return manager.commandsByType[cmdType]
|
||||
|
||||
@@ -90,6 +99,10 @@ proc getModules*(modules: uint32 = 0): seq[Module] =
|
||||
result.add(m)
|
||||
|
||||
proc getCommands*(modules: uint32 = 0): seq[Command] =
|
||||
# House-keeping
|
||||
result.add(manager.commandsByType[CMD_EXIT])
|
||||
|
||||
# Modules
|
||||
if modules == 0:
|
||||
for m in manager.modules:
|
||||
result.add(m.commands)
|
||||
|
||||
@@ -30,7 +30,7 @@ when defined(agent):
|
||||
import winim/inc/wingdi
|
||||
import strutils, strformat, times, pixie
|
||||
import stb_image/write as stbiw
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/[utils, serialize]
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import osproc, strutils, strformat
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/utils
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import os, strutils, strformat
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/utils
|
||||
|
||||
@@ -69,7 +69,7 @@ when defined(agent):
|
||||
case int(task.argCount):
|
||||
of 0:
|
||||
# Retrieve sleepmask settings
|
||||
let response = fmt"Sleepmask settings: Technique: {$ctx.sleepSettings.sleepTechnique}, Delay: {$ctx.sleepSettings.sleepDelay}ms, Jitter: {$ctx.sleepSettings.jitter}, Stack spoofing: {$ctx.sleepSettings.spoofStack}"
|
||||
let response = fmt"Sleepmask settings: Technique: {$ctx.sleepSettings.sleepTechnique}, Delay: {$ctx.sleepSettings.sleepDelay}ms, Jitter: {$ctx.sleepSettings.jitter}%, Stack spoofing: {$ctx.sleepSettings.spoofStack}"
|
||||
return createTaskResult(task, STATUS_COMPLETED, RESULT_STRING, string.toBytes(response))
|
||||
|
||||
of 1:
|
||||
|
||||
@@ -38,7 +38,7 @@ when defined(agent):
|
||||
|
||||
import winim
|
||||
import os, strutils, sequtils, strformat, tables, algorithm
|
||||
import ../agent/core/io
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/utils
|
||||
|
||||
|
||||
@@ -88,7 +88,8 @@ when not defined(agent):
|
||||
when defined(agent):
|
||||
|
||||
import winim, strutils, strformat
|
||||
import ../agent/core/[token, io]
|
||||
import ../agent/core/token
|
||||
import ../agent/utils/io
|
||||
import ../agent/protocol/result
|
||||
import ../common/utils
|
||||
|
||||
|
||||
Reference in New Issue
Block a user