Added remote address and modules to agent structure. Help command now only shows commands for which the agent has been configured.
This commit is contained in:
@@ -129,7 +129,7 @@ proc addItem*(component: ConsoleComponent, itemType: LogType, data: string, time
|
||||
Handling console commands
|
||||
]#
|
||||
proc displayHelp(component: ConsoleComponent) =
|
||||
for module in getModules():
|
||||
for module in getModules(component.agent.modules):
|
||||
for cmd in module.commands:
|
||||
component.addItem(LOG_OUTPUT, fmt" * {cmd.name:<15}{cmd.description}")
|
||||
|
||||
@@ -252,7 +252,7 @@ proc draw*(component: ConsoleComponent, connection: WsConnection) =
|
||||
Session information
|
||||
]#
|
||||
let domain = if component.agent.domain.isEmptyOrWhitespace(): "" else: fmt".{component.agent.domain}"
|
||||
let sessionInfo = fmt"{component.agent.username}@{component.agent.hostname}{domain} | {component.agent.ip} | {$component.agent.pid}/{component.agent.process}".cstring
|
||||
let sessionInfo = fmt"{component.agent.username}@{component.agent.hostname}{domain} | {component.agent.ipInternal} | {$component.agent.pid}/{component.agent.process}".cstring
|
||||
igTextColored(GRAY, sessionInfo)
|
||||
igSameLine(0.0f, 0.0f)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ proc AgentModal*(): AgentModalComponent =
|
||||
for cmd in module.commands:
|
||||
result &= " - " & cmd.name & "\n"
|
||||
proc compareModules(x, y: Module): int =
|
||||
return cmp(x.name, y.name)
|
||||
return cmp(x.moduleType, y.moduleType)
|
||||
|
||||
result.moduleSelection = DualListSelection(modules, moduleName, compareModules, moduleDesc)
|
||||
|
||||
|
||||
@@ -59,12 +59,13 @@ proc draw*(component: SessionsTableComponent, showComponent: ptr bool) =
|
||||
ImGui_TableFlags_SizingStretchSame.int32
|
||||
)
|
||||
|
||||
let cols: int32 = 11
|
||||
let cols: int32 = 12
|
||||
if igBeginTable("Sessions", cols, tableFlags, vec2(0.0f, 0.0f), 0.0f):
|
||||
|
||||
igTableSetupColumn("AgentID", ImGuiTableColumnFlags_NoReorder.int32 or ImGuiTableColumnFlags_NoHide.int32, 0.0f, 0)
|
||||
igTableSetupColumn("ListenerID", ImGuiTableColumnFlags_DefaultHide.int32, 0.0f, 0)
|
||||
igTableSetupColumn("Address", ImGuiTableColumnFlags_None.int32, 0.0f, 0)
|
||||
igTableSetupColumn("Internal", ImGuiTableColumnFlags_None.int32, 0.0f, 0)
|
||||
igTableSetupColumn("External", ImGuiTableColumnFlags_DefaultHide.int32, 0.0f, 0)
|
||||
igTableSetupColumn("Username", ImGuiTableColumnFlags_None.int32, 0.0f, 0)
|
||||
igTableSetupColumn("Hostname", ImGuiTableColumnFlags_None.int32, 0.0f, 0)
|
||||
igTableSetupColumn("Domain", ImGuiTableColumnFlags_None.int32, 0.0f, 0)
|
||||
@@ -99,21 +100,23 @@ proc draw*(component: SessionsTableComponent, showComponent: ptr bool) =
|
||||
if igTableSetColumnIndex(1):
|
||||
igText(agent.listenerId)
|
||||
if igTableSetColumnIndex(2):
|
||||
igText(agent.ip)
|
||||
igText(agent.ipInternal)
|
||||
if igTableSetColumnIndex(3):
|
||||
igText(agent.username)
|
||||
igText(agent.ipExternal)
|
||||
if igTableSetColumnIndex(4):
|
||||
igText(agent.hostname)
|
||||
igText(agent.username)
|
||||
if igTableSetColumnIndex(5):
|
||||
igText(if agent.domain.isEmptyOrWhitespace(): "-" else: agent.domain)
|
||||
igText(agent.hostname)
|
||||
if igTableSetColumnIndex(6):
|
||||
igText(agent.os)
|
||||
igText(if agent.domain.isEmptyOrWhitespace(): "-" else: agent.domain)
|
||||
if igTableSetColumnIndex(7):
|
||||
igText(agent.process)
|
||||
igText(agent.os)
|
||||
if igTableSetColumnIndex(8):
|
||||
igText($agent.pid)
|
||||
igText(agent.process)
|
||||
if igTableSetColumnIndex(9):
|
||||
let duration = now() - agent.firstCheckin.fromUnix().utc()
|
||||
igText($agent.pid)
|
||||
if igTableSetColumnIndex(10):
|
||||
let duration = now() - agent.firstCheckin.fromUnix().local()
|
||||
let totalSeconds = duration.inSeconds
|
||||
|
||||
let hours = totalSeconds div 3600
|
||||
@@ -123,8 +126,8 @@ proc draw*(component: SessionsTableComponent, showComponent: ptr bool) =
|
||||
let timeText = dateTime(2000, mJan, 1, hours.int, minutes.int, seconds.int).format("HH:mm:ss")
|
||||
igText(fmt"{timeText} ago")
|
||||
|
||||
if igTableSetColumnIndex(10):
|
||||
let duration = now() - component.agentActivity[agent.agentId].fromUnix().utc()
|
||||
if igTableSetColumnIndex(11):
|
||||
let duration = now() - component.agentActivity[agent.agentId].fromUnix().local()
|
||||
let totalSeconds = duration.inSeconds
|
||||
|
||||
let hours = totalSeconds div 3600
|
||||
|
||||
Reference in New Issue
Block a user