디지털 포렌식 - Memory Forensic

1. Memory Forensic

1.1 Volatility

  • 메모리 포렌식을 위해 필요한 툴
  • 주요 플러그인
    플러그인설명
    windows.info운영체제 정보 (프로필을 알아내는 데에 사용)
    windows.pslist windows.psscan windows.pstree프로세스 정보
    windows.dumpfiles --pid windows.dumpfiles ‑‑virtaddr windows.dumpfiles --physaddr프로세스의 실행 파일 덤프 가상 주소 기반으로 메모리에서 파일 덤프 물리 주소 기반으로 메모리에서 파일 덤프
    windows.memmap프로세스가 사용하던 메모리 덤프
    windows.handles프로세스가 열고 있는 모든 핸들 검색
    windows.dlllist프로세스와 관련된 DLL 목록 출력
    windows.filescan메모리에 남아있는 파일 오브젝트 목록을 출력
    windows.cmdline실행된 커맨드 목록 출력
    windows.netscan windows.netstat네트워크 연결 정보 출력
    windows.registry.hivescan레지스트리 하이브 검색
    windows.registry.printkey레지스트리 하이브 키 출력
  • 메모리 덤프 분석 raw 파일을 대상으로 최초 실행시 config.json 저장
    python vol.py --save-config config.json -f [메모리파일] windows.info

    이후 -c 이용해 설정 파일을 불러오기를 통해 간편하게 사용

    python vol.py -c config.json -f [메모리파일] [플러그인]
    windows.pslist 실행 예시
    windows.pslist 실행 예시
    • PID / PPID : 프로세스 ID 및 부모의 프로세스 ID
    • ImageFileName: 프로세스 이름
    • CreateTime: 프로세스가 생성된 시간
    windows.psscan 실행 예시
    windows.psscan 실행 예시

    windows.pslist 와 windows.psscan 모두 프로세스 목록을 출력하는 플러그인이지만 내부 동작 원리가 다름. pslist가 더 빠르지만 악성코드에 의해 조작될 수 있음.

    → psslist와 psscan 모두 실행한 후 실행 목록을 비교

1.2 프로세스 분석 방법

  1. 수상한 프로세스 이름 찾기
    • 수상한 이름의 프로세스는 악성코드일 가능성이 높음
    • windows에서 일반적으로 동작하는 프로세스는 하단의 표를 참고
      프로세스 이름설명
      explorer.exe파일 탐색기
      cmd.exe명령 프롬프트
      smss.exe세션 관리자 서브 시스템
      csrss.exe클라이언트/서버 런타임 서브 시스템
      wininit.exe윈도우 초기화 프로세스
      winlogon.exe윈도우 로그인 관리자
      services.exe윈도우 서비스 관리자
      lsass.exe로컬 보안 인증 서브 시스템
      svchost.exe윈도우 서비스를 관할하기 위한 프로세스
      conhost.exe윈도우 콘솔 호스트
      dwm.exe데스크톱 창 관리자
  2. 부모 프로세스가 정상적이지 않은 프로세스 찾기
    악성코드들은 때때로 정상 프로세스와 동일한 이름으로 생성되기도 합니다. 분석가들이 이름을 기반으로 탐지하는 것을 피하기 위함입니다. 그러나 이 경우에는 부모 프로세스가 정상적이지 않은 경우가 많습니다.

    예를 들어 svchost.exe의 경우 services.exe를 부모로 가지고, services.exewininit.exe를 부모로 가집니다. 그런데 악성코드의 경우 svchost.exe가 콘솔을 통해 실행되어, conhost.execmd.exe를 부모로 가지기도 합니다.

    이러한 부모-자식 관계를 알기 위해서는 마찬가지로 Windows 프로세스들의 호출 관계를 잘 알고 있어야 합니다. 호출 관계를 확인하기 위해서는 위에서 설명한 wmic, tasklist 명령어를 잘 활용해 현재 시스템에서의 호출 관계와 비교합니다

  3. 실행 경로가 정상적이지 않은 프로세스 찾기
    악성코드가 정상 프로세스와 동일한 이름을 가지더라도, 실행 경로가 달라 쉽게 찾아낼 수도 있습니다. 예를 들어 svchost.exe 프로세스의 경우 C:\Windows\System32\svchost.exe 경로에 있어야 정상이지만, 악성코드는 다른 경로에서 svchost.exe 라는 이름의 프로세스를 호출하기도 합니다.

    참고로 svchost.exe는 실제로 악성코드들이 위장 목적으로 흔히 사용하는 이름입니다.

