Fixed bug caused by '\0' in username that broke formatting.

This commit is contained in:
Jakob Friedl
2025-09-25 20:22:56 +02:00
parent 14771a4b50
commit 166cadcb56
3 changed files with 3 additions and 7 deletions

View File

@@ -36,7 +36,7 @@ proc getUsername(): string =
# If not domain-joined, only return USERNAME # If not domain-joined, only return USERNAME
discard GetUsernameW(&buffer, &dwSize) discard GetUsernameW(&buffer, &dwSize)
return $buffer[0 ..< int(dwSize)] return $buffer[0 ..< int(dwSize) - 1]
# Current process name # Current process name
proc getProcessExe(): string = proc getProcessExe(): string =

View File

@@ -150,7 +150,7 @@ proc print(item: ConsoleItem) =
igTextUnformatted(item.text.cstring, nil) igTextUnformatted(item.text.cstring, nil)
proc draw*(component: ConsoleComponent, ws: WebSocket) = proc draw*(component: ConsoleComponent, ws: WebSocket) =
igBegin(fmt"[{component.agent.agentId}] {component.agent.username}@{component.agent.hostname}", addr component.showConsole, 0) igBegin(fmt"[{component.agent.agentId}] {component.agent.username}@{component.agent.hostname}".cstring, addr component.showConsole, 0)
defer: igEnd() defer: igEnd()
let io = igGetIO() let io = igGetIO()
@@ -182,7 +182,7 @@ proc draw*(component: ConsoleComponent, ws: WebSocket) =
Session information Session information
]# ]#
let domain = if component.agent.domain.isEmptyOrWhitespace(): "" else: fmt".{component.agent.domain}" 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}" let sessionInfo = fmt"{component.agent.username}@{component.agent.hostname}{domain} | {component.agent.ip} | {$component.agent.pid}/{component.agent.process}".cstring
igTextColored(GRAY, sessionInfo) igTextColored(GRAY, sessionInfo)
igSameLine(0.0f, 0.0f) igSameLine(0.0f, 0.0f)

View File

@@ -26,7 +26,6 @@ proc interact(component: SessionsTableComponent) =
while ImGuiSelectionBasicStorage_GetNextSelectedItem(component.selection, addr it, addr row): while ImGuiSelectionBasicStorage_GetNextSelectedItem(component.selection, addr it, addr row):
let agent = component.agents[cast[int](row)] let agent = component.agents[cast[int](row)]
# Create a new console window # Create a new console window
if not component.consoles[].hasKey(agent.agentId): if not component.consoles[].hasKey(agent.agentId):
component.consoles[][agent.agentId] = Console(agent) component.consoles[][agent.agentId] = Console(agent)
@@ -35,9 +34,6 @@ proc interact(component: SessionsTableComponent) =
else: else:
igSetWindowFocus_Str(fmt"[{agent.agentId}] {agent.username}@{agent.hostname}") igSetWindowFocus_Str(fmt"[{agent.agentId}] {agent.username}@{agent.hostname}")
# TODO: Clear selection properly
ImGuiSelectionBasicStorage_Clear(component.selection)
proc draw*(component: SessionsTableComponent, showComponent: ptr bool) = proc draw*(component: SessionsTableComponent, showComponent: ptr bool) =
igBegin(component.title, showComponent, 0) igBegin(component.title, showComponent, 0)
defer: igEnd() defer: igEnd()