@port139 Blog

基本的にはデジタル・フォレンジックの技術について取り扱っていますが、記載内容には高確率で誤りが含まれる可能性があります。

SANSからの練習問題を試す ファイルの取り出し (9)

ディスク上にある notepad.exe の先頭 4096byte と、メモリイメージからカービングした notepad.exe の先頭 4096byte を比較すると、Image Baseの値が異なっている事から MD5 ハッシュ値では一致しない事が確認できました。(実際には、先頭から 1024byte 範囲内ですでに差異があるという結果でしたね)

 

ハッシュ方式として、MD5 を使うのではなく、Fazzy ハッシュを使うとどうなるか?を Fuzzy Hashing and ssdeep を使って確認してみたいと思います。

まず、ディスク上の notepad.exe 先頭 4096byte のハッシュを計算します。

>ssdeep.exe -b notepad_4096.bin > hashes.txt

ssdeep: Did not process files large enough to produce meaningful results

エラーメッセージが表示されてますが、ひとまずこの状態で出力されたテキストを確認すると以下の内容になっています。

ssdeep,1.1--blocksize:hash:hash,filename

48:aY2p5XkaIC/EZ1TDIz9f0V64PkXJn+j1VTXDrnIUfvKUjWOYVMOU4L1clC7b:uppktnIpf0Va2XDL5jP1l4,"notepad_4096.bin"

結果の数字は出力されていますが、エラーメッセージとして「ssdeep: Did not process files large enough to produce meaningful results」が出ていますので、検索してみると下記の情報を確認できました。

ssdeep / Bugs / #13 Small Identical text files fail to match with the -d

The ssdeep algorithm requires about 4KB of input to do fuzzy hashing. In your output there was a warning message indicating this, "ssdeep: Did not process files large enough to produce meaningful results". Try again with larger files.

対象のサイズが小さすぎるという事でエラーになっているようです。実際にこの状態で比較処理を行ってもエラーメッセージが出るだけで比較できないようです。(対象が小さい場合には、エラーも結果も表示されないというケースもあるようですね)

>ssdeep.exe -bm hashes.txt memdump4096-Offset929972224.bin

ssdeep: Did not process files large enough to produce meaningful results

4096byte はあるはずですが、いずれにしても 4096byte 範囲では 1024byte 以降のデータでかなり差異がありますので意味のある結果は得られないかもしれません。

 

試しに、Volatility の procexedump と procmemdump で出力したファイルを ssdeep で比較したところ、99 という数値が得られましたので、一定サイズ以上のものには有効ですね。

>ssdeep.exe -b procexedump.796.exe > hashes.txt

>ssdeep.exe -bm hashes.txt procmemdump.796.exe

procmemdump.796.exe matches hashes.txt:procexedump.796.exe (99)

 

 これとは別の話題として、メモリ内のプロセスイメージのハッシュ値を取る方法としては Memd5 がありますね。Memoryze に実装されているようですが、下記を読む感じだとLiveでないといかんというお話もあるようで、なかなか難しいですね。

https://media.blackhat.com/bh-us-11/Butler/BH_US_11_ButlerMurdock_Physical_Memory_Forensics-WP.pdf

On the other hand, by parsing the ImageSectionObject of a FileObject, it is possible to calculate the same hash from memory as the one on disk. We have implemented this approach to produce the MemD5 since it is identical to the MD5 on disk. This requires a live analysis of memory because of the necessity to read paged out sectors of the file from disk.