#include <sys/socket.h>

あとで書く Twitter:@sys_socket

Defcon DFIR CTF 2018 # Image1 - HRServer WriteUp

はじめに

インターネットを眺めていたら,Magnet Forensicsが開催していたDFIRのCTF「Defcon DFIR CTF 2018」が公開されていたのでやった話(全部は解けていない)

Hacking Exposed Computer Forensics Blog Daily Blog #451 Defcon DFIR CTF 2018 Open to the Public : http://www.hecfblog.com/2018/08/daily-blog-451-defcon-dfir-ctf-2018.html

Defcon DFIR CTF 2018 : https://defcon2018.ctfd.io/challenges

対象イメージファイル

実際に調査するイメージファイルは以下のブログのDropboxのリンクからImage1,Image2,Image3と3つダウンロードできる.

http://www.hecfblog.com/2018/08/daily-blog-451-defcon-dfir-ctf-2018.html

Image1.7zのパスワードは書いてあるので,それを使う.

Image2.7z,Image3.7zのパスワードはCTFの問題を解いていくと分かる.

やっていったら長くなったので,Image2とImage3については今後書く予定です.

Image 1 : HRServer

Image1.7zを展開すると,HRServer_Disk0.e01HRServer_Disk0.txtが出てくる. HRServer_Disk0.txtを見ると,X-waysでこのディスクイメージを取得したっぽいことが分かる.

HRServer_Disk.e01をFTK Imagerで開く.

f:id:socketo:20180826023119p:plain

Windows Serverっぽい.

どうせならSIFT Workstationでやるかという気持ちになったので,E01ファイルをSIFT Workstationでマウントする.

SANS Digital Forensics and Incident Response Blog _ Digital Forensic SIFTing - Mounting Evidence Image Files _ SANS Institute : https://digital-forensics.sans.org/blog/2011/11/28/digital-forensic-sifting-mounting-ewf-or-e01-evidence-image-files

# ewfmount HRServer_Disk0.e01 /mnt/e01/

# mmls /mnt/e01/ewf1

DOS Partition Table
Offset Sector: 0
Units are in 512-byte sectors

      Slot      Start        End          Length       Description
