LoginSignup
0
0

More than 1 year has passed since last update.

メモリフォレンジックCTF「MemLabs」Lab5のWriteUp(Volatility3)

Posted at

はじめに

前回に続きLab5を解いていく,また使用するツールなどの備忘録を残す.

MemLabs

P.Abhiram Kumar氏が公開しているCTFスタイルでメモリフォレンジックを学ぶことができる教材で,Githubにて公開されています。

Writeup

使用したツール

  • unrar
  • gimp
  • feh

問題

We received this memory dump from our client recently. Someone accessed his system when he was not there and he found some rather strange files being accessed. Find those files and they might be useful. I quote his exact statement,
The names were not readable. They were composed of alphabets and numbers but I wasn't able to make out what exactly it was.
Also, he noticed his most loved application that he always used crashed every time he ran it. Was it a virus?
Note-1: This challenge is composed of 3 flags. If you think 2nd flag is the end, it isn't!! :P
Note-2: There was a small mistake when making this challenge. If you find any string which has the string "L4B_3_D0n3!!" in it, please change it to "L4B_5_D0n3!!" and then proceed.
Note-3: You'll get the stage 2 flag only when you have the stage 1 flag.
Note: This challenge is composed of 3 flags.

先日、お客様からこのようなメモリーダンプを受け取りました。
彼がいない時に誰かが彼のシステムにアクセスし、かなり奇妙なファイルがアクセスされているのを見つけたそうです。
そのファイルを見つければ、役に立つかもしれません。彼の言葉をそのまま引用します。
「名前は読めなかった。アルファベットと数字で構成されていましたが、それが何であるかは分かりませんでした。」
また、いつも使っている愛用のアプリケーションが起動するたびにクラッシュしていることにも気がついた。ウイルスだったのだろうか?
注1:このチャレンジは3つのフラグで構成されています。もし、2つ目のフラグで終わると思っているなら、それは違います!:P
注2: この課題を作るときに、小さなミスがありました。L4B_3_D0n3!"という文字列を見つけたら、"L4B_5_D0n3!"に変えてから進めてください。
注3:ステージ2のフラグは、ステージ1のフラグを持っているときのみ取得できます。

初動調査

取り敢えず,メモリダンプ取得時に起動していたプロセス情報を確認.
画像_2023-01-04_010129244.png
ここで気になる点としては,NOTEPAD.EXE(PID:1388,2056,2724),WinRAR.exe(PID:2924),notepad.exe(PID:2744)のプロセスがある.まずは,WinRAR.exe(PID:2924)について調査するため,コマンドライン引数を確認していく.

$ vol3 -f MemoryDump_Lab5.raw windows.cmdline --pid 2924
Volatility 3 Framework 2.4.1
Progress:  100.00		PDB scanning finished                        
PID	Process	Args

2924	WinRAR.exe	"C:\Program Files\WinRAR\WinRAR.exe" "C:\Users\SmartNet\Documents\SW1wb3J0YW50.rar"

実行結果からSW1wb3J0YW50.rarを引数にしていることから関連するファイルであると考えれるため,ダンプして確認してみる.

$ vol3 -f MemoryDump_Lab5.raw windows.filescan | grep -i SW1wb3J0YW50.rar
$ vol3 -f MemoryDump_Lab5.raw windows.dumpfiles --physaddr 0x3eed56f0
$ file SW1wb3J0YW50.rar 
SW1wb3J0YW50.rar: RAR archive data, v5
$ unrar x SW1wb3J0YW50.rar 

UNRAR 5.61 beta 1 freeware      Copyright (c) 1993-2018 Alexander Roshal
Extracting from SW1wb3J0YW50.rar

Enter password (will not be echoed) for Stage2.png: 

パスワードがついていて解凍が出来なかったが,ファイルの中身がStage2.pngであると推測ができる.
ここで,問題文の注3にステージ2のフラグにはステージ1のフラグが必要であることが記載されているため,Flag1を探しに行こうと思う.

Flag1

問題文にて奇妙なファイルにアクセスしているとの記載があるので,アクセス履歴が記録される可能性のあるInternet Explorerの履歴を確認していく.ちなみに,Volatility2にはiehistoryプラグインがあるためコマンド実行で済むが,Volatility3にはプラグインがなさそうなので地道に確認しようと思う.

$ vol3 -f MemoryDump_Lab5.raw windows.filescan | grep -i "index.dat"

画像_2023-01-04_021425147.png
ユーザとして「SmartNet」と「Alissa Simpson」がいるため,履歴が保存されているファイルを2つダンプしてみる.
また,両方とも確認してみる.

