How to Use Volatility

Kail-KM
|2015. 10. 14. 03:28

개요


 메모리 포렌식에 있어서 볼라틸리티는 많이 유명하며 실제로도 많이 사용을 하고 있다. 이러한 볼라틸리티를 이용하여 메모리 포렌식에 대하여 알아보고 이후에는 이를 통하여 실습을 진행할 수 있도록 연습을 해볼 것이다. Volatility에 관한 글은 한번에 포스팅하기에는 많기에 전체적인 사용방법에 대하여 포스팅을 한 후 어떻게 활용을 하는지에 대하여 추가적인 포스팅을 진행할 것 같다.



Memory Acquisition

 메모리 분석을 하기 전에 해당 메모리를 수집하여야 한다. 이러한 메모리 수집에 있어서는 Win32dd와 같은 툴을 주로 사용하며 필자의 경우 DumpIt나 FTK Imager를 사용하기에 이에 대해서는 별도의 언급을 하지 않겠다. DumpIt의 경우 간단하게 더블 클릭으로 실행하면 해당 메모리가 수집되기에 편리한 장점이 있다.


Getting Started with Volatility™

 볼라틸리티를 사용함에 있어서 헷갈리거나 모르는 부분이 있을 경우에는 이러한 help를 이용하여 필요한 정보를 확인하거나 어떠한 인자가 필요한지 등을 확인하여야 한다. 그리고 Imageinfo는 기본적으로 가장 먼저 수행해야하는 작업이며 이를 통해 해당 이미지의 정보를 확인하여 이후 --profile=<profile>에 사용하여야 한다.

Getting Help

# vol.py –h (show options and supported plugins)

# vol.py plugin –h (show plugin usage)

# vol.py plugin --info (show available OS profiles)


Sample Command Line

# vol.py -f image --profile=profile plugin


Identify System Profile

imageinfo - Display memory image metadata

# vol.py –f mem.img imageinfo



Using Environment Variables

Set name of memory image (takes place of -f )

# export VOLATILITY_LOCATION=file:///images/mem.img


Set profile type (takes place of --profile= )

# export VOLATILITYPROFILE=WinXPSP3x86


Converting Hibernation Files and Crash Dumps

 시스템을 사용하는데 있어서 크래시가 발생하는 경우가 종종 존재한다. 이러한 크래시가 발생하였을 때 덤프 파일을 생성하는데 이러한 덤프파일을 볼라틸리티를 이용해 이미지 파일로 생성할 수가 있다. 

 또한 하이버네이션 파일의 경우 절전 모드 시 최소한의 전력만 사용하기 위해 물리메모리의 내용을 파일로 저장하게 하는 기능이다. 다시 시스템을 동작시키면 재부팅 과정에서 저장된 하이버네이션 파일의 내용을 메모리에 읽어와 절전 모드 이전 상태로 시스템을 복원시켜준다. 이러한 하이버네이션이 기본적으로 활성화 되어있는 노트북의 경우 메모리 상에서 존재했던 많은 내용을 확인할 수가 있다. 해당 경로는 다음과 같다. C:\hiberfil.sys 의 형태로 존재하고 있다.

 여기선 덤프된 이미지가 아니라 현재 사용자의 PC에서의 파일을 대상으로 -f 인자를 지정해야 한다.

Volatility imagecopy

-f Name of source file (crash dump, hibernation file)

-O Output file name

--profile Source OS From imageinfo

# vol.py imagecopy -f hiberfil.sys -O hiber.img --profile=<profile>

# vol.py imagecopy -f Memory.dmp -O memdmp.img --profile=<profile>


Memory Artifact Timelining

 볼라틸리티의 Timeliner 플러그인은 메모리 이지미에서 발견할 수 있는 타임스탬프를 수집한다. 출력물은 아래와 같이 정리된다.

 Process creation time   Thread creation time   Driver compile time   DLL / EXE compile time   Network socket creation time

 Memory resident registry key last write time    Memory resident event log entry creation time