1.3 실습

Lab 0

  • 메모리 덤프를 수행할 당시 무엇을 하고 있었는지 확인하기 위해 pstree 호출
    (venv) PS C:\Users\newid\Desktop\WorkSpace\volatility3\volatility3> python vol.py -c config.json -f Challenge.raw windows.pstree Volatility 3 Framework 2.26.2 Progress: 100.00 PDB scanning finished PID PPID ImageFileName Offset(V) Threads Handles SessionId Wow64 CreateTime ExitTime Audit Cmd Path 4 0 System 0x83d09c58 85 483 N/A False 2018-10-23 08:29:16.000000 UTC N/A - - - * 260 4 smss.exe 0x8437db18 2 29 N/A False 2018-10-23 08:29:16.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\smss.exe \SystemRoot\System32\smss.exe \SystemRoot\System32\smss.exe 340 332 csrss.exe 0x84d69030 8 347 0 False 2018-10-23 08:29:21.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\csrss.exe %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16 C:\Windows\system32\csrss.exe 380 372 csrss.exe 0x84d8d030 9 188 1 False 2018-10-23 08:29:23.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\csrss.exe %SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,12288,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ServerDll=sxssrv,4 ProfileControl=Off MaxRequestThreads=16 C:\Windows\system32\csrss.exe * 2104 380 conhost.exe 0x851a5cd8 2 52 1 False 2018-10-23 08:30:18.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\conhost.exe \??\C:\Windows\system32\conhost.exe "9597847671419376088700206021-7055470871162148935-704730587-1400429052-1906668177 C:\Windows\system32\conhost.exe ** 716 484 svchost.exe 0x84e54030 9 243 0 False 2018-10-23 08:29:32.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\system32\svchost.exe -k RPCSS C:\Windows\system32\svchost.exe ** 652 484 VBoxService.ex 0x84e41708 12 116 0 False 2018-10-23 08:29:31.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\VBoxService.exe C:\Windows\System32\VBoxService.exe C:\Windows\System32\VBoxService.exe ** 1164 484 sppsvc.exe 0x850d0030 6 154 0 False 2018-10-23 08:29:57.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\sppsvc.exe C:\Windows\system32\sppsvc.exe C:\Windows\system32\sppsvc.exe ** 592 484 svchost.exe 0x84e23030 12 358 0 False 2018-10-23 08:29:30.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\system32\svchost.exe -k DcomLaunch C:\Windows\system32\svchost.exe ** 848 484 svchost.exe 0x84e84898 20 400 0 False 2018-10-23 08:29:33.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\System32\svchost.exe -k LocalSystemNetworkRestricted C:\Windows\System32\svchost.exe *** 1992 848 dwm.exe 0x85109030 5 132 1 False 2018-10-23 08:30:04.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\dwm.exe "C:\Windows\system32\Dwm.exe" C:\Windows\system32\Dwm.exe ** 1488 484 svchost.exe 0x84f828f8 8 170 0 False 2018-10-23 08:29:44.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\system32\svchost.exe -k LocalServiceAndNoImpersonation C:\Windows\system32\svchost.exe ** 2032 484 SearchIndexer. 0x85164030 14 614 0 False 2018-10-23 08:30:14.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\SearchIndexer.exe C:\Windows\system32\SearchIndexer.exe /Embedding C:\Windows\system32\SearchIndexer.exe *** 284 2032 SearchProtocol 0x8515ad20 7 235 0 False 2018-10-23 08:30:16.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\SearchProtocolHost.exe "C:\Windows\system32\SearchProtocolHost.exe" Global\UsGthrFltPipeMssGthrPipe1_ Global\UsGthrCtrlFltPipeMssGthrPipe1 1 -2147483646 "Software\Microsoft\Windows Search" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT; MS Search 4.0 Robot)" "C:\ProgramData\Microsoft\Search\Data\Temp\usgthrsvc" "DownLevelDaemon" C:\Windows\system32\SearchProtocolHost.exe *** 1292 2032 SearchFilterHo 0x8515cd20 5 80 0 False 2018-10-23 08:30:17.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\SearchFilterHost.exe "C:\Windows\system32\SearchFilterHost.exe" 0 520 524 532 65536 528 C:\Windows\system32\SearchFilterHost.exe ** 1364 484 svchost.exe 0x84f4dca0 19 307 0 False 2018-10-23 08:29:43.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\system32\svchost.exe -k LocalServiceNoNetwork C:\Windows\system32\svchost.exe ** 1460 484 svchost.exe 0x84f7d578 11 148 0 False 2018-10-23 08:29:44.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\svchost.exe C:\Windows\System32\svchost.exe -k utcsvc C:\Windows\System32\svchost.exe ** 308 484 taskhost.exe 0x850b2538 8 151 1 False 2018-10-23 08:29:55.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\taskhost.exe "taskhost.exe" C:\Windows\system32\taskhost.exe ** 1336 484 spoolsv.exe 0x84f323f8 16 295 0 False 2018-10-23 08:29:43.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\spoolsv.exe C:\Windows\System32\spoolsv.exe C:\Windows\System32\spoolsv.exe * 492 388 lsass.exe 0x84def3d8 7 480 0 False 2018-10-23 08:29:25.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\lsass.exe C:\Windows\system32\lsass.exe C:\Windows\system32\lsass.exe 424 372 winlogon.exe 0x84dcbd20 6 117 1 False 2018-10-23 08:29:23.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\winlogon.exe winlogon.exe C:\Windows\system32\winlogon.exe 324 1876 explorer.exe 0x85097870 33 827 1 False 2018-10-23 08:30:04.000000 UTC N/A \Device\HarddiskVolume2\Windows\explorer.exe C:\Windows\Explorer.EXE C:\Windows\Explorer.EXE * 1000 324 VBoxTray.exe 0x85135af8 14 159 1 False 2018-10-23 08:30:08.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\VBoxTray.exe "C:\Windows\System32\VBoxTray.exe" C:\Windows\System32\VBoxTray.exe * 2096 324 cmd.exe 0x851a6610 1 22 1 False 2018-10-23 08:30:18.000000 UTC N/A \Device\HarddiskVolume2\Windows\System32\cmd.exe "C:\Windows\system32\cmd.exe" C:\Windows\system32\cmd.exe * 2412 324 DumpIt.exe 0x845a8d20 2 38 1 False 2018-10-23 08:30:48.000000 UTC N/A \Device\HarddiskVolume2\Users\hello\Desktop\DumpIt\DumpIt.exe "C:\Users\hello\Desktop\DumpIt\DumpIt.exe" C:\Users\hello\Desktop\DumpIt\DumpIt.exe
  • PID : 프로세스 아이디, PPID : parent 프로세스 아이디

  • windows.envars → 분석 대상 시스템의 환경 변수 출력
    notion image
  • windows.hashdump → windows 시스템에 저장된, 사용자의 패스워드를 변환한 결과인 NTLM 해시값 추출
    notion image

1.4 흐름 요약

  1. 운영체제 정보를 출력하고, 설정 파일을 저장함
  2. 프로세스 목록 출력 등 volatility 플러그인 활용
  3. 수상한 프로세스 추적