$ vol3 -f MemoryDump_Lab5.raw windows.dumpfiles --physaddr 0x3ecee380
$ vol3 -f MemoryDump_Lab5.raw windows.dumpfiles --physaddr 0x3fca2770
SmartNet_History
URL 
Visited: SmartNet@http://www.msn.com/?ocid=iehp
URL 
Visited: SmartNet@http://static-global-s-msn-com.akamaized.net/hp-neu/sc/2b/a5ea21.ico
URL 
Visited: SmartNet@http://go.microsoft.com/fwlink/?LinkId=69157
URL 
Visited: SmartNet@https://support.microsoft.com/internet-explorer
URL 
Visited: SmartNet@https://ieonline.microsoft.com/favicon.ico
URL 
&P{G
Visited: SmartNet@file:///C:/Users/SmartNet/Desktop/St4g3$1.bat.txt
URL 
Visited: SmartNet@http://www.msn.com/en-in/?ocid=iehp
URL 
Visited: SmartNet@https://www.google.com/url?esrc=s&frm=1&q=&rct=j&sa=U&url=https://www.mozilla.org/en-US/firefox/&ved=2ahUKEwjPutGLnZzmAhWGzTgGHR8iCQYQFjAAegQIABAB&usg=AOvVaw2J-e0RAWen1CLuXRm460yz
https://www.google.com/favicon.ico
URL 
Visited: SmartNet@https://www.google.com/chrome
https://www.google.com/chrome/static/images/favicons/favicon.ico
URL 
Visited: SmartNet@http://www.bing.com/search?format=rss&q=Firefox+quantum&FORM=IE8SRC
URL 
Visited: SmartNet@http://www.bing.com/search?q=Firefox+quantum&FORM=IE8SRC
URL 
Visited: SmartNet@http://www.bing.com/favicon.ico
URL 
Visited: SmartNet@http://www.bing.com/search?q=Firefox+quantum&FORM=IE8SRC
ox/browser/favicon.f093404c0135.ico
URL 
Visited: SmartNet@https://www.mozilla.org/en-US/firefox/new
https://www.mozilla.org/media/img/favicons/firefox/browser/favicon.f093404c0135.ico
URL 
Visited: SmartNet@https://www.mozilla.org/en-US/firefox/download/thanks
https://www.mozilla.org/media/img/favicons/firefox/browser/favicon.f093404c0135.ico
URL 
Visited: SmartNet@https://www.google.com/url?esrc=s&frm=1&q=&rct=j&sa=U&url=https://blog.mozilla.org/firefox/quantum-performance-test/&ved=2ahUKEwjPutGLnZzmAhWGzTgGHR8iCQYQFjACegQIBhAB&usg=AOvVaw3XO7APxPDXR-bDT-ByfMkZ
https://www.google.com/favicon.ico
URL 
Visited: SmartNet@https://www.google.com/url?esrc=s&frm=1&q=&rct=j&sa=U&url=https://www.google.com/chrome/&ved=2ahUKEwi3g__rnJzmAhUSwTgGHSEdCKwQFjAAegQIAhAB&usg=AOvVaw0W4n46XRBG6D5uYcO0mSfE
https://www.google.com/favicon.ico
URL 
Visited: SmartNet@https://www.google.com/search?hl=en-IN&source=hp&biw=&bih=&q=Google+Chrome+Download&iflsig=AAP1E1EAAAAAXefThwUYJlS4SDPu4Rm53s1SWhG-ZbO0&gbv=2
https://www.google.com/favicon.ico
URL 
&P-H
Visited: SmartNet@file:///C:/Users/SmartNet/Desktop/St4g3$1.txt
URL 
&PGH
Visited: SmartNet@file:///C:/Users/SmartNet/Desktop/st4G3$$1.txt
URL 
Visited: SmartNet@https://www.mozilla.org/en-US/firefox
https://www.mozilla.org/media/img/favicons/firefox/favicon.4e526382d5a6.ico
URL 
)PiR
Visited: SmartNet@file:///C:/Users/SmartNet/Secrets/Hidden.kdbx
URL 
.PYj
Visited: SmartNet@file:///C:/Users/SmartNet/Documents/SW1wb3J0YW50.rar
URL 
Visited: SmartNet@file:///C:/Users/SmartNet/SW1wb3J0YW50.rar
URL 
Visited: SmartNet@https://notifier.rarlab.com/?language=English&source=RARLAB&landingpage=first&version=580&architecture=64
URL 
Visited: SmartNet@file:///C:/Users/SmartNet/Documents/New%20Text%20Document.txt
URL 
Visited: SmartNet@file:///C:/Users/SmartNet/Documents/SW1wb3J0YW50.rar
URL 
Visited: SmartNet@https://download-installer.cdn.mozilla.net/pub/firefox/releases/71.0/win32/en-US/Firefox%20Installer.exe
URL 
Visited: SmartNet@https://download-installer.cdn.mozilla.net/pub/firefox/releases/71.0/win32/en-US/Firefox%20Setup%2071.0.exe
URL 
Visited: SmartNet@https://download-installer.cdn.mozilla.net/pub/firefox/releases/71.0/win32/en-US/Firefox%20Setup%2071.0.exe
URL 
Visited: SmartNet@https://www.mozilla.org/en-US/firefox/installer-help/?channel=release&installer_lang=en-US
https://www.mozilla.org/media/img/favicons/firefox/browser/favicon.f093404c0135.ico
Alissa Simpson_History
URL 
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/Documents/Important.rar
URL 
&PyP
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/Downloads/SW1wb3J0YW50.rar
URL 
&P{P
Visited: Alissa Simpson@https://notifier.rarlab.com/?language=English&source=RARLAB&landingpage=first&version=580&architecture=64
URL 
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/stAg3_5.txt
URL 
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/Pictures/Password.png
URL 
Visited: Alissa Simpson@file:///C:/Users/SmartNet/Documents/New%20Text%20Document.txt
URL 
Visited: Alissa Simpson@file:///C:/Users/SmartNet/Secrets/Hidden.kdbx
URL 
-PHw
Visited: Alissa Simpson@file:///Z:/MemLabs-Files/Lab-2/Hidden.kdbx
URL 
-PKw
Visited: Alissa Simpson@file:///Z:/MemLabs-Files/Lab-2/Password.png
URL 
.PjD
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/Pictures/ZmxhZ3shIV93M0xMX2QwbjNfU3Q0ZzMtMV8wZl9MNEJfM19EMG4zXyEhfQ.bmp
URL 
Visited: Alissa Simpson@file:///C:/Users/Alissa%20Simpson/Pictures/ZmxhZ3shIV93M0xMX2QwbjNfU3Q0ZzMtMV8wZl9MNEJfNV9EMG4zXyEhfQ.bmp
URL 
| aG
| aG
Visited: Alissa Simpson@file:///C:/Users/SmartNet/SW1wb3J0YW50.rar
URL 
Visited: Alissa Simpson@file:///C:/Windows/AppPatch/ZmxhZ3shIV93M0xMX2QwbjNfU3Q0ZzMtMV8wZl9MNEJfNV9EMG4zXyEhfQ.bmp

問題文の記載から,ZmxhZ3shIV93M0xMX2QwbjNfU3Q0ZzMtMV8wZl9MNEJfNV9EMG4zXyEhfQ.bmpが対象のファイルであると考えられる.
また,ファイル名の構成からBase64でエンコードされていると推測できるためデコードしてみる.Flagを得ることができた.

「名前は読めなかった。アルファベットと数字で構成されていましたが、それが何であるかは分かりませんでした。」

$ echo "ZmxhZ3shIV93M0xMX2QwbjNfU3Q0ZzMtMV8wZl9MNEJfM19EMG4zXyEhfQ" | base64 -d
Flag1
Flag1
flag{!!_w3LL_d0n3_St4g3-1_0f_L4B_3_D0n3_!!}

Flag2

Flag1が手に入ったので初動調査で手に入れたrarファイルの解凍を行うと,Stage2.pngを手に入れることができFlag2が手に入る.
:::note warn
注意
問題文の注釈通り,文字列を変形させて入力します.
:::

$ unrar x SW1wb3J0YW50.rar
UNRAR 5.61 beta 1 freeware      Copyright (c) 1993-2018 Alexander Roshal

Extracting from SW1wb3J0YW50.rar

Enter password (will not be echoed) for Stage2.png: 

Extracting  Stage2.png                                                OK 
All OK
Flag2
Flag2
flag{W1th_th1s_$taGe_2_1s_c0mPL3T3!!} 

Flag3

2つ目の画像には,終了のような記載があるが問題にある通り3つのFlagで構成されているため,最後のFlagを探していく.
ここで初動調査の際に気になったNOTEPAD.EXE(PID:1388,2056,2724)について,調査するためプロセスのダンプをしてみる.
結果としてPID:2724のプロセスのみダンプすることができた.

$ vol3 -f MemoryDump_Lab5.raw windows.pssca --pid 2724 --dump
$ vol3 -f MemoryDump_Lab5.raw windows.pssca --pid 2056 --dump
PID	PPID	ImageFileName	Offset(V)	Threads	Handles	SessionId	Wow64	CreateTime	ExitTime	File output

2056	1580	NOTEPAD.EXE	0x3fd02b30	1	226	2	True	2019-12-20 03:48:15.000000 	N/A	Error outputting file
$ vol3 -f MemoryDump_Lab5.raw windows.pssca --pid 1388 --dump
PID	PPID	ImageFileName	Offset(V)	Threads	Handles	SessionId	Wow64	CreateTime	ExitTime	File output

1388	1580	NOTEPAD.EXE	0x3e81ab30	1	39	2	True	2019-12-20 03:48:00.000000 	N/A	Error outputting file
$ file pid.2724.0x1000000.dmp 
pid.2724.0x1000000.dmp: PE32 executable (GUI) Intel 80386, for MS Windows

PE32 executableのようなので,Ghidraを使用して調査してみる.
entry関数内にFlagが隠されていました.
画像_2023-01-04_025303415.png

Flag3
Flag3
bi0s{M3m_l4B5_OVeR_!}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0