KaliLinux (shredコマンド)を使って HDDを消去する

PCをKaliLinux で起動して Shredを使ってHDDの上書き消去する。

  • 特にKalilinuxである必要はありません。
    たまたま手元にあったので、消えたことを確認する手順も実行するのに都合が良いと思って使ってみましました。
  • SecureEraseについては扱いません。
    いろいろとコツがあるようなので、今回は取り扱わないことにしました。
  • 消去製品と違い実行結果レポート出ないので、作業の証拠は実行結果とdmidecodeの出力を並べて写真撮る事で代用かな、、
    信頼性の有るレポートが必要な場合、消去用の製品を買った方が良いですね。そんなに高くないし。

注意点

  • パソコンのSecureboot が有効だと USBメモリからKaliLinux を起動することが出来ませんでした。
    この場合BIOSの設定でSecurebootを無効化する必要があります。
  • 起動用USBメモリの作り方は書いてません。
    こっちの記事なんかを参照してください

消去に必要な上書き回数は何回か?

これまで、三回上書きがスタンダードと聞くことが多くありましたが、一回上書きで十分だとの根拠が示される事も多くなりましたので、
作業効率を考えて今回は一回上書きで手順を作ってみます。ただ、Shredが最初から"0"クリアができない為、結果的には
ランダムで一回 + "0"で一回 の二回上書きになっちゃってます。

参考)上書きが一回で十分だと思うようになったのは、以下の資料を見た事がきっかけです。

Shred コマンドの実行

消去対象ディスクの特定

fdisk -l で接続されているDiskを表示し、容量・パーティション構成などから消去対象Diskを特定してください。
今回は 4GB のディスクイメージを追加してテストします。

操作例はUSB起動ではなくVirtualBox上にインストールしたKali Linuxを利用した時のものです。

user01@kali:~$ sudo fdisk -l
[sudo] password for user01:
Disk /dev/sdb: 4 GiB, 4294967296 bytes, 8388608 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5c679d64

Device     Boot    Start      End  Sectors Size Id Type
/dev/sda1  *        2048 75497471 75495424  36G 83 Linux
/dev/sda2       75499518 83884031  8384514   4G  5 Extended
/dev/sda5       75499520 83884031  8384512   4G 82 Linux swap / Solaris


user01@kali:~$

Shred の実行

今回は テスト用の 4GBのDisk /dev/sdb を消去してみます。

オプションは以下のものを指定しました。
-v は、実行中の表示を増やすオプション
-z は、最後全面に"0"を書き込むオプション(最初から"0"を書き込むオプションはないみたい)
-n 1 は、上書き回数の指定。未指定の場合 3回上書きになります。

user01@kali:~$ sudo shred -v -z -n 1 /dev/sdb
shred: /dev/sdb: pass 1/2 (random)...
shred: /dev/sdb: pass 1/2 (random)...466MiB/4.0GiB 11%
shred: /dev/sdb: pass 1/2 (random)...1014MiB/4.0GiB 24%
shred: /dev/sdb: pass 1/2 (random)...1.5GiB/4.0GiB 38%
shred: /dev/sdb: pass 1/2 (random)...2.0GiB/4.0GiB 51%
shred: /dev/sdb: pass 1/2 (random)...2.5GiB/4.0GiB 64%
shred: /dev/sdb: pass 1/2 (random)...3.1GiB/4.0GiB 77%
shred: /dev/sdb: pass 1/2 (random)...3.6GiB/4.0GiB 91%
shred: /dev/sdb: pass 1/2 (random)...4.0GiB/4.0GiB 100%
shred: /dev/sdb: pass 2/2 (000000)...
shred: /dev/sdb: pass 2/2 (000000)...863MiB/4.0GiB 21%
shred: /dev/sdb: pass 2/2 (000000)...1.7GiB/4.0GiB 43%
shred: /dev/sdb: pass 2/2 (000000)...2.6GiB/4.0GiB 66%
shred: /dev/sdb: pass 2/2 (000000)...3.5GiB/4.0GiB 89%
shred: /dev/sdb: pass 2/2 (000000)...4.0GiB/4.0GiB 100%
user01@kali:~$

削除した事の証跡

PC情報の表示

shredを実行したterminalとは別に新しい端末(terminal)を開き dmidecode を実行し system情報を入手。
shredの実行結果ウインドウと並べて写真を撮ると、消去を実行した機器と実行結果を同時に残すことができます。

サンプルは仮想マシンなので、あまり有効な情報は表示されていませんが、通常は製造元・装置名・製造号機が確認できます。

