news TrustedSec

Loading DLLs Reflections

The blog explains reflective DLL loading, a malware technique that executes a DLL directly from a process’s memory without writing it to disk. Unlike Windows’ `LoadLibrary`, reflective loading reduces exposure to file-based antivirus scanning and makes incident response and reverse engineering more difficult. The technique begins by obtaining the DLL bytes, either by embedding them in a program or downloading them from a remote server. Downloading provides flexibility and allows attackers to remove or replace the payload, although embedding makes extraction from a static binary easier. The loader allocates memory based on the DLL’s `SizeOfImage` and preferred `ImageBase`, copies the PE headers and sections into the allocated region, applies relocation fixes if the DLL is loaded at a different address, and resolves imported libraries and functions. It then locates and calls the DLL’s entry point, commonly `DllMain`. Reflective loading can also be adapted for remote-process injection, although the article focuses on loading into the current process. Attackers benefit because the payload may not appear in the process’s loaded-module list. Instead, it can resemble an ordinary memory allocation, though simplistic implementations may expose suspicious read-write-execute (RWX) permissions. The article demonstrates implementations in C and C#. The example downloads a DLL generated to launch Calculator, stores it in memory, reflectively loads it, and executes it. The author notes that remote hosting can hinder forensic recovery because servers may remove the payload quickly, leaving memory capture as the primary investigative option.

Build this article’s timeline

Extract dated events, key actors, and open questions using the same timeline analysis available in Signal.

Log in to build

Timeline generation is available to signed-in community members.

Five Ws 🤖 3 AI prefills · 2 still unanswered
Who Who are the key actors in this story?
What
The blog explains reflective DLL loading, a malware technique that executes a DLL directly from a process’s memory without writing it to disk.
🤖 AI prefill
When
April 25, 2024
🤖 AI prefill
Where Where did this occur?
Why
Centers on reflective DLL loading, in-memory execution, and Windows API LoadLibrary
🤖 AI prefill

Login to answer and earn XP for each gap you fill.

Reflective DLL Loading reflective loading, DLL, memory, LoadLibrary, in-memory execution PE Memory Mapping VirtualAlloc, IMAGE_OPTIONAL_HEADER, ImageBase, SizeOfImage, section headers Relocations and Imports relocations, Import Table, Import Address Table, external libraries, function addresses Evasion and Anti-Forensics anti-virus evasion, diskless execution, incident response, remote download, memory dumping C and C# Demonstration C, C#, code sample, DownloadToBuffer, reflective_loader
reflective DLL loading100% in-memory execution96% Windows API LoadLibrary91% DLL injection88% PE image mapping87% VirtualAlloc86% relocation patching84% Import Address Table83% IMAGE_OPTIONAL_HEADER80% RWX memory permissions79%
24
Manipulation Score: Low How much this article uses emotional framing vs. straight reporting
Loaded Language 1225%
Absolutist 1015%
Threat/Panic 2825%
Us vs Them 1815%
Engagement Bait 2020%
Manipulation score look right?

Factual Claims (10)

medium technology
Reflective DLL loading can load a DLL into a process's memory without writing the DLL to disk.
medium technology
The technique is intended to mimic the Windows API's LoadLibrary function.
medium technology
Avoiding disk writes can reduce detection by basic antivirus products that scan files written to disk.
medium technology
Reflective loading can make incident response and identification of the DLL's contents more difficult.
medium technology
A reflective loader can potentially be modified to load a DLL into a remote process.
medium technology
A DLL can be downloaded directly into memory and executed without being stored on disk.
medium technology
Reflective loading may cause the payload to appear as an allocated memory region rather than as a loaded module.
medium technology
The example uses VirtualAlloc to allocate memory and then copies headers and sections into the allocated buffer.
medium technology
Relocations and the Import Address Table must be processed before the reflectively loaded DLL can execute correctly.
medium technology
The demonstrated DLL was generated with msfvenom to execute Windows Calculator.

Comments

Login to view and post comments.

🏠Portal 📰Links ❓Q&A 📅Events 💼Jobs