2020年7月31日金曜日

【64】BitCurator Access Redaction Tools (インストール成功版)

今日はなんだか始める前から眠気が半端じゃありません。
でも、頑張って大人の勉強会についていきます~

始める前の雑談
AtoM2.6.1がそろそろでる。マルチリンガル機能を強化するらしい。翻訳も一緒に改善される予定のよう。夏休みに一日翻訳をやりますか…

ではここから本題
BitCurator Access Redaction Tools を試してみます。
これが何をするものなのかは61回のブログを読んでください。簡単に言ってしまうと墨消ししてくれるツールです。

インストール

今日は以下のマニュアルを見ながら、最後までインストールを成功させましょう。
bitcurator-access-redaction Quick Start Guide
Githubにもマニュアルあります~
我々は、Githubのマニュアルでインストールを勧めました。マニュアル通りでインストールすれば良いということがわかったのですが、PDFガイドと一緒に見ていると間違いやすいところが2箇所あります。

Bitcurator 1.7.28 以上を使っている場合は、すぐ次を実行します。Prerequisites部分は飛ばします。(https://github.com/BitCurator/bitcurator-access-redaction#prerequisites

そして、Pythonのバージョンに注意が必要です。PDFのガイドにはこのことが書いてないので混乱しやすいです。

Note! In the BitCurator Environment, both Python 2.7 and Python 3.5 are installed, and the "pip" command links to Python 3.5 version of pip. You must use "pip2" to install with Python 2.7 (currently required due to a dependency on pylightgrep).

我々も以下の部分でエラーが発生しました。どうもpipにはPython3.5がインストールされるような設定になっているためのようです。

$ cd bitcurator-access-redaction
$ cd libredact
$ pip2 install -e .
 →ここでエラーが発生しました。

そこで、Pythonのバージョンを下げるために、pythonがあるディレクトリー下で以下を実施。エラーを解消できました。

sudo rm python-config
sudo ln python-2.7 python
sudo ln python2.7-config python-config
python -V     #バージョン確認


※参考:インストール中にあるsudo -H とは?
https://teratail.com/questions/169492
ユーザのホームディレクトリ($HOME)を書き換えるオプション。

ツールの大まかな流れ

このツールが動く大まかな流れは、
  1. disk imageを取る(test_image.rawを作成)
  2. Digital Forensics XML fileを作成(fiwalkを利用、ファイル名やMD5のようなハッシュ値を比較するためのもの)
  3. configファイルを作成(test_image_config.txt、どう墨消しするかを指定) 
  4. configファイルを実行($ redact-cli -c ~/Desktop/test_image_config.txtで実行)
  5. test_image_redacted.rawがアウトプットされる
です。

Configファイルのルール
ここでconfigファイルのルールを理解することが必要になります。以下はテストで実行するルールですが、マニュアルにはないコメント(#)を赤で追加しました。
# インプットするファイルの指定
INPUT_FILE /home/bcadmin/Desktop/test_image.raw # 事前に作成したDigital Forensic XMLファイルの指定
DFXML_FILE /home/bcadmin/Desktop/test_image_fw.xml
# アウトプットフアィルの指定
OUTPUT_FILE /home/bcadmin/Desktop/test_image_redacted.raw

# Targets The Whale.txt 
FILE_NAME_MATCH *Whale.txt FUZZ

# Targets Dorian Gray.txt
FILE_MD5 114583cd8355334071e9343a929f6f7c FILL 0x44

# Targets DRINKME.TXT
FILE_SHA1 7f9f0286e16e9c74c992e682e27487a9eb691e86 FILL 0x44

# Fill Kafka sequences in Metamorphsis.txt with K
SEQ_EQUAL Kafka FILL 0x4B

# employmentなんとかのファイルにある社会保障番号のようなものを0x44(ASCIIではアルファベットD)で埋める
SEQ_MATCH \d{3}-?\d{2}-?\d{4} FILL 0x44

# Scrub EATME.TXT
FILE_SEQ_EQUAL pineapple-upside-down-cake SCRUB

# Scrub Alice in Wonderland
FILE_DIRNAME_EQUAL looking-glass SCRUB

# Ignore EATME.TXT.BACKUP
IGNORE *.BACKUP

# Commit the redaction (write out a redacted disk image)
COMMIT

上記の操作は以下のルールに沿っています。(PDFガイドp11)
Rule Command Format: [target condition] [action]

Target Conditions:
FILE_NAME_EQUAL <filename> - target a file with the given filename
FILE_NAME_MATCH <pattern> - target any file with a given filename pattern
FILE_DIRNAME_EQUAL <directory> - target all files in the directory
FILE_MD5 <md5> - target any file with the given md5
FILE_SHA1 <sha1> - target any file with the given sha1
FILE_SEQ_EQUAL <string> - target any file that contains <a string>
FILE_SEQ_MATCH <pattern> - target any file that contains a sequence matching <a pattern>
SEQ_EQUAL <string> - target any sequences equal to <a string>
SEQ_MATCH <pattern> - target any sequences matching <a pattern>

Actions:
SCRUB overwrite the bytes in the target with zeroes
FILL 0x44 overwrite by filling with a given character (here, 0x44, or ASCII 'D')
FUZZ fuzz the binary, but not the strings

しかし、指定した内容が正しく実行されたかがよくわかりません。例えば、SCRUBはゼロに埋めるという処理ですが、予想よりはるかに多いファイルの中がゼロで埋め尽くされていました。
画像の左が元のファイル、右が00で埋められたファイル


そこで、SCRUBが含まれている処理を付けたり外したりして、処理されたファイル数を調べて見ました。configファイルにある以下のSCRUB処理が対象です。
① FILE_DIRNAME_EQUAL looking-glass SCRUB
② FILE_SEQ_EQUAL pineapple-upside-down-cake SCRUB
  1. ①、②両方実行:42個 (ここだけXMLファイルを除外)
  2. ①のみ実行:9個
  3. ②のみ実行:41個
  4. ①、②両方除外:8個
この結果から、SCRUBがどう動いているか…よくわかりません。例えば、SEQ_EQUAL Kafka FILL 0x4Bの場合は、Kafkaの名前部分だけがKKKKKに変更されたことが確認できました。しかし、SCRUBのようによくわからない部分も… 

ここで他の設定を入れてみて処理ファイルの数を確認したりしましたが、ファイルの内容を全部把握していないこともあり、結果が正確かがいまいちわかりませんでした。ということで、今日はこのあたりで終わりです。次回は、Configファイルのルールについてもう少し勉強します。

---------------------------------------------
次回は、9月4日(金)です。
8月は、な・つ・や・す・み! いぇ~~

後日追記
以下は参考資料です〜 読みましょう〜

Testing bca-redtools in the BitCurator Environment

Redacting Private and Sensitive Information in Born-Digital Collections

最近の投稿

【108】Archives in the Digital Age: The use of AI and machine learning in the Swedish archival sectorを読む

 Gijs Aangenendt氏の修士論文、Archives in the Digital Age: The use of AI and machine learning in the Swedish archival sectorを半分読みました。 前半は、AIを扱ったアーカ...

人気の投稿