Back to Articles

RemoteRecon: Building Covert C2 Channels with WMI and the Windows Registry

[ View on GitHub ]

RemoteRecon: Building Covert C2 Channels with WMI and the Windows Registry

Hook

The most effective command-and-control infrastructure is the one your target already trusts—and on Windows networks, few things are more trusted than WMI traffic between domain-joined machines.

Context

Traditional post-exploitation frameworks face a fundamental problem: the moment you establish a network-based C2 channel, you've created a detectable pattern. Security operations teams have become exceptionally skilled at identifying beaconing behavior, unusual DNS queries, and encrypted traffic to suspicious external IPs. Even sophisticated domain fronting and malleable C2 profiles leave traces that modern EDR solutions can fingerprint.

RemoteRecon emerged from the red team community's need for tactical compartmentalization. The concept is straightforward: your primary implant shouldn't be the same tool you use for sensitive intelligence collection. If you burn a keylogger or screenshot tool on a high-value target, you don't want that detection to compromise your main access. RemoteRecon solves this by creating a disposable, lightweight collection framework that operates entirely within Windows' native management infrastructure. By using WMI as the command channel and the registry as a data store, it blends into the noise of legitimate administrative activity, making it considerably harder to distinguish malicious commands from routine system management.

Technical Insight

Operator Infrastructure

Target Machine

WMI Command Objects

Poll for Commands

Execute Task

Results

Query Results

Initial Deployment

PowerShell Controller

Target WMI Namespace

C# Agent

Local System

Windows Registry Store

DotNetToJScript

System architecture — auto-generated

RemoteRecon's architecture is built around three core components that work in concert: a PowerShell-based controller (the operator's interface), a C# agent (the target-side collector), and Windows infrastructure (WMI and Registry) as the communication medium. The brilliance lies in how it repurposes legitimate administrative tools to avoid introducing foreign artifacts.

The deployment process leverages DotNetToJScript, a technique that serializes .NET assemblies into JavaScript that can execute them in memory. This gives operators flexibility in initial access—whether through phishing, web-based delivery, or other vectors—while ensuring the C# agent never touches disk in its original form. Once running, the agent doesn't maintain a persistent network connection. Instead, it polls a specific WMI namespace for command objects.

Here's a simplified representation of how commands flow through the system:

# Controller: Sending a command via WMI
$target = "WIN-TARGET01"
$namespace = "root\default"
$className = "Win32_OSRecoveryConfiguration"

# Encode command as base64 to avoid parsing issues
$command = "screenshot" | ConvertTo-Base64

# Create WMI instance with command data
$wmiParams = @{
    ComputerName = $target
    Namespace = $namespace
    Class = $className
    Property = @{CommandData=$command; TaskId="task_001"}
}
Set-WmiInstance @wmiParams

# Agent polls WMI, executes command, stores result in registry
# Controller retrieves results later
$regKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\TaskCache"
$results = Invoke-Command -ComputerName $target -ScriptBlock {
    Get-ItemProperty -Path $using:regKey -Name "task_001_output"
}

The push-pull architecture is crucial to understanding RemoteRecon's operational security benefits. Unlike interactive shells that require persistent connections, the operator pushes commands through WMI, then disconnects. The agent executes asynchronously and writes results to predefined registry keys—often disguised within legitimate-looking Windows paths like TaskCache or Windows Update keys. The operator retrieves these results at their discretion, potentially hours or days later, making temporal correlation between command and exfiltration extremely difficult.

The registry storage mechanism is particularly clever for persistence. Even if the agent process is killed, previously collected intelligence remains accessible in the registry until the operator retrieves and cleans it up. This creates a "dead drop" pattern familiar to intelligence operations: one party leaves information in a predetermined location, another retrieves it later, with no direct interaction required.

RemoteRecon also implements reflective DLL injection following Stephen Fewer's widely-adopted technique. This allows operators to inject arbitrary position-independent code into running processes without creating new processes or writing DLLs to disk. The framework handles the complexities of memory allocation, permission modification, and execution within the target process space:

// Simplified reflective injection flow
public class ReflectiveInjector
{
    public static bool InjectDLL(byte[] dllBytes, int targetPID)
    {
        // Open target process with required permissions
        IntPtr hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, targetPID);
        
        // Allocate memory in target process
        IntPtr allocatedMem = VirtualAllocEx(
            hProcess, 
            IntPtr.Zero, 
            dllBytes.Length, 
            MEM_COMMIT | MEM_RESERVE, 
            PAGE_EXECUTE_READWRITE
        );
        
        // Write DLL bytes to allocated memory
        WriteProcessMemory(hProcess, allocatedMem, dllBytes, dllBytes.Length, out _);
        
        // Execute the reflective loader stub
        CreateRemoteThread(hProcess, IntPtr.Zero, 0, allocatedMem, IntPtr.Zero, 0, IntPtr.Zero);
        
        return true;
    }
}

This capability transforms RemoteRecon from a simple collection tool into a delivery mechanism for arbitrary post-exploitation payloads. You can inject Mimikatz for credential harvesting, custom keyloggers, or network traffic capture tools—all executed in memory within legitimate processes.

The WMI command channel itself operates over DCOM (Distributed Component Object Model), typically on port 135 with dynamic high ports for callbacks. On domain-joined Windows networks, this traffic is ubiquitous and rarely filtered between internal systems. Domain administrators use WMI constantly for inventory, patch management, and configuration—making it the perfect cover for command traffic. The agent can be configured to poll at irregular intervals with jitter, further obscuring its presence in process and network telemetry.

Gotcha

RemoteRecon's dependence on Windows infrastructure is both its strength and its Achilles' heel. The framework requires local administrator privileges for most operations, particularly WMI remote access and registry modification. On hardened environments with proper least-privilege implementation, you'll find your access insufficient. Modern Windows 10/11 systems with Credential Guard, HVCI, and Attack Surface Reduction rules will block many of the techniques RemoteRecon relies on.

The forensic footprint is more significant than initial appearances suggest. While WMI and registry operations are common, they're also heavily logged on mature environments. Event IDs 4688 (process creation), 5861 (WMI activity), and registry modification events (4657) will all fire when RemoteRecon operates. A competent blue team with proper SIEM correlation will spot unusual WMI command patterns and registry keys appearing in non-standard locations. The registry storage mechanism, while persistent, is also a liability during incident response—collected data sits in a recoverable location that forensic tools will enumerate.

Perhaps most critically, RemoteRecon appears largely unmaintained. The last significant commits date back several years, predating major security enhancements like the Antimalware Scan Interface (AMSI) integration in PowerShell 5.1+ and Windows Defender's behavior-based detection improvements. You'll likely encounter execution policy restrictions, AMSI blocks on the PowerShell components, and signature-based detection on the reflective injection techniques. Using RemoteRecon in 2024+ requires forking the repository and implementing significant updates: AMSI bypasses, obfuscation of known signatures, and adaptation to modern Windows security baselines. This is more reference implementation than production-ready tool.

Verdict

Use if: You're conducting targeted red team engagements where compartmentalization of collection infrastructure is paramount, you have local admin access on target Windows systems, and you're willing to invest time forking and modernizing the codebase for current defensive controls. RemoteRecon excels in scenarios where burning a collection tool shouldn't compromise your primary access—think high-value target surveillance where you deploy a keylogger or screen capture agent separate from your main implant. It's also valuable as an educational resource for understanding WMI-based C2 and registry persistence patterns. Skip if: You need production-ready, maintained tooling; you're targeting modern, hardened Windows environments with comprehensive logging and EDR; you require real-time interactive access rather than asynchronous collection; or you lack the reverse engineering and tool development skills to update the framework for modern defensive controls. For most operators, actively maintained alternatives like Cobalt Strike or Sliver will provide better reliability with less operational risk.

// ADD TO YOUR README
[![Featured on Starlog](https://starlog.is/api/badge/developer-tools/xorrior-remoterecon.svg)](https://starlog.is/api/badge-click/developer-tools/xorrior-remoterecon)