000:  Meta      0000000000   0000000000   0000000001   Primary Table (#0)
001:  -------   0000000000   0001026047   0001026048   Unallocated
002:  000:000   0001026048   0104857599   0103831552   NTFS / exFAT (0x07)
# python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1026048 * 512
525336576

# mount -o ro,loop,show_sys_files,streams_interface=windows,offset=525336576 -t ntfs /mnt/e01/ewf1 /mnt/windows_mount

確認する

f:id:socketo:20180826023220p:plain

OK

HR Server Basic

前情報

HRServer_Disk0.txtの中身する

08/08/2018, 14:32:43
X-Ways Forensics BYOD 19.6 SR-6 x64
Create Disk Image

Computer: DESKTOP-0QT8017
4 processor cores
Windows 10 (64 bit)
Time zone: -7:00 Pacific Daylight Time
User: Administrator
Examiner(s): Professor Frink

Source: Hard disk 1
Sectors 0-104857599

Model: f-switch BF063FCFC580DB48
Serial No.: DIsk-0
Firmware Rev.: 0001
Bus: SCSI/SATA

Total capacity: 53,687,091,200 bytes = 50.0 GB
Bytes per sector: 512
Sector count: 104,857,600

SMART: n/a (Incorrect function.)
Read consistency: no anomalies detected

Partitioning style: MBR
Disk signature: 5C2C870D
Unpartitionable space: 0 Sectors

Partition 1
Sectors 1,026,048 - 104,857,599
Partition table: Sector 0
NTFS

Unused inter-partition space:
Sectors 0 - 1,026,047 (501 MB)
= 501 MB

Destination: C:\Users\Administrator\Desktop\HRServer_Disk0.e01

Hash of source data: BB3E772F1896D23865AC3FE9763691D3 (MD5)

08/08/2018, 20:30:47
Imaging completed: 12.6 GB
Duration: 5:58:03 h. 0.1 GB/min.
Compression: fast, adaptive
Compression ratio: 75%

HRServer基本調査

Regripperでレジストリ周りを調べると以下のことが分かる

  • Windows OSのバージョン : Windows Server 2016 Datacenter
  • Timezoneの確認 : UTC-7
  • ユーザ
    • Administrator[500]
    • Guest[501]
    • DefaultAccount[503]
    • mpowers[1000]
  • グループ
    Group Name    : Administrators [2]
    LastWrite     : Wed Jul 11 17:22:06 2018 Z
    Group Comment : Administrators have complete and unrestricted access to the computer/domain
    Users :
      S-1-5-21-2967420476-1305424719-3994513216-1000     => mpowers
      S-1-5-21-2967420476-1305424719-3994513216-500       => Administrator

HR Server - Acquisition Software(2)

問題文

Which software was used to image the HR Server?

HRServerのイメージを取得したソフトウェアを答えるだけ.

HRServer_Disk0.txtに取得時のログか書かれており,X-Ways Forensics BYODで取得されたことがわかるので,それ.

FLAG:X-Ways

HR Server - Acquisition Software Version(2)

問題文

Which version of the software was used to image the HR Server? [Format: n.n]

X-Waysのバージョンを答える.

FLAG:19.6

HR Server - Entry Name(2)

問題文

What is the file name that represents MFT Entry 168043?

MFTエントリ168043を表すファイル名は何か.

MFTを解析するのにはanalyzeMFT.pyを使う.

analyzeMFT.py : https://github.com/dkovar/analyzeMFT

# analyzeMFT.py -f \$MFT.copy0 -o MFT.csv

出力したMFT.csvからエントリ168043を探す

# cat MFT.csv | grep '"168043"'

f:id:socketo:20180826023558p:plain

FLAG:pip3.7.exe

HR Server - Entry Number(2)

問題文

What is the MFT Entry number of the following file? \xampp\mysql\bin\mysql.exe
[format is an integer]

逆にファイルからMFATのエントリー番号を探す.

ファイルは\xampp\mysql\bin\mysql.exe

# cat MFT.csv | grep '/xampp/mysql/bin/mysql.exe'

f:id:socketo:20180826023703p:plain

FLAG:115322

HR Server - Attribute ID(2)

問題文

What is the MFT Attribute ID of the named $J data attribute for the MFT Entry with a file name of $UsnJrnl?
[format is an integer]

$ Jデータ属性のMFT属性IDをintで答える的は話

Autopsyでイメージを開く f:id:socketo:20180826023754p:plain

[属性アドレス]が128-3なので3

FLAG:3

HR Server - SMB(2)

問題文

At 2018-08-08 18:10:38.554 (UTC) what was the IP address of the the client that attempted to access SMB via an anonymous logon?

2018-08-08 18:10:38.554 (UTC)にSMBでanonymous logonを施行したクライアントのIPアドレスを調べる.

調査用している端末がUTC+9である為,Windowsのイベントビュアーで見ると9時間ズレることになる.

XMLで表示すると,実際の生のUTCで見れるんでそれで確認する

f:id:socketo:20180826023830p:plain

IPアドレス80.81.110.50のクライアントからanonymous logonを施行しているのがある.

FLAG:80.81.110.50

HR Server - Saved(2)

問題文

What was the name of the batch file saved by mpowers?

[answer is fullpath starting with c:*****]

mpowersが保存したバッチファイルの名前は何.

mpowersのuserassistをregripperを使って見る.

その中に.batファイルがあればそれっぽいのでそれ.

# rip.pl -r Users/mpowers/NTUSER.DAT -p userassist | grep bat

f:id:socketo:20180826023909p:plain

  FLAG:c:\Production\update_app.bat

HR Server - Application Q 1(2)

問題文

What is the name of the hr management application that hosts a web server?

ホストしているHR Managementのアプリケーションは何?

/Users/Administrator/Downloadsに以下の実行ファイルがあった

  • orangehrm-4.1.exe
  • orangehrm_mysql.sql
  • xampp-win32-5.6.36-0-VC11-installer.exe

OrangeHRMというオープンソースの人材管理システムがインストールされていたように感じる.

OrangeHRM - Human Resource Management 日本語情報トップページ - OSDN : https://ja.osdn.net/projects/sfnet_orangehrm/

/直下にxamppディレクトリはあるが,xampp/apache/logsにこれといったログは無いので,このOrangeHRMの方のディレクトリを見るべきっぽい.

OrangeHRMのホームディレクトリは/Program Files/OrangeHRM/4.1になっており,それ以下はxamppと同じようなディレクトリ構造になっているっぽい.

そんな感じでOrangeHRMですね.はい.

FLAG:OrangeHRM

HR Server - Application Q 2(2)

問題文

What was the public url for the HR system's portal?

[format: http://*****]

/Program Files/OrangeHRM/4.1/apache/logsaccess.logをザッと見てると,http://127.0.0.1/orangehrm-4.1/symfony/web/*へアクセスしている後にhttp://74.118.139.108/symfony/web/*へのアクセスに変わってる.

ローカルで立てた後にPublicにしたっぽくてhttp://74.118.139.108/symfony/web/index.phpがポータルのトップっぽい.

FLAG:http://74.118.139.108/symfony/web/index.php/

HR Server- Changes Q1(2)

問題文

What is name of the file that had a change recorded with an update sequence number of 368701440?

USNAnalyticsを使ってUSNジャーナルの解析をする. USNAnalytics:https://www.kazamiya.net/usn_analytics

C:\Users\socketo\workspace\DFIR\DefconDFIR2018\HRServer\usn_analysis.exe -o outputdir -u $UsnJrnl$J

出力されたcsvファイル(tsv)からUSN:368701440を探す.

# cat usn_analytics_records-20180806T233530.tsv | grep 368701440

f:id:socketo:20180826025609p:plain

FLAG:Microsoft-Windows-SMBServer%4Security.evtx

HR Server - Changes Q2(2)

問題文

What is the name of the deleted file with a reference number of 12947848928752043?

よくわからん

HR Server - Advanced

HR Server - Logon(4)

問題文

At 2018-07-30 22:31:33 UTC which user was logged in under, what was the logon type (integer), and the logon process name?
[format: {TargetUserName} - {LogonType} - {LogonProcessName} - {IpAddress}]

この時間にログオンしたやつを見つけて上のフォーマットで答える

このフォーマット的にSecurityイベントログのようなので/Windows/System32/winevt/Logs/Security.evtxを見たいので見たが,Eventlogの消去が行われていたようで,その時間のイベントログを見ることが出来ない.(UTC+9上の環境で見ている為,時間はズレている)

f:id:socketo:20180826024121p:plain

Security.evtx以外では,RDP関係のイベントが残るイベントログMicrosoft-Windows-TerminalServices-RemoteConnectionManager%4Admin.evtxを見ると,該当の時間にRDPで接続されているように思える.

f:id:socketo:20180826024159p:plain

一応この時間に接続がされていたようなので,どうにかしてSecurity.evtxを持ってきたい.

今回は幸いに,/System Volume Information下を見るとVolume Shadow Copyのファイルあるので,それを利用する.

Volume Shadow CopyをSIFT Workstationにマウントする

参考動画

# ewfmount /mnt/hgfs/DefconDFIR2018/HRServer/HRServer_Disk0.e01 /mnt/ewf/

# mmls /mnt/ewf/ewf1

DOS Partition Table
Offset Sector: 0
Units are in 512-byte sectors

      Slot      Start        End          Length       Description
000:  Meta      0000000000   0000000000   0000000001   Primary Table (#0)
001:  -------   0000000000   0001026047   0001026048   Unallocated
002:  000:000   0001026048   0104857599   0103831552   NTFS / exFAT (0x07)
# python
Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1026048 * 512
525336576
>>> exit()

# vshadowmount -o 525336576 /mnt/ewf/ewf1 /mnt/vss/

# mountwin /mnt/vss/vss1 /mnt/shadow_mount/

確認する

f:id:socketo:20180826024252p:plain

このVSSでのイベントログを確認すると,Security.evtxはイメージファイルに現存しているSecurity.evtxよりもサイズが大きいので削除されていないっぽい.

実際にSecurity.evtxを抽出し,中身を見ると削除される前の状態のものであることが確認できる. 目的の時間のイベントログを探すと以下のイベントログが見つかる.

f:id:socketo:20180826024320p:plain

この結果をフォーマットに合わせる

FLAG:mpowers - 10 - User32 - 74.118.138.195

HR Server - Task Started(4)

問題文

At 2018-07-27 02:42:43 (UTC), what is the name of the task that was started?

この時間に始まったタスクを調べるとのこと. イベントログMicrosoft-Windows-TaskScheduler%4Operation.evtxを見る

f:id:socketo:20180826024353p:plain

Throw Tacoというタスクがこの時間にスケジューラによって開始しているのでそれ.

FLAG:Throw Taco

HR Server - HR System 1(4)

問題文

Which IP address was accessing the OrangeHRM portal via Chrome 68.0.3440.84?

access.logChrome/68.0.3440.84grepする

f:id:socketo:20180826024427p:plain

FLAG:74.118.139.108

HR Server - Web App(4)

問題文

What version of Apache was being used?

[format: n.n]

Apacheのバージョンを調べる

Program Files/OrangeHRM/4.1/apacheApache関係のファイルがあるので見ると,Apache2.4っぽいので2.4

FLAG:2.4

HR Server - Changes Q3(4)

問題文

What is the integer representation for the reason code given a USN V2 record where the record's reason flags have the following:

USN_REASON_CLOSE | USN_REASON_DATA_EXTEND | USN_REASON_FILE_CREATE

USN RECORD V2においてCLOSEDATA_EXTENDFILE_CREATEのReasonコードを答える問題.

以下のMicrosoftのドキュメントを見ると分かる.

USN_RECORD_V2 _ Microsoft Docs : https://docs.microsoft.com/en-us/windows/desktop/api/winioctl/ns-winioctl-usn_record_v2

Reason Code
USN_REASON_CLOSE 0x80000000
USN_REASON_DATA_EXTEND 0x00000002
USN_REASON_FILE_CREATE 0x00000100

この3つが含まれているコードは0x80000102になる

これをdecimalにすると2147483906になる

FLAG:2147483906

HR Server - Expert

HR Server - Web Traffic Q1(8)

問題文

What was the top communicating IP address with the web server?

Webサーバと一番通信していたIPアドレスを探す. 普通にaccess.logで出現したIPアドレスを出現多い順にする

$ cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head

 780 74.118.138.195
 361 99.191.150.129
 361 73.60.202.108
 361 68.34.44.44
 211 74.118.139.108
 193 24.63.119.107
 175 74.56.59.151
 139 104.9.181.249
 126 47.75.16.178
 125 47.90.92.121

FLAG:74.118.138.195

HR Server - Web Traffic Q2(8)

問題文

How many requests were made to the web server where the requested url contained a wget command within in?

リクエストされたURLにwgetが含まれた回数を数える. 普通にgrepして数える

$ cat access.log| grep wget | wc -l

101

FLAG:101