Hackers Employ DLL Side-Loading To Deliver Malicious Python Code


A sophisticated cybersecurity threat has emerged as threat actors have begun leveraging DLL side-loading techniques to distribute malicious Python code.

This attack vector allows hackers to bypass standard security controls by exploiting the way legitimate applications search for and load dynamic-link libraries (DLLs).

The technique enables attackers to execute arbitrary Python code with the privileges of the compromised application, creating a stealthy and persistent access point into targeted systems.

DLL side-loading exploits the Windows DLL search order mechanism, where attackers place malicious DLL files in locations where legitimate applications will load them instead of the intended legitimate libraries.

This method is particularly effective because it leverages trusted applications, enabling malware to evade detection by security solutions that primarily focus on identifying suspicious executables.

Internet Storm Center security researchers detected this campaign last week, noting that the attackers specifically target organizations in the financial and healthcare sectors.

Their analysis revealed that the malware operators are using this technique to deliver Python-based payloads, which offer greater flexibility and cross-platform capabilities compared to traditional compiled malware.

The attack begins with a spear-phishing email containing a seemingly benign attachment. When opened, the attachment executes a legitimate application that attempts to load a specific DLL.

The attackers ensure their malicious DLL is found first in the search path, allowing them to hijack the execution flow.

Once loaded, the malicious DLL injects a Python interpreter into memory and executes embedded Python code, establishing persistence and communication with command-and-control servers.

DLL Side-Loading

The malicious DLL mimics the legitimate library’s exported functions but contains additional code that decrypts and loads Python scripts.

Analysis of the samples reveals the attackers use a custom XOR-based encryption algorithm to obfuscate the embedded Python code.

When the legitimate application calls an exported function from what it believes is the genuine DLL, the malicious version executes both the expected functionality and the concealed payload.

DLL side-loading (Source – Internet Storm Center)

The extracted Python code contains sophisticated modules for system reconnaissance, credential harvesting, and lateral movement.

One particularly concerning aspect is the use of legitimate Python libraries like “requests” and “pywin32” to blend in with normal system operations.

The malware also implements a fileless technique where much of the malicious code exists only in memory, further complicating detection efforts.

Malicious DLL loading (Source – Internet Storm Center)

Security experts recommend organizations implement application whitelisting, keep systems patched, and utilize tools that monitor for suspicious DLL loading patterns.

Additionally, configuring Windows to prefer system directories when searching for DLLs can mitigate many side-loading attacks.

Are you from SOC/DFIR Teams? – Analyse Malware Incidents & get live Access with ANY.RUN -> Start Now for Free.



Source link