Learning Objectives of Memory Analysis: SEPTEMBER 27, 2020
Learning Objectives of Memory Analysis: SEPTEMBER 27, 2020
20,967 views
Reading Time: 23 minutes
This memory analysis lab will walk you through the entire process, start to finish, for investigating malware in
a system’s memory.
SEMI-REQUIRED KNOWLEDGE
Computer Processes and threads
Computer memory (the RAM) basic knowledge
Basic Linux Command Line Fu
Basic Virtual Machine Operation
COMMON TOOLS
Volatility
Rekall
Redline
Cyber Triage
MUSIC
Robot Music
Metal Forensics
NOTES
Keep solid notes on your thinking around evidence and data that you find
o This is for teammates to understand your thinking
o Understand your own thinking later… or after sleep.
Notes should be accompanied by screenshots that tell a story
o Examples: Highlights, Boxes, Arrows Text. The reader should quickly
understand what they’re looking at
A great note-keeping App that teams can use to coordinate is OneNote.
o Each host gets a tab etc.
A great piece of software to take Screen Shots is Greenshot
PIVOT POINTS
From PCAP: Malicious filenames, IP Addresses, and Malicious Activity times.
To PCAP: Malicious IP Addresses, Processes and file names.
From Disk: Malicious filenames and paths, IP Addresses, and Malicious Activity times.
To Disk: Malicious file names and paths, DLL’s, IP Addresses, Exfiltration filenames
From Timeline: Malicious filenames and paths, IP Addresses, processes, DLL’s.
To Timeline: Malicious filenames and paths, IP Addresses, processes, DLL’s.
ACQUIRING MEMORY
The Memory Image for this walk-through is provided at the link in the beginning of this post. A quick lesson
memory acquisition follows.
You want to acquire memory first. It is what is known as ‘Volatile’. This means it is highly prone to changes.
Investigators want the best possible view into the state of the machine at the time of the incident; or as close to
it as they can. The more activity on the machine between the incident and the time of collection can mean less
fidelity of the samples collected.
In this ‘case’ the incident responder had a thumb drive with incident handling tools prepared on it and inserted
it into the victim machine. FTK Imager Lite was then run on the machine from the thumb drive. FTK Imager is
a free tool from Access Data that makes quick work of forensic collection of the disk images, memory images,
and ‘protected files’. Andrea Fortuna has a great walk-through on the collection of artifacts from a
machine. As company networks begin to spread out physically, the collection techniques are shifting to remote
solutions and lighter ‘triage’ collections. Understanding memory forensics will still be key for digital forensics
for many years to come.
Start with key terrain and systems the attacker interacted with.
VOLATILITY 2
IMAGE INFO
Hopefully, the person who retrieved the image took great notes on the affected system. This is often not the
case. This knowledge will be key in analyzing the image. Memory analysis revolves around essentially finding
answers in the memory to questions the investigator has. As you work you should start to build a hypothesis
based on evidence you find. Do not get married to a hypothesis. Go where the data takes you. Finally, test the
hypothesis in a lab if possible.
To find the answers the framework being used needs to know where to find the data structures that have these
answers. The map to finding these specific structures in the billions of bytes is known as a profile. There are
efforts underway to remove the need for telling the framework which profile to use. For now, we will practice
‘asking’ the image what profile to use. The framework does this by searching the bytes for known signatures of
operating systems in the Kernel Debugger Block (KDGB).
In this scenario, you ask around and sure enough, the incident handler took a screenshot of the System Info
page and provided in on request.
Running subsequent commands is now as easy as hitting the up arrow and changing the latter part of the
command rather than re-typing it. One could also set an alias for the first portions of the command if desired.
Tee all commands into output files. Any extention works but .out is a safe bet
Use the up arrow to simply modify previous run commands rather than retype them all.
CTRL+R will also allow you to search your history for previous commands
NETWORK CONNECTIONS
Understanding which processes have, or recently had, connections to remote systems is key. Most modern
Malware has network functionality. This can quickly help an investigator narrow their search for which
process(es) in memory is (are) malicious.
This will produce A LOT of data on a DC. A good practice here is to do some Linux Fu against the output file
after scrolling through it with the less command. What to look for:
Known bad IP Addresses (If pivoting from other data and findings)
Known Malicious Processes (If pivoting from other data and findings)
Processes that don’t normally connect to the internet
Looking through the output we immediately notice that dns.exe is loud! Very loud. We can reduce the noise by
removing dns.exe from the data. However, we should make a mental note here that dns.exe could in fact be the
malicious process. We will come back to that if we need to. For now, let’s look at connections not related to
dns.exe with: grep -v dns.exe netscan.out|less.
That’s better.
1. Memory offset of where this connection data structure begins in the connection pool.
2. Protocol of the connection.
3. Which local interface the connection is coming from. Useful for Servers with multiple
Interfaces. Was this in the DMZ? The Management LAN?
4. Remote System this connection is connected to.
5. State of the connection at the time of collection.
6. Process ID
7. The Process is allegedly responsible for this connection.
8. Timestamp of when this connection started.
Did you find a process associated with a name that isn’t well known to Captain Google as being a normal
windows process? Was it connected to the internet?
Great job if you found it on your own! If not, do not worry. It takes practice. Note the IP Address, Owner
Name, and PID. Take a screenshot. If you haven’t found it yet, let’s walk through it together.
We find a single process connected over IPv4 at the time of the memory collection. Note: this VM really was
connected to the actual internet and the Lab net at the same time. It’s a bit of luck this was the only connection.
Notice the language. It is not immediately malicious because it is interesting to us. If this was for a report we
may change the language once this information is confirmed and supported with forensics and adequate
screenshots.
This is interesting. There aren’t any detections yet. This company doesn’t do a lot of business in Thailand, and
there aren’t a lot of Content Distribution Nodes out that way either. Checking the Relations tabs might help us
out. We see that around the time of the incident there was reference to happydoghappycat-th.com. Lets pivot
off of that and look into some Threat Streams.
1. It’s currently TLP: White. This means it’s not known as an indicator of compromise.
2. This is interesting. It’s a baby domain. That is often a sign of trouble. How would any user
on this network know anything about this website… especially in Thailand. These facts will
shift over time. In other words, if anyone is looking at this exercise after November 2020
this site will no longer be a ‘Baby Domain’. The IP Address will likely no longer match, and
the site might be completely gone. For this exercise use the information above.
3. The first time of domain observation. A decent indicator of the ‘born on date’.
Note: No detections or warnings about an indicator does not mean its benign (good). It just means it
is not yet known to be bad.
This IP and Domain was briefly an IOC for an APT. Between the time of this writeup and when the
research was done for the lab, it was no longer considered an IOC. It worked out well since there are
many cases where there is lag time between detection and knowledge of an IOC reaching the
Community.
MALFIND
Malfind is a Volatility program that frankly does some magic for the investigator. It examines many aspects of
every process in memory and does a great job of determining which ones smell of evil. As stated from the
Malfind GitHub page:
The malfind command helps find hidden or injected code/DLLs in user mode memory, based on characteristics
such as VAD tag and page permissions.
Malfind is great at its job. It will get Analysts close to the mark. To do this, simply run the plugin and tee the
output as normal.