user01@kali:~$ sudo dmidecode -t system
[sudo] password for user01:
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.5 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: innotek GmbH
    Product Name: VirtualBox
    Version: 1.2
    Serial Number: 0
    UUID: b9ccfbe0-17af-8248-89c3-093a1a907650
    Wake-up Type: Power Switch
    SKU Number: Not Specified
    Family: Virtual Machine

user01@kali:~$

本当に消えてるのか?

空き領域からファイルの検索してくれてる PhotoRec コマンドを使って消去済みファイルを検索してみます。

user01@kali:~$ sudo photorec

検索対象のDiskを選択します。今回は削除した /dev/sdb を調査します。

PhotoRec 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

  PhotoRec is free software, and
comes with ABSOLUTELY NO WARRANTY.

Select a media (use Arrow keys, then press Enter):
 Disk /dev/sda - 42 GB / 40 GiB (RO) - VBOX HARDDISK
>Disk /dev/sdb - 4294 MB / 4096 MiB (RO) - VBOX HARDDISK









>[Proceed ]  [  Quit  ]

Note:
Disk capacity must be correctly detected for a successful recovery.
If a disk listed above has an incorrect size, check HD jumper settings and BIOS
detection, and install the latest OS patches and disk drivers.

選択したDisk内のパーティションが表示されます。ここから調査したいパーティションを選択してください。
今回はDisk毎削除している為パーティションは認識されません。Unknownを選択してください。

PhotoRec 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

Disk /dev/sdb - 4294 MB / 4096 MiB (RO) - VBOX HARDDISK

     Partition                  Start        End    Size in sectors
>   P Unknown                  0   0  1   522  42 32    8388608















>[ Search ]  [Options ]  [File Opt]  [  Quit  ]
                              Start file recovery

選択したパーティションをどのファイルシステムとして調査するのかを指定してください。
殆どの場合Linuxで使用していたのであれば ext2/ext3、Windowsであれば other を選択すれば良いです。

PhotoRec 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

   P Unknown                  0   0  1   522  42 32    8388608

To recover lost files, PhotoRec needs to know the filesystem type where the
file were stored:
>[ ext2/ext3 ] ext2/ext3/ext4 filesystem
 [ Other     ] FAT/NTFS/HFS+/ReiserFS/...

ファイルが検出された場合の保存先ディレクトリを指定します。
今回は Documents を選択しました。

PhotoRec 7.1, Data Recovery Utility, July 2019

Please select a destination to save the recovered files to.
Do not choose to write the files to the same partition they were stored on.
Keys: Arrow keys to select another directory
      C when the destination is correct
      Q to quit
Directory /home/user01
 drwxr-xr-x  1000  1000      4096 20-Apr-2020 14:02 .
 drwxr-xr-x     0     0      4096  4-Mar-2020 11:38 ..
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Desktop
>drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Documents
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Downloads
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Music
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Pictures
 drwxr-xr-x  1000  1000      4096 20-Apr-2020 13:58 Public
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Templates
 drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 Videos
 -r-xr-xr-x  1000  1000   6716837  8-Apr-2020 15:56 VBoxLinuxAdditions.run
 -rw-r--r--     0     0     40960 20-Apr-2020 14:02 photorec.se2

"C"を押すと検索が始まります。

PhotoRec 7.1, Data Recovery Utility, July 2019

Please select a destination to save the recovered files to.
Do not choose to write the files to the same partition they were stored on.
Keys: Arrow keys to select another directory
      C when the destination is correct
      Q to quit
Directory /home/user01/Documents
>drwxr-xr-x  1000  1000      4096  4-Mar-2020 11:40 .
 drwxr-xr-x  1000  1000      4096 20-Apr-2020 14:02 ..

しばらくすると検索結果が表示されます。
"0 files saved"が有ればファイルが検知されなかったと言う事なので、消去は成功していたと思われます。

確認出来たら、Q を数回押して photorec を終了してください。

PhotoRec 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

Disk /dev/sdb - 4294 MB / 4096 MiB (RO) - VBOX HARDDISK
     Partition                  Start        End    Size in sectors
   P Unknown                  0   0  1   522  42 32    8388608


0 files saved in /home/user01/Documents/recup_dir directory.
Recovery completed.











[ Quit ]

おしまい。

kichise
ユーザー登録して、Qiitaをもっと便利に使ってみませんか。
  1. あなたにマッチした記事をお届けします
    ユーザーやタグをフォローすることで、あなたが興味を持つ技術分野の情報をまとめてキャッチアップできます
  2. 便利な情報をあとで効率的に読み返せます
    気に入った記事を「ストック」することで、あとからすぐに検索できます
ユーザーは見つかりませんでした