Cybrary Pro Day is here!

Memory Analysis Part 2

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Time
3 hours 41 minutes
Difficulty
Advanced
CEU/CPE
5
Video Transcription
00:00
Hello, everyone. And welcome to memory analysis, Part two. In this session, we're going to continue learning about the different ways we can perform memory analysis. Using volatility
00:12
during the memory analysis process, you should focus on any suspicious processes that are running on the system.
00:19
In a live incident situation. You may not really know what the process is you're looking for, so you'll have to do a little bit of hunting. Of course, if you've been analyzing a piece of that where you probably know the process, you want to investigate because you've analyzed it previously in your lab,
00:35
volatility offers a few plug ins that allow you to enumerate a process list. The first is P s list. We've seen this in action already, but we also have PS scan and P S X view.
00:48
Now you might be asking yourself. Okay, well, why do we have several options to look for processes? Well, the answer is that PS scan this scans the physical memory for the signature of a process object.
01:00
Using this technique, volatility can detect terminated processes and hidden processes. Now, typically, I skip P s list altogether and use PS can.
01:11
However, in Mawr Advanced Situations Attackers can install a colonel driver to run in the kernel space and modify different memory tax.
01:19
By modifying the memory tags, an attacker can prevent the plug ins from working properly. In a sense, it's just another hiding technique
01:27
to defeat malware. In these types of situations, we can use PSX view
01:33
as you can see in our output. We've used the PSX View Command to enumerate the processes.
01:38
Each process is displayed as a single row, and the plug ins that volatility used are displayed as columns containing a value of true or false. A false value in a column means that the process wasn't found using that plug in
01:52
the process. We're interested in the second one. That's the mall where Iran was detected by all of the modules.
01:59
Once we find a process where interested in weaken, start investigating it, further using the other plug ins that volatility offers.
02:07
Now that we've identified our process that we want to know more about, the next thing that we should do is investigate which objects like registry keys, files, etcetera. The processes accessing thes objects will give us an idea of the Knauer components and their function.
02:27
For example, a piece of malware may access another process, like power shell, to profile the system and then access a network, a p I to exfiltrate information.
02:36
Now, anytime a piece of malware wants to access an object, the malware process first needs to open a handle to that object. For instance, if malware wants to create a file, then malware will open handle to an object and use that handle to performance operations.
02:52
The reasons handles are open is because objects like the CPU and other hardware reside in kernel space
02:59
process is executed in user space. Don't have access to colonel space? Typically. So to use an object the process needs and user space, the processes presented a handle to that object. By running volatility with handles, plug in, you can get a list of all the handle objects the processes are using.
03:19
But to further refine the list, you can use the dash piece, which, with the number of the process I D. You're interested in, you can obtain the process I d using any one of the process in new Marais shin commands we've just reviewed
03:31
while reviewing your list. If you're interested in a specific handle type. You can specify it by passing it as a sub option to the handles. Plug in by using a Dashti, followed by the handle type,
03:46
for instance. Dashti Mutant to look for mu Texas Dashti file to look for files and dash T key to look for registry keys.
03:59
Malicious processes Use deals to implement different malicious functionality. Therefore, another artifact you can analyze and memory are loaded. Libraries
04:08
To list loaded modules, execute a bles or DLL so you can use volatilities. DLL list. Plug in the plug in displays the full path associated with the process as well as any loaded DLL.
04:20
The way the DLL list plug in works is that it gets information about the modules from the process environment block or the pep.
04:29
This is a structure that resides in the process memory.
04:32
The PEB resigns in user space, and the structure contains information about where the process is loaded. It's full path on disk and any loaded execute a bles and ordeals.
04:46
Another plug in that we can use to look for loaded dll is the L. D. R. Modules. Plugging
04:50
this plug in takes information from the PEB in three separate lists and compares it to the information from a data structure residing in kernel space known as the virtual address Descriptors, or VAT.
05:03
Virtual address descriptors are way to track which virtual address in the process. Memory is reserved or free by the memory manager.
05:11
For each process. The memory manager maintains a set of descriptors for a specific memory region.
05:16
If the process memory region contains a map file like a DLL or ah execute herbal, then this descriptor stores information about the loaded files, base address, file path and memory protection.
05:29
So, in essence, the plug in works by comparing the virtual address descriptors to the PEB lists. And then any discrepancies are identified and listed by volatility. As you can see in our screenshot, a DLL is listed with E L. D R modules plug in that was not listed with our DLL list. Blufgan
05:48
in full disclosure, I missed this deal well when I analyzed this piece of malware using traditional techniques,
05:55
but found it when I was performing memory forensics.
06:00
One of the cool features I wanted to show you in our lab is how to dump dll as you saw in our previous screenshot. We had a DLL that wasn't listed when we used the DLL list. Blufgan.
06:12
But when we run the L. D. R modules plug in, we can see that we have a DLL. That's interesting, and we want to know more about it.
06:19
To inspect the DLL, we can use the DLL dumb plug in this dumps the module to the disks so that we can inspect it.
06:28
It's fairly simple, and all we need to do is specify a base address by using the Dash B target.
06:34
The base address is located here in the base column,
06:39
and then we can dump it to a specific location using the Dash Capital D Target. We can just dump it to this directory using period.
06:47
Now we can inspect this just like we would any other file.
06:53
And if we run strings on this, we can see we've got some a novice skated strings. We've got a P ice, and there are some strings that indicate some key logging functionality.
07:08
A malicious process will typically involve the network in some way. This could be to download a second stage, execute herbal exfiltrate data, receive commands from the sea to server or communicate with a back door on the target system.
07:23
By looking at work activity, you can determine in what way the malware is using a connection
07:28
to look at what type of network connections the malware used you can use. The nets can plug in.
07:33
The nets can plug in displays both the network connections and the sockets.
07:38
In our example. Here, you can see that are malicious. Process was utilizing Port 80 an attempt to communicate outside the network
07:47
while you're hunting for malware. The registry can provide a lot of information, especially when you're looking for persistence methods. Many times, malware programs want to add entries in the registry so that they can survive a reboot.
08:01
Now we're also uses the registry to store configuration, data, encryption keys and many other types of information
08:09
to inspect the registry. With volatility, we can use the print key plug in by providing the desired registry path using the Dash Capital K argument.
08:20
As you can see in our example, we printed the run keys, and we've got a few services that will run at startup.
08:26
There's a few other registry keys that store binary information that could be useful when you're performing an investigation.
08:33
The volatility plug ins, such as user assist, shell banks and Shim Cash, parse thes register keys and display information in a readable format.
08:45
The user assist key contains programs that have been executed and the plug ins Shim cash and shell bags give information about file, folder access, network storage devices and other resource is
09:00
all right. So I hope you enjoyed this session on memory Forensics. As you can see, volatility is a pretty powerful tool, and we've Onley really explored several of the many options and features volatility has to offer.
09:16
I definitely encourage you to explore the various plug ins on your own and see what kind of artifacts you can extract from the different malware that you play with.
Up Next