File System Forensic Analysis まとめ - DD練習

背景

「File System Forensic Analysis」の Chapter 3 のDDを使った練習の一部を試してみます。

目的

DDコマンドを用いてファイルシステムを操作できるようになる。

準備

  • MacBookPro(15.3.0 Darwin
  • ddコマンド

練習

小さなファイルをコピーしてみます。

$ echo "Hello, World!" >> file1 
$ dd if=file1 of=file1_cp bs=512
0+1 records in
0+1 records out
13 bytes transferred in 0.000055 secs (237069 bytes/sec)
$ ls
file1 file1_cp

0+1 records in ここの意味は

  • 0 → 0(+1)個分のセクタブロック(??)を処理した
  • +1 → 最後のセクタブロックをFullサイズ(=512 byte)処理した(+0ならFullサイズ処理しなかった)

次にInputファイルサイズを大きくしてみます。
ただしファイルサイズ<ブロックサイズとします。

$ perl -e "print 'a'x511" > file2
$ dd if=file2 of=file2_cp bs=512
0+1 records in
0+1 records out
511 bytes transferred in 0.000054 secs (9441803 bytes/sec)

上記は 0(+1) = 1個のセクタブロックに対して読込、書込を行い、かつ
最後のセクタブロックに対してFullサイズ処理していないので0+1 records inとなっていますね。

次にファイルサイズ=ブロックサイズとしてみます

$ perl -e "print 'a'x512" > file3
$ dd if=file3 of=file3_cp bs=512
1+0 records in
1+0 records out
512 bytes transferred in 0.000064 secs (8012999 bytes/sec)

上記は 1(+1) = 2個のセクタブロックに対して読込、書込を行い(※ 1番目のブロックに対して0byte処理したってことかな)
かつ、最後のセクタブロックに対してFullサイズ処理しているので1+0 records inとなっていますね。

次にファイルサイズ>ブロックサイズとしてみます。

$ perl -e "print 'a'x513" > file4
$ dd if=file4 of=file4_cp bs=512
1+1 records in
1+1 records out
513 bytes transferred in 0.000068 secs (7549747 bytes/sec)

上記は 1(+1) = 2個のセクタブロックに対して読込、書込を行い、かつ
最後のセクタブロックに対してFullサイズ処理していないので1+1 records inとなっていますね。

思ったほどddコマンドの難しい使い方って思いつかないですね...

以上。