--output-file Optional file to write output

--output=body Mactime bodyfile format (also text | xslx)

--registry Include timestamps from registry hives

-y <file> Perform YARA search using signature file

#volatility -f MEMDUMP timeliner --output-file out.csv --profile=Win7SP1x64



Registry Analysis Volatility™ Plugins

 레지스트리와 관련하여 볼라틸리티의 플러그인은 아래와 같다.

hivelist - Find and list available registry hives

# vol.py hivelist -f filename

hivedump - Print all keys and subkeys in a hive

-o Offset of registry hive to dump (virtual offset)

# vol.py hivedump -f filename –o 0xe1a14b60

printkey - Output a registry key, subkeys, and values

-K “Registry key path”

# vol.py printkey -f filename –K “Software\Microsoft\Windows\CurrentVersion\Run”

userassist - Find and parse userassist key values

# vol.py userassist -f filename

hashdump - Dump user NTLM and Lanman hashes

-y Virtual offset of SYSTEM registry hive (from hivelist)

-s Virtual offset of SAM registry hive (from hivelist)

# vol.py hashdump -f filename –y 0x8781c008 –s 0x87f6b9c8



Identify Rogue Processes

 메모리에서 어떤 프로그램이 실행되었는지 확인을 하기 위해 볼라틸리티의 ps* 명령어들을 사용할 수가 있다. 기본적으로 pslist를 사용하면 어떤 프로세스가 메모리에 올라왔는지 그리고 메모리에 있었다가 종료된 프로세스의 경우 해당 종료 시간 또한 알 수가 있다.

 그 외에 psscan을 통해 종료된(비활성) 프로세스들과 루트킷에 의해 숨겨지거나 연결이 끊어진 프로세들을 찾을 수 있다. 또한 pstree를 통하여 프로세스 간의 부모 자식 관계를 알 수가 있으며 이를 통하여 분석자가 편하게 확인을 할 수가 있다.

pslist - High level view of running processes

# vol.py pslist        //여기서 -P 옵션을 주면 물리적 오프셋의 주소가 나타내어 진다.

psscan - Scan memory for EPROCESS blocks

# vol.py psscan

pstree - Display parent-process relationships

# vol.py pstree

pstotal - Graphical view of parent-process relationships

--output=dot Produces vector process DOT graph

# vol.py pstotal -output=dot



Look for Evidence of Code Injection

malfind명령어는 VAD 태그와 페이지 권한들 같은 문자들을 기반으로 사용자 모드(user mode) 메모리에 숨겨져 있거나 삽입(injected) 되어 있는 코드/DLLs 를 찾아내는데 도움을 준다.

malfind - Find injected code and dump sections

-p Show information only for specific PIDs

-o Provide physical offset of single process to scan

--dump-dir Directory to save memory sections

# vol.py malfind --dump-dir ./output_dir


ldrmodules - Detect unlinked DLLs

-p Show information only for specific PIDs

-v Verbose: show full paths from three DLL lists

# vol.py ldrmodules –p 868 -v


Check for Signs of a Rootkit

psxview - Find hidden processes using cross-view

# vol.py psxview



modscan - Scan memory for loaded, unloaded, and unlinked drivers

# vol.py modscan

apihooks - Find API/DLL function hooks

-p Operate only on specific PIDs

-Q Only scan critical processes and DLLS

# vol.py apihooks

ssdt - Hooks in System Service Descriptor Table

# vol.py ssdt | egrep –v ‘(ntoskrnl|win32k)’

driverirp - Identify I/O Request Packet (IRP) hooks

-r Analyze drivers matching REGEX name pattern

# vol.py driverirp –r tcpip

idt - Display Interrupt Descriptor Table

# vol.py idt


