0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Posted at

はじめに

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

MemLabs

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

Writeup

使用したツール

  • 7z
  • SQLite3
  • Keepass2

問題

One of the clients of our company, lost the access to his system due to an unknown error. He is supposedly a very popular "environmental" activist. As a part of the investigation, he told us that his go to applications are browsers, his password managers etc. We hope that you can dig into this memory dump and find his important stuff and give it back to us.
Note: This challenge is composed of 3 flags.

当社のクライアントの一人が、原因不明のエラーでシステムにアクセスできなくなった。
彼は非常に人気のある「環境」活動家であると思われます。
調査の一環として、彼はブラウザやパスワード・マネージャーなどのアプリケーションをよく使っていると話してくれました。
私たちは、あなたがこのメモリダンプを掘り下げ、彼の重要なものを見つけて、それを私たちに返してくれることを期待しています。
注:この課題は3つのフラグで構成されています。

初動調査

取り敢えず,メモリダンプ取得時に起動していたプロセス情報を確認.
画像_2023-01-02_235547961.png
問題文にある通り,KeePass.exe(PID:3008)やchrome.exeのプロセスが確認できる.

Flag1

日本語訳にすると分かりづらいが問題文にて"environmental"と強調されており,環境変数に関するヒントだと思われるため,調査してみる.

$ vol3 -f MemoryDump_Lab2.raw windows.envars

画像_2023-01-03_002804641.png
NEW_TMPにいかにもな文字列の値が設定されている.

NEW_TMP	C:\Windows\ZmxhZ3t3M2xjMG0zX1QwXyRUNGczXyFfT2ZfTDRCXzJ9

Base64エンコードっぽいのでデコードしてみるとFlagを得ることができた.

$ echo 'ZmxhZ3t3M2xjMG0zX1QwXyRUNGczXyFfT2ZfTDRCXzJ9' | base64 -d
Flag1
Flag1
flag{w3lc0m3_T0_$T4g3_!_Of_L4B_2}

Flag2

KeePass.exeプロセスの起動時引数を確認してみる.

$ vol3 -f MemoryDump_Lab2.raw windows.cmdline
3008	KeePass.exe	"C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe" "C:\Users\SmartNet\Secrets\Hidden.kdbx"

起動時にHidden.kdbxを読み込んでおり,KeePassのパスワードデータベースと思われる.
そのため,「Hidden.kdbx」をダンプしてみる.

$ vol3 -f MemoryDump_Lab2.raw windows.filescan | grep -i Hidden.kdbx
0x3fb112a0 100.0\Users\SmartNet\Secrets\Hidden.kdbx	216
$ vol3 -f MemoryDump_Lab2.raw windows.dumpfiles --physaddr 0x3fb112a0
$ file Hidden.kdbx 
Hidden.kdbx: Keepass password database 2.x KDBX

ダンプしたデータを調査してみると,KeePassのパスワードデータベースであることが分かった.
KeePass2を使用して開いてみるとパスワードを聞かれて開けない...

$ keepass2 Hidden.kdbx 

画像_2023-01-03_011205908.png
何か情報がないか調査してみると,それっぽいファイルを発見.取り敢えずダンプして確認してみる.

$ vol3 -f MemoryDump_Lab2.raw windows.filescan | grep -i password
0x3e868370 100.0\Program Files (x86)\KeePass Password Safe 2\KeePass.exe.config	216
0x3e873070	\Program Files (x86)\KeePass Password Safe 2\KeePass.exe	216
0x3e8ef2d0	\Program Files (x86)\KeePass Password Safe 2\KeePass.exe	216
0x3e8f0360	\Program Files (x86)\KeePass Password Safe 2\KeePass.XmlSerializers.dll	216
0x3eaf7880	\Program Files (x86)\KeePass Password Safe 2\KeePass.XmlSerializers.dll	216
0x3fb0abc0	\Program Files (x86)\KeePass Password Safe 2\KeePassLibC64.dll	216
0x3fce1c70	\Users\Alissa Simpson\Pictures\Password.png	216
0x3fd62f20	\Program Files (x86)\KeePass Password Safe 2\KeePass.config.xml	216
0x3fecf820	\Program Files (x86)\KeePass Password Safe 2\unins000.exe	216
$ vol3 -f MemoryDump_Lab2.raw windows.dumpfiles --physaddr 0x3fce1c70
$ feh Password.png 

