Telegram: | maintex |
![]() Join Date: Aug 2013
Posts: 567
![]() |
![]()
Process injection is one of those stealthy techniques malware loves to use to stay under the radar. By injecting malicious code into legitimate processes, attackers can hide in plain sight, making detection a real challenge.
In this post, I’ll walk you through an actual malware sample that uses process injection, breaking down how it works. Target:
Process injection*is a technique used by malware to execute code within the address space of another legitimate process. This allows attackers to evade detection by blending malicious activity with trusted system processes. Common injection methods include Remote Thread Injection, Process Hollowing, APC Injection, and DLL Injection, each leveraging system APIs to manipulate memory and execution flow. By injecting code into a legitimate process, malware can bypass security mechanisms, hide from forensic tools, and maintain persistence. Security analysts detect these techniques by monitoring suspicious API calls, analyzing memory regions, and inspecting process behaviors. Identifying process injection early is crucial for preventing privilege escalation and stealthy persistence in compromised systems. We’ll go step by step, looking at how the injection happens, what’s going on under the hood, and how we can spot it using the right tools. Let’s get into it! We are going to perform a Basic Static Analysis*of the malware sample to identify process injection and, to do this, we will load our sample into Ghidra*and open Symbol References*to examine function calls and memory manipulations related to the injection technique. ![]() Right away we see these functions: ![]() Let me explain what these functions do and why they are relevant for malware analysis. By understanding how they work, we can get a clearer picture of how Remcos RAT*interacts with the system to perform process injection. CreateToolhelp32Snapshot This function creates a snapshot of all running processes, threads, heaps, and modules on the system. Malware frequently uses it to get a full list of active processes before choosing a target for injection. Once it has the snapshot, it can iterate through the processes using Process32First*and Process32Next. Reference:*Microsoft*Docs*- CreateToolhelp32Snapshot Process32First & Process32Next These functions allow the malware to go through each process in the system. This is typically a reconnaissance step where the malware:
By analyzing these API calls, we can start piecing together how Remcos RAT*interacts with the system, selects its targets, and ultimately executes its injection method. Understanding this behavior is key to detecting and mitigating similar threats. How Remcos Uses These Functions Remcos likely uses these APIs for process enumeration*and possibly privilege escalation. This is a common technique in malware to gather information about the system and prepare for further actions.
The functions CreateToolhelp32Snapshot, Process32First, and Process32Next*are often used in the initial reconnaissance phase*of malware that performs process injection. This setup phase is crucial, as it lays the foundation for the actual injection technique, which we’ll analyze next. Now, let's take a look at the VirtualAllocEx*function. ![]() VirtualAllocEx*is a Windows API function that allows a process to allocate memory in the address space of another process. It is commonly used in legitimate applications for interprocess communication, but it is also frequently abused by malware for Process Injection*techniques. By allocating memory in a remote process, an attacker can write and execute malicious code within a trusted system process, making detection more difficult. Malware often uses VirtualAllocEx*alongside other APIs like WriteProcessMemory*and CreateRemoteThread*to inject and execute payloads. This function provides fine-grained control over memory allocation, allowing the malware to specify the size, protection level, and location of the allocated memory. This makes it a critical component of many injection techniques. Reference:*Microsoft*Docs*- VirtualAllocEx ![]() Here’s the function signature for context:
![]() Now, let's take a look at this code, and I will explain it to you in detail to make it easier to interpret. ![]()
From this code, we can deduce that Remcos RAT is attempting to allocate executable, writable memory in a specific target process. This is a classic step in process injection, especially if followed by a call to WriteProcessMemory*(which we see right after this VirtualAllocEx*call) to copy its malicious payload into the allocated memory. Now, let's take a look at the decompiled code window located to our right in Ghidra. ![]() We now turn our attention to another critical function observed in the decompiled code: NtUnmapViewOfSection. This function is often used to "hollow out"*or remove the legitimate code of a target process. By unmapping the original executable section, Remcos*can replace it with its own malicious payload. This technique enables the malware to run under the appearance of a legitimate process, enhancing its evasion capabilities. The likely workflow involves the following:
Combining these observations, it is evident that Remcos*employs process hollowing*for stealthy execution. The full step-by-step process based on the analyzed APIs is as follows:
Now, if you want to learn all of this in detail and much more, I recommend enrolling in our Reverse Engineering for Malware Analysts*courses. In this course, we cover everything step by step, with real-world examples like the one I just showed you. SmouK out!
__________________
Advertising Policies |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reverse Engineering Malware: Cactus Ransomware, Basic Static Analysis | Cartographer | News | 0 | 12-30-2024 08:31 PM |
Check Authorization Process | Cartographer | Tutorials | 3 | 02-04-2022 08:31 PM |
ATM Malware Private Software | Clark Marshall | Real Carding | 1 | 02-07-2021 03:50 PM |
Need cooperation with ePOS malware provider | kaiten | Unverified Advertising | 1 | 12-03-2018 02:33 PM |
unable to process credit transcation??? | Getrichscamz | Real Carding | 0 | 04-19-2015 11:24 PM |