Analyze Process DLLs and Handles

 dlllist와 handles의 경우 어떠한 dll과 핸들이 사용되었는지 확인 할 수가 있으며, filescan의 경우 pool 태그 스캐닝을 사용하여 물리적 메모리에서 FILE_OBJECT들을 찾아내려면 filescan 명령어를 사용해야 한다. 이것은 루트킷이 디스크에서 파일을 숨겼을지라도 열려있는 파일들을 찾아낼 것이고 루트킷이 활성 시스템에서 열린 핸들을 숨기도록 몇몇 API 함수들을 연결시켜도 찾아낼 것이다.

dlllist - List of loaded dlls by process

-p Show information only for specific process identifiers (PIDs)

# vol.py dlllist –p 4,868

getsids - Print process security identifiers

-p Show information only for specific PIDs

# vol.py getsids –p 868

handles - List of open handles for each process

-p Show information only for specific PIDs

-t Display only handles of a certain type {Process, Thread, Key, Event, File, Mutant, Token, Port}

# vol.py handles –p 868 –t Process,Mutant

filescan - Scan memory for FILE_OBJECT handles

# vol.py filescan


svcscan - Scan for Windows Service information

-v Show service DLL

# vol.py svcscan


Review Network Artifacts

네트워크와 관련된 명령어들의 경우 netscan을 제외하고는 XP 환경에서 밖에 실행이 되지 않아서 구체적으로 확인을 하지 못하였다.

connections - [XP] List of open TCP connections

# vol.py connections

connscan - [XP] ID TCP connections, including closed

# vol.py connscan

sockets - [XP] Print listening sockets (any protocol)

# vol.py sockets

sockscan - [XP] ID sockets, including closed/unlinked

# vol.py sockscan

netscan - [Win7] Scan for connections and sockets

# vol.py netscan



Dump Suspicious Processes and Drivers

 의심되는 프로세스나 드라이버가 있을 경우에 아래의 명령어들을 통하여 덤프를 뜰 수가 있다. 하지만 덤프를 함에 있어서 메모리에서 페이징되는 등의 경우는 덤프에 실패 할 수가 있다. 

dlldump - Extract DLLs from specific processes

-p Dump DLLs only for specific PIDs

-b Dump DLLs from process at base offset

-r Dump DLLs matching REGEX name

--dump-dir Directory to save extracted files

# vol.py dlldump --dump-dir=./output –r metsrv

moddump - Extract kernel drivers

-b Dump driver using base address (from modscan)

-r Dump drivers matching REGEX name

--dump-dir Directory to save extracted files

# vol.py moddump --dump-dir=./output –r gaopdx

procdump - Dump process to executable sample

-p Dump only specific PIDs

-o Specify process by physical memory offset

-n Use REGEX to specify process

--dump-dir Directory to save extracted files

# vol.py procdump --dump-dir=./output –p 868

memdump - Dump every memory section into a single file

-p Dump memory sections from these PIDs

-n Use REGEX to specify process

--dump-dir Directory to save extracted files

# vol.py memdump –dump-dir=./output –p 868

dumpfiles - Dump File_Objects from file cache

-Q Extract using physical offset

-r Extract using REGEX (-i for case insensitive)

--dump-dir Directory to save extracted files

# vol.py dumpfiles –dump-dir=./output –r \\.exe










Reference


http://www.codeengn.com/archive/Forensic/Volatility%20Plugin%20%EC%9D%84%20%EC%9D%B4%EC%9A%A9%ED%95%9C%20Windows%20Memory%20Dump%20%EB%B6%84%EC%84%9D%20%5BDeok9%5D.pdf

https://digital-forensics.sans.org/media/volatility-memory-forensics-cheat-sheet.pdf

https://digital-forensics.sans.org/media/Poster-2015-Memory-Forensics2.pdf

http://forensic-proof.com/archives/1834   , 하이버네이션 파일 관련 참고

'Forensic > Theory' 카테고리의 다른 글

KDBG Structure  (0) 2015.11.08
[번역] Acquisition and Analysis of Windows Memory  (0) 2015.11.06
$UsnJrnl 분석  (1) 2015.10.09
Torrent Artifacts  (0) 2015.10.06
Retrieving Digital Evidence : Methods, Techniques and Issues  (0) 2015.10.06