Password.png
画像を見ると右下にパスワードが小さく書かれている.P4SSw0rd_123
パスワードが手に入ったので,再挑戦してみる.
画像_2023-01-03_012607947.png
入れました.「Recycle Bin」を確認するとUser Name「Flag」が存在しているので,Passwordを確認するとFlagが手に入りました.
image.png

Flag2
Flag2
flag{w0w_th1s_1s_Th3_SeC0nD_ST4g3_!!}

Flag3

次にブラウザをよく利用しているということから,履歴を確認するためにChromeのHistoryファイルをダンプしてみる.

$ vol3 -f MemoryDump_Lab2.raw windows.filescan | grep -i history
0x3ec63a70 100.0\Users\Alissa Simpson\AppData\Local\Microsoft\Windows\History\History.IE5\index.dat	216
0x3fa0fb60	\Users\Alissa Simpson\AppData\Local\Microsoft\Windows\History\History.IE5\index.dat	216
0x3fa27920	\Users\Alissa Simpson\AppData\Local\Microsoft\Windows\History\desktop.ini	216
0x3fa3e430	\Users\SmartNet\AppData\Local\Google\Chrome\User Data\Default\History-journal	216
0x3fa6e660	\Users\Alissa Simpson\AppData\Local\Microsoft\Windows\History\History.IE5\MSHist012019121420191215\index.dat	216
0x3fb249a0	\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\Windows\History\History.IE5\index.dat	216
0x3fb28380	\Windows\ServiceProfiles\NetworkService\AppData\Local\Microsoft\Windows\History\History.IE5\index.dat	216
0x3fcfb1d0	\Users\SmartNet\AppData\Local\Google\Chrome\User Data\Default\History	216
0x3fd4a670	\Users\SmartNet\AppData\Local\Google\Chrome\User Data\Default\History-journal	216
0x3fd967e0	\ProgramData\Microsoft\Windows Defender\Scans\History\CacheManager\MpSfc.bin	216
0x3fdae3b0	\Users\Alissa Simpson\AppData\Local\Microsoft\Windows\History\History.IE5\MSHist012019121420191215\index.dat	216
$ vol3 -f MemoryDump_Lab2.raw windows.dumpfiles --physaddr 0x3fcfb1d0
$ file History 
History: SQLite 3.x database, last written using SQLite version 3030001

ダンプしたファイルを調査してみるとSQLite 3.xデータベースであることが分かるので,開いてみてテーブルを確認してみる.

$ sqlite3 History
sqlite> .tables
downloads                meta                     urls                   
downloads_slices         segment_usage            visit_source           
downloads_url_chains     segments                 visits                 
keyword_search_terms     typed_url_sync_metadata

Chromeブラウザの閲覧履歴を確認してみると「32」でMEGAを閲覧していることが分かる.
取り敢えず,接続してみるとImportant.zipといったファイルが置かれている.

