■メモリフォレンジック volatility
①インストール
https://zoomadmin.com/HowToInstall/UbuntuPackage/volatility

(1)CTFの問題を使って、フォレンジックをやってみよう
問題は以下
---------
Memory Analysis(Forensics 100)
Memory Analysis
Find the website that the fake svchost is accessing.
You can get the flag if you access the website!!

memoryanalysis.zip
The challenge files are huge, please download it first.
Hint1: http://www.volatilityfoundation.org/
Hint2: Check the hosts file
---------
 メモリダンプそのものは、容量が大きいが以下にある。
 https://github.com/SECCON/SECCON2016_online_CTF/blob/master/Forensic/100_MemoryAnalysis/files/fileurl.txt
 ダウンロ―ドして、記載されたPW「fjliejflsjiejlsiejee33cnc」で開ける

(2)解き方はこちら
http://ecoha0630.hatenablog.com/entry/2016/12/11/200127
https://qiita.com/yuu26/items/c257cc09a4535367c021

①imageinfoオプションで、メモリダンプの情報を見る 
# volatility -f ./forensic_100.raw imageinfo

Suggested Profile(s) : WinXPSP2x86, WinXPSP3x86 (Instantiated with WinXPSP2x86)

→WinXPのものらしい。
★場合によっては、ここで表示されたProfileを指定する。
# volatility -f ./forensic_100.raw --profile=WinXPSP3x86 pstree
※必須という表記もあるが、以下のようになくてもうまくいった。よくわからん。それと、複数のプロファイルが表示されたら、新しい方がいいかも

②pstreeを見てみる
# volatility -f ./forensic_100.raw pstree

...... 0x8229f7e8:IEXPLORE.EXE                       1080    380     19    397 2016-12-06 05:27:21 UTC+0000

IEなどのプロセスが見える。

③接続状況を見る connectionsまたはnetscan
# volatility -f ./forensic_100.raw connections
Volatility Foundation Volatility Framework 2.6
Offset(V)  Local Address             Remote Address            Pid
---------- ------------------------- ------------------------- ---
0x8213bbe8 192.168.88.131:1034       153.127.200.178:80        1080

接続したサーバがわかる。pid1080とあるが、先ほどのpestreeではIEが動いていた。

または、netscanコマンド。このあたりは、OS(WindowsXPなのか7なのかなど)によってコマンドが違うので、OSに合わせたコマンドを打つ

④ヒントとして「Hint2: Check the hosts file」とあったので、hostsファイルが見たい →filescanで hostsでGrepする

# volatility -f ./forensic_100.raw filescan | grep hosts
0x000000000217b748      1      0 R--rw- \Device\HarddiskVolume1\WINDOWS\system32\drivers\etc\hosts
→どうやらhostsファイルがあるようだ。

⑤そのhostsファイルのIDを指定して、ファイルを出力する。-Qでファイルを指定し、名前をわかるようにしたほうがいいので、--name -D と指定する。※このあたりは上記のサイトの通り。

# volatility -f ./forensic_100.raw dumpfiles -Q 0x000000000217b748 --name -D ./

⑥lsで見ると、以下のファイルが作成されている。
file.None.0x819a3008.hosts.dat 

⑦このhostsファイルを開くと、以下とある。
153.127.200.178    crattack.tistory.com root@user-virtual-machine:/home/user#

・・・その他のオプション
◎OSのユーザを見るには、以下で見えるはず
python vol.py hashdump -f ./xxxx --profile=xxx

⑧hivelist :レジストリ情報

#volatility -f ./forensic_100.raw hivelist
・・・・
0xe230d5e0 0x0ffa15e0 \Device\HarddiskVolume1\Documents and Settings\Administrator\NTUSER.DAT
・・・

ここで、上記のNTUSER.DATを出力してみる。

#volatility -f ./forensic_100.raw hivedump -o 0xe230d5e0
※オプションが -sなのか-yなのか、バージョンによって異なるような気もする。

⑨yarascanを使った文字列の検索
# volatility -f ./forensic_100.raw yarascan -Y "https:"
ここで、"http"などとしてもいいだろう。ただ、量が多い。pidがわかるのであれば、指定したい。

# volatility -f ./forensic_100.raw yarascan -Y "http" --pid=1080

# volatility -f ./forensic_100.raw connscan
・connscan:既に接続が終わっているもの

・cmdscan、consolesでコマンド履歴を表示
たとえば、
#volatility.exe -f ./MemoryDump_Lab1.raw --profile=Win7SP1x64 consoles


・一覧および操作方法は以下
https://github.com/volatilityfoundation/volatility/wiki/Command-Reference

・ログインパスワードを解析する
パスワードを解析するには、SYSTEMの中のシステムKEYと、実際にパスワードが格納されているSAMの両方が必要になる。
https://gomiba.co.in/blog/archives/342
ここにあるように、hivelist でSYSTEMとSAMのVirtual Addressを取得する。
# volatility -f ../Memorydump2.bin --profile=Win7SP0x86 hivelist
上記のコマンドリファレンスにあるように、以下を参照。
すると、SYSTEMは -yで、SAMは -sで指定する。どっちがSYSTEMでどっちがSAMかをわかるようにしているのだろう。

To use hashdump, pass the virtual address of the SYSTEM hive as -y and the virtual address of the SAM hive as -s, like this:

$ python vol.py hashdump -f image.dd -y 0xe1035b60 -s 0xe165cb60
→ こんな感じかな
# volatility -f ../Memorydump2.bin --profile=Win7SP0x86 hashdump -y 0x8f61c008 -s 0x9ffc03a0

すると、PWファイルが表示される。このハッシュからPWを出す。
PWハッシュは2つあり、後半の方が実際に使われているNTハッシュ。
これを解く。どうやって解くんだろう
→https://crackstation.net/に投げてみたが、表示されなかった・・。