Process Injection is one of the most fundamental capabilities of malware. It plays a role both in establishing a foothold after initial access and during post-exploitation, but the technique suffers from a fundamental problem: its traditional behavior is predictable and well understood by defensive solutions.
The classic Remote Process Injection flow can be roughly summarized in four stages:
1. Enumerate processes on the compromised machine;
2. Obtain a handle to the target process;
3. Allocate and write shellcode into the target process's memory space;
4. Change the memory region's permissions from RW to RX.
The set of WINAPIs designed for these operations is relatively small, which makes life easier for EDRs. The list of the most sensitive APIs is short:
VirtualAllocEx → NtAllocateVirtualMemory
VirtualProtectEx → NtProtectVirtualMemory
WriteProcessMemory → NtWriteVirtualMemory
Whether through kernel callbacks or userland hooks on ntdll, these calls are easily monitored. There are ways to deal with this problem, including simply not performing process injection, at least not during initial access, and choosing something like DLL Sideloading. But we want a challenge, right? :)
In the screenshot I show something different. It is possible to write into a remote process's memory without invoking sensitive APIs such as NtAllocateVirtualMemory or NtWriteVirtualMemory.
Based on an article written by the amazing researcher @TwoSevenOneT, I developed a shellcode runner that successfully evades Windows Defender (with Cloud-Delivered Protection enabled) by poisoning a target process hStdInput. The technique abuses Windows console applications (such as netsh.exe) by redirecting the child process's hStdInput handle via CreateProcess with STARTF_USESTDHANDLES. The content written to the Named Pipe ends up allocated in the target process's memory by the operating system itself, with no explicit call to VirtualAllocEx or WriteProcessMemory.
To locate the shellcode in remote memory, the payload is preceded by a previously established byte sequence that serves as a marker. The runner scans the target process's memory for this pattern, identifies the region, adjusts permissions, and redirects execution to the shellcode.
None of the most sensitive APIs are used for writing the payload. Three APIs that are also used, among other purposes, in traditional injection are present (VirtualProtectEx, CreateProcessW, and ResumeThread), but outside their traditional context they are far less suspicious.
Currently, this shellcode runner PoC would not successfully evade top-tier EDRs, but the goal was to demonstrate viability, not perfection. A little bit more evasion tomfoolery would be enough.
The link to the article that guided me through this experiment will be down below, make sure to do something useful with your life and read it.
Keep Hacking,
Sp1d3rM_*!^
é hoje. bate papo #02 - bug bounty na Fork 🔐
20h (Brasília) no google meet, link no Discord
e pra aquecer, nesse vídeo tem um bug escondido 🐛 se vc achou comenta ai
hoje vai ser um conteúdo muito bom(espero ensinem hackear o serasa
#cybersecurity#BugBounty#Fork
é hoje. bate papo #02 - bug bounty na Fork 🔐
20h (Brasília) no google meet, link no Discord
e pra aquecer, nesse vídeo tem um bug escondido 🐛 se vc achou comenta ai
hoje vai ser um conteúdo muito bom(espero ensinem hackear o serasa
#cybersecurity#BugBounty#Fork
é hoje. bate papo #02 - bug bounty na Fork 🔐
20h (Brasília) no google meet, link no Discord
e pra aquecer, nesse vídeo tem um bug escondido 🐛 se vc achou comenta ai
hoje vai ser um conteúdo muito bom(espero ensinem hackear o serasa
#cybersecurity#BugBounty#Fork