sqlite> select * from urls;
1|https://chrome.google.com/webstore?hl=en|Chrome Web Store - Extensions|1|0|13220788565724461|0
2|https://chrome.google.com/webstore/category/extensions?hl=en|Chrome Web Store - Extensions|1|0|13220789573844597|0
3|https://www.google.com/|Google|2|1|13220789572147284|0
4|http://bing.com/|Bing|1|0|13220788578118193|0
5|https://bing.com/|Bing|1|1|13220788578118193|0
6|https://www.bing.com/?toWww=1&redig=2BBD701F84AA44D2A71D870534D085AE|Bing|1|0|13220789580366479|0
7|https://www.facebook.com/|Facebook – log in or sign up|3|1|13220789595814086|0
8|http://volatilevirus.home.blog/|Abhiram's Blog – Dying Is The Day Worth Living For!!|1|0|13220789251877522|0
9|https://volatilevirus.home.blog/|Abhiram's Blog – Dying Is The Day Worth Living For!!|1|1|13220789251877522|0
10|http://r3xnation.wordpress.com/|R3xNation – Free Flowing passions|1|0|13220789357212089|0
11|https://r3xnation.wordpress.com/|R3xNation – Free Flowing passions|1|1|13220789357212089|0
12|http://ashutosh1206.github.io/|Home | Ashutosh|1|0|13220789373876790|0
13|https://ashutosh1206.github.io/|Home | Ashutosh|1|1|13220789373876790|0
14|https://www.onlinesbi.com/|State Bank of India|1|1|13220789377802253|0
15|https://www.india.com/|Latest India News, Breaking News, Entertainment News | India.com News|1|1|13220789408206258|0
16|https://ashutosh1206.github.io/writeups/|Writeups | Ashutosh|1|0|13220791652324863|0
17|https://volatilevirus.home.blog/blog-posts/|Blog Posts – Abhiram's Blog|1|0|13220791655236223|0
18|http://bbc.com/|BBC - Homepage|1|0|13220789455836868|0
19|https://bbc.com/|BBC - Homepage|1|1|13220789455836868|0
20|https://www.bbc.com/|BBC - Homepage|1|0|13220789455836868|0
21|https://www.bbc.com/sport/football/50780855|Jurgen Klopp signs new Liverpool deal until 2024 - BBC Sport|1|0|13220789495842850|0
22|https://www.facebook.com/common/referer_frame.php||1|0|13220789592169571|1
23|http://yahoo.in/|Yahoo India | News, Finance, Cricket, Lifestyle and Entertainment|1|1|13220789605210345|0
24|http://in.yahoo.com/|Yahoo India | News, Finance, Cricket, Lifestyle and Entertainment|1|0|13220789605210345|0
25|https://in.yahoo.com/|Yahoo India | News, Finance, Cricket, Lifestyle and Entertainment|2|0|13220789612266003|0
26|https://www.youtube.com/|YouTube|1|1|13220791499173510|0
27|https://r3xnation.wordpress.com/about/|About – R3xNation|1|0|13220791651296539|0
28|http://blog.bi0s.in/|bi0s|1|0|13220790112269568|0
29|https://blog.bi0s.in/|bi0s|1|1|13220792292073607|0
30|http://ndtv.com/|NDTV: Latest News, India News, Breaking News, Business, Bollywood, Cricket, Videos & Photos|1|0|13220792289449115|0
31|https://www.ndtv.com/|NDTV: Latest News, India News, Breaking News, Business, Bollywood, Cricket, Videos & Photos|1|1|13220792289449115|0
32|https://mega.nz/#F!TrgSQQTS!H0ZrUzF0B-ZKNM3y9E76lg|MEGA|2|0|13220792499602970|0
33|http://bi0s.in/|Amrita Bios|1|0|13220793431596681|0
34|https://bi0s.in/|Amrita Bios|1|1|13220793431596681|0

画像_2023-01-03_015830539.png
ダウンロードしたファイルを解凍してみると,パスワードがかかっており開けない...

$ 7z x Important.zip 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz (A0655),ASM,AES-NI)

Scanning the drive for archives:
1 file, 57457 bytes (57 KiB)

Extracting archive: Important.zip
--
Path = Important.zip
Type = zip
Physical Size = 57457
Comment = Password is SHA1(stage-3-FLAG) from Lab-1. Password is in lowercase.

Enter password (will not be echoed):

しかし,コメントにPassword is SHA1(stage-3-FLAG) from Lab-1. Password is in lowercase.と記載があり,Lab1ステージ3のFlagのSha1ハッシュを求め小文字にしてみる.
その後,再挑戦すると解凍できImportant.pngが手に入る.
確認するとFlagが記載されていた.

$ echo -n 'Lab1ステージ3のFlag'|sha1sum
6045dd90029719a039fd2d2ebcca718439dd100a
$ feh Important.png 
Flag3flag{oK_So_Now_St4g3_3_is_DoNE!!}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?