🔎

SadServers解説#4 "The Command Line Murders"

2024/01/22に公開

問題概要

シナリオ

コマンドライン殺人事件
 

問題詳細

今回の問題は「コマンドライン殺人事件」です。
ヒントは/home/admin/clmysteryディレクトリの下にあります。ぜひ、捜査を楽しんでください!

 

解決判定

犯人の名前を/home/admin/mysolutionに書き込み、Check My Solutionボタンをクリックしてください。たとえば、犯人の名前がJohn Smithなら、 次のようなコマンドを実行し、Check My Solutionボタンをクリックしてください。

$ echo "John Smith" > /home/admin/mysolution

解答が正解かどうか、コマンドプロンプト上で確認することも可能です。ハッシュ値を求める次のコマンドを実行して、以下と同じ出力が得られた場合は正解です。

$ md5sum /home/admin/mysolution 
9bba101c7369f49ca890ea96aa242dd5  /home/admin/mysolution

 

補足

ファイルの中身を見ればわかるのですが、各ファイルには何が書いてあるのか、ディレクトリ構造がどうなっているのか混乱したので、最初にまとめておきます。

/home/admin/clmystery
|--cheatsheet.md            :使用するコマンド
3が記載されています。
|--hint1                    :ヒントが8つ用意されています。本記事の末尾に、各ヒントと日本語訳を掲載しています。
|--hint2
|--hint3
|--...
|--hint8
|--instructions             :【最初にこのファイルを読んでください】問題の導入。
|--mystery                  :このディレクトリ内で捜査を行います。
|  |--crimescene            :犯罪現場の報告書。様子が詳しく記載されています。
|  |--people                :この街の住人の一覧です。名前、性別、年齢、住所が書かれています。
|  |                         特定の人物を取材するには、streetsディレクトリ内のその人の住む街路にアクセスします。
|  |--streets               :街路が格納されたディレクトリです。特定の街路で聞き込み捜査をするには、この中の街路ファイルにアクセスします。
|  |  |                      特定の人物に聞き込み捜査をするには、その人物が住んでいる街路の、特定の行番号にアクセスします。
|  |  |--Abbot_Street
|  |  |--Acton_Street
|  |  |--Addington_Road
|  |  |--…
|  |--interviews            :各人物に聞き込み捜査した結果。
|  |  |--interview-000296
|  |  |--interview-00448418
|  |  |--interview-00502304
|  |  |--…
|  |--vehicles              :ターミナル市自動車局から提供された、車両および所有者の情報。
|  |--memberships           :会員情報。各ファイルには会員名のリストが記載されています。
|  |  |--AAA
|  |  |--AAdvantage
|  |  |--Costco
|  |  |--…

 

実際に遊んでみました

調査開始

ヒントは/home/admin/clmysteryディレクトリの下にあるそうなので、まずはclmysteryディレクトリの中身を見てみます。

~$ ls
agent  clmystery  mysolution
~$ ls clmystery/
LICENSE.md  cheatsheet.md   hint1  hint3  hint5  hint7  instructions
README.md   cheatsheet.pdf  hint2  hint4  hint6  hint8  mystery

何やらいろいろなファイルがあります。instructionsを見てみます。

~/clmystery$ cat instructions
.OOOOOOOOOOOOOOO @@                                   @@ OOOOOOOOOOOOOOOO.
OOOOOOOOOOOOOOOO @@                                    @@ OOOOOOOOOOOOOOOO
OOOOOOOOOO'''''' @@                                    @@ ```````OOOOOOOOO
OOOOO'' aaa@@@@@@@@@@@@@@@@@@@@"""                   """""""""@@aaaa `OOOO
OOOOO,""""@@@@@@@@@@@@@@""""                                     a@"" OOOA
OOOOOOOOOoooooo,                                            |OOoooooOOOOOS
OOOOOOOOOOOOOOOOo,                                          |OOOOOOOOOOOOC
OOOOOOOOOOOOOOOOOO                                         ,|OOOOOOOOOOOOI
OOOOOOOOOOOOOOOOOO @          THE                          |OOOOOOOOOOOOOI
OOOOOOOOOOOOOOOOO'@           COMMAND                      OOOOOOOOOOOOOOb
OOOOOOOOOOOOOOO'a'            LINE                         |OOOOOOOOOOOOOy
OOOOOOOOOOOOOO''              MURDERS                      aa`OOOOOOOOOOOP
OOOOOOOOOOOOOOb,..                                          `@aa``OOOOOOOh
OOOOOOOOOOOOOOOOOOo                                           `@@@aa OOOOo
OOOOOOOOOOOOOOOOOOO|                                             @@@ OOOOe
OOOOOOOOOOOOOOOOOOO@                               aaaaaaa       @@',OOOOn
OOOOOOOOOOOOOOOOOOO@                        aaa@@@@@@@@""        @@ OOOOOi
OOOOOOOOOO~~ aaaaaa"a                 aaa@@@@@@@@@@""            @@ OOOOOx
OOOOOO aaaa@"""""""" ""            @@@@@@@@@@@@""               @@@|`OOOO'
OOOOOOOo`@@a                  aa@@  @@@@@@@""         a@        @@@@ OOOO9
OOOOOOO'  `@@a               @@a@@   @@""           a@@   a     |@@@ OOOO3
`OOOO'       `@    aa@@       aaa"""          @a        a@     a@@@',OOOO'


There's been a murder in Terminal City, and TCPD needs your help.
To figure out whodunit, go to the 'mystery' subdirectory and start working from there.
You'll want to start by collecting all the clues at the crime scene (the 'crimescene' file).
The officers on the scene are pretty meticulous, so they've written down EVERYTHING in their officer reports.
Fortunately the sergeant went through and marked the real clues with the word "CLUE" in all caps.
If you get stuck, open one of the hint files (from the CL, type 'cat hint1', 'cat hint2', etc.).
To check your answer or find out the solution, open the file 'solution' (from the CL, type 'cat solution').
To get started on how to use the command line, open cheatsheet.md or cheatsheet.pdf (from the command line, you can type 'nano cheatsheet.md').
Don't use a text editor to view any files except these instructions, the cheatsheet, and hints.
【日本語訳】

ターミナル・シティで殺人事件が発生し、TCPD(Linux向けセキュリティソフト)があなたの助けを必要としています。
犯人を突き止めるには、mysteryディレクトリに行き、そこから作業を開始してください。
まず、犯行現場(crimesceneファイル)にある手がかりをすべて集めることから始めましょう。
現場の巡査はかなり几帳面なので、巡査報告書にあらゆることを書き留めています。
幸いなことに、巡査部長は本物の手がかりに目を通し、大文字で「CLUE」と印をつけました。
行き詰まったら、ヒントファイルを開いてください(コマンドラインからcat hint1cat hint2などとタイプしてください)。
自分の解答を確認したり、解答を知りたい場合には、solutionファイルを開いてください(コマンドラインからcat solutionと入力してください)。
※SadServersにはsolutionファイルは存在しないようです。
コマンドラインの使い方を始めるには、cheatsheet.mdcheatsheet.pdfを開いてください(コマンドラインからnano cheatsheet.mdと入力できます)。
この説明書、チートシート、ヒント以外のファイルを見るのにテキストエディタは使わないでください。

大事なことは、以下の点です。

  • mysteryディレクトリに移動して謎解きを開始する
  • まずは、crimesceneファイルで手掛かりを探す
  • 手掛かりにはCLUEの印がついている

 

捜査開始

捜査内容

重要な手掛かりに"CLUE"という印がついているらしいので、crumesceneファイルのCLUEという文字列を含む行を抽出してみます。

実行コマンド

grepコマンドを使用して、行を絞り込みます。

~/clmystery/mystery$ grep CLUE crimescene 
CLUE: Footage from an ATM security camera is blurry but shows that the perpetrator is a tall male, at least 6'.
CLUE: Found a wallet believed to belong to the killer: no ID, just loose change, and membership cards for Rotary_Club, Delta SkyMiles, the local library, and the Museum of Bash History. The cards are totally untraceable and have no name, for some reason.
CLUE: Questioned the barista at the local coffee shop. He said a woman left right before they heard the shots. The name on her latte was Annabel, she had blond spiky hair and a New Zealand accent.
【日本語訳】

手掛かり:ATMの監視カメラの映像は不鮮明だが、犯人は身長6フィート(約183cm)以上の長身の男性である。
手掛かり:犯人のものと思われる財布を発見。IDはなく、小銭と、ロータリークラブ、デルタスカイマイル、地元の図書館、バッシュ歴史博物館の会員カードが入っていたのみ。会員カードから持ち主を特定することは不可能で、なぜか名前もない。
手掛かり:地元のコーヒーショップのバリスタに質問したところ、銃声を聞く直前に女性が立ち去ったという。彼女のコーヒーカップに書いてあった名前はAnnabelで、髪はブロンズのスパイキーヘアで、言葉はニュージーランド訛りだった。

得られた手掛かり

この手掛かりをまとめると、以下のようになります。

  • 犯人は身長6フィート以上の男性
  • 犯人は以下の会員
    • Rotary_Club
    • Delta SkyMiles
    • the local library
    • the Museum of Bash History
  • 事件当時、Annabelという名前の女性が現場近くにいた

 

目撃者の捜索

捜査内容

目撃者の手掛かりが得られたので、その人を探して聞き込み調査をしましょう。
この街に住む人はpeopleファイルにリスト化されているので、その中からAnnabelという名前の人を探します。

実行コマンド

まずは、ファイルの中身をのぞいてみましょう。

~/clmystery/mystery$ head people 
***************
To go to the street someone lives on, use the file
for that street name in the 'streets' subdirectory.
To knock on their door and investigate, read the line number
they live on from the file.  If a line looks like gibberish, you're at the wrong house.
***************

NAME    GENDER  AGE     ADDRESS
Alicia Fuentes  F       48      Walton Street, line 433
Jo-Ting Losev   F       46      Hemenway Street, line 390

各行に、住人の名前、性別、年齢、住所が書かれているようです。
grepコマンドを使って、Annabelという名前の人を探します。

~/clmystery/mystery$ grep Annabel people
Annabel Sun     F       26      Hart Place, line 40
Oluwasegun Annabel      M       37      Mattapan Street, line 173
Annabel Church  F       38      Buckingham Place, line 179
Annabel Fuglsang        M       40      Haley Street, line 176

Annabelという名前の人を探した結果、4名の人物がヒットしました。

得られた手掛かり

Annabelという名前の人は女性ということですから、以下2名の人が該当します。

  • Annabel Sun F 26 Hart Place, line 40
  • Annabel Church F 38 Buckingham Place, line 179

 

目撃者への聞き込み調査

捜査内容

目撃者の可能性がある人物に聞き込み調査を行います。
peopleファイルに書かれた住所と行数から、streetsディレクトリにアクセスし、聞き込み調査を行います。

実行コマンド
~/clmystery/mystery$ less -N streets/Hart_Place
     39 stupendous prolonged smog naps 
     40 SEE INTERVIEW #47246024
     41 jails attune subversives forewarn adept 
~/clmystery/mystery$ cat interviews/interview-47246024
Ms. Sun has brown hair and is not from New Zealand.  Not the witness from the cafe.
【日本語訳】

サンさんは茶髪で、ニュージーランド出身ではなかった。カフェの目撃者ではない。

 

~/clmystery/mystery$ less -N streets/Buckingham_Place
    178 whitewall napkins overheats embittering grimmer beamed 
    179 SEE INTERVIEW #699607
    180 festoon dispenser kidder odysseys spoons buttonholing 
~/clmystery/mystery$ cat interviews/interview-699607
Interviewed Ms. Church at 2:04 pm.  Witness stated that she did not see anyone she could identify as the shooter, that she ran away as soon as the shots were fired.
 
However, she reports seeing the car that fled the scene.  Describes it as a blue Honda, with a license plate that starts with "L337" and ends with "9"
【日本語訳】

午後2時4分、チャーチさんに聞き込み捜査を実施。彼女は犯人を見ておらず、発砲と同時に逃げたと述べている。
しかし、彼女は現場から逃走した車を見ていた。逃走車の車種はHondaで、色は青、ナンバープレートは"L337"で始まり"9"で終わっていたとのこと。

得られた手掛かり

二人目のチャーチさんが目撃者でした。
犯人の車は、青のHondaで、ナンバープレートは"L337~9"だったことが分かりました。

 

車両の特定

捜査内容

車の特徴から、持ち主である犯人を捜しましょう。
この街の車両と持ち主の情報は、vehicleファイルに記載されています。

実行コマンド

まずは、vehicleファイルを見てみましょう。

~/clmystery/mystery$ head -11 vehicles 
***************
Vehicle and owner information from the Terminal City Department of Motor Vehicles
***************

License Plate T3YUHF6
Make: Toyota
Color: Yellow
Owner: Jianbo Megannem
Height: 5'6"
Weight: 246 lbs

どうやら、車両と持ち主の情報が、1車両につき6行で書いてあるようです。
探している車両の情報をもとに絞り込みます。

~/clmystery/mystery$ grep -A 6 L337.*9 vehicles | grep -B 1 -A 5 "Make: Honda" | grep -B 2 -A 3 "Color: Blue"
License Plate L337QE9
Make: Honda
Color: Blue
Owner: Erika Owens
Height: 6'5"
Weight: 220 lbs
--
License Plate L337539
Make: Honda
Color: Blue
Owner: Aron Pilhofer
Height: 5'3"
Weight: 198 lbs
--
License Plate L337369
Make: Honda
Color: Blue
Owner: Heather Billings
Height: 5'2"
Weight: 244 lbs
--
License Plate L337DV9
Make: Honda
Color: Blue
Owner: Joe Germuska
Height: 6'2"
Weight: 164 lbs
--
License Plate L3375A9
Make: Honda
Color: Blue
Owner: Jeremy Bowers
Height: 6'1"
Weight: 204 lbs
--
License Plate L337WR9
Make: Honda
Color: Blue
Owner: Jacqui Maher
Height: 6'2"
Weight: 130 lbs

また、車の持ち主の性別も調べておきます。

~/clmystery/mystery$ grep -A 6 L337.*9 vehicles | grep -B 1 -A 5 "Make: Honda" | grep -B 2 -A 3 "Color: Blue" | grep Owner: | cut -d " " -f 2- | xargs -i grep {} people 
Erika Owens      F       56      Trapelo Street, line 98
Aron Pilhofer    M       16      Claybourne Street, line 145
Heather Billings F       38      Culbert Street, line 19
Joe Germuska     M       65      Plainfield Street, line 275
Jeremy Bowers    M       34      Dunstable Road, line 284
Jacqui Maher     F       40      Andover Road, line 224
得られた手掛かり

上の出力結果より、容疑者は以下6名に絞り込まれました。

名前 性別 身長
Erika Owens 女性 6'5
Aron Pilhofer 男性 5'3
Heather Billings 女性 5'2
Joe Germuska 男性 6'2
Jeremy Bowers 男性 6'1
Jacqui Maher 女性 6'2

最初の手掛かりから、身長6フィートであり、かつ性別が男であることが分かっているので、容疑者は以下の2人に絞られます。

  • Joe Germuska
  • Jeremy Bowers

 

犯人の特定

捜査内容

容疑者を2人にまで絞り込めました。
まだ使用していない証拠は、会員情報です。
この2人の会員情報を調べて、犯人を特定しましょう
 
再掲:犯人は以下の会員

  • Rotary_Club
  • Delta SkyMiles
  • the local library
  • the Museum of Bash History
実行コマンド
~/clmystery/mystery$ grep  "Joe Germuska" memberships/*
memberships/AAA:Joe Germuska
memberships/Delta_SkyMiles:Joe Germuska
memberships/Museum_of_Bash_History:Joe Germuska
memberships/Rotary_Club:Joe Germuska
memberships/Terminal_City_Library:Joe Germuska
~/clmystery/mystery$ grep  "Jeremy Bowers" memberships/*
memberships/AAA:Jeremy Bowers
memberships/Delta_SkyMiles:Jeremy Bowers
memberships/Museum_of_Bash_History:Jeremy Bowers
memberships/Terminal_City_Library:Jeremy Bowers
得られた手掛かり

事件現場に残された財布の中の会員情報に一致するのはJoe Germuskaでした。
以下コマンドを実行し犯人を報告して、Check My Solutionボタンをクリックすることでクリアです。

$ echo "Joe Germuska" > /home/admin/mysolution

コマンドラインで殺人事件を捜査する、という不思議な謎解きでしたが、とても面白かったです。
製作者のNoah Veltmanさん、この問題を登録不要で開放しているSadServersに拍手👏
 

公式のヒント

~/clmysteryディレクトリで以下のコマンドを実行すると、ヒントを表示することができます。

~/clmystery$ cat hint1

ヒントはhint1~hint8の計8つあります。各ヒントの内容と日本語訳を以下に記載しています。

ヒント1

Try poking around what's in a file by using the 'head' command:

~/clmystery/mystery$ head -n 20 people

This will show you the first 20 lines of the 'people' file.

【日本語訳】

headコマンドを使ってファイルの中身を探ってみましょう。

~/clmystery/mystery$ head -n 20 people

これでpeopleファイルの最初の20行が表示されます。

ヒント2

Try using grep to search for the clues in the crimescene file:

~/clmystery/mystery$ grep CLUE crimescene 
【日本語訳】

grepを使ってcrimesceneファイル内の手がかりを検索してみましょう。

~/clmystery/mystery$ grep CLUE crimescene 
ヒント3

In order to track down our potential witness, we need to figure out where she lives.
Try using 'head' on some of the files like 'people' and 'vehicles' and see where we might find that.

【日本語訳】

目撃者候補を追跡するためには、彼女がどこに住んでいるかを突き止める必要があります。
headpeoplevehiclesなどのファイルに使ってみて、どこに住んでいるか調べてみましょう。

ヒント4

To find all the Annabels' addresses, use the 'people' file:

~/clmystery/mystery$ grep Annabel people 

Notice that not all of the results are worth investigating. Remember what we know about Annabel.

【日本語訳】

すべてのAnnabelの住所を見つけるには、'people'ファイルを使います

~/clmystery/mystery$ grep Annabel people 

すべての結果が調査する必要があるとは限りません。Annabelについて知っていることを思い出しましょう。

ヒント5

"Interview" the two possible witnesses by reading the correct line from the streets they live on:

head -n 173 streets/Mattapan_Street | tail -n 1

This will give you just line 173 of Mattapan street, because it will take first 173 lines, and then take the last line from those.

【日本語訳】

彼らが住んでいる通りから正しい行を読み取ることによって、目撃者の可能性がある2人の人物に "インタビュー "しましょう

head -n 173 streets/Mattapan_Street | tail -n 1

これは、マタパン通りの173行目だけを表示できます。なぜなら、headコマンドで最初の173行を表示し、tailコマンドで末尾の173行目だけを残すことができるからです。

ヒント6

To find a matching license plate, or a matching car, you can use grep on the 'vehicles' file:

grep "Honda" vehicles
grep "Blue" vehicles
grep "L337" vehicles

This doesn't give us anything useful - why not? Try using 'head' on the file to investigate its structure.

【日本語訳】

一致するナンバープレート、または一致する車を見つけるには、'vehicles'ファイルでgrepを使います。

grep "Honda" vehicles
grep "Blue" vehicles
grep "L337" vehicles

しかし、上記のコマンドは何の役にも立ちません。headコマンドを使ってファイルの構造を調べてみましょう。

ヒント7

In order to actually get information about vehicles that might match our description,we need to get multiple lines AROUND each match. We can use the -A, -B, or -C option with grep:

grep -A 5 "L337" mystery/vehicles

This will match the license plates that contain "L337" and, for each match, show us the five lines AFTER it.

【日本語訳】

証拠と一致する可能性のある車の情報を実際に得るためには、複数の行を取得する必要があります。grepコマンドで-A-B-Cオプションを使うことができます。

grep -A 5 "L337" mystery/vehicles

このコマンドは、"L337"を含むナンバープレートにマッチし、マッチするごとに、その後に続く5行を表示します。

ヒント8

To see who was a member of several different groups, you can combine their membership lists into one and search against that.

cat Fitness_Galaxy AAA United_MileagePlus | grep "John Smith"

If you only want to see the number of matches, you can use grep's -c option (the c must be lowercase):

cat Fitness_Galaxy AAA United_MileagePlus | grep -c "John Smith"

Or you can pipe the result to 'wc -l':

cat Fitness_Galaxy AAA United_MileagePlus | grep "John Smith" | wc -l
【日本語訳】

誰が複数の異なるグループのメンバーであったかを見るためには、それらのメンバーリストを1つにまとめ、それに対して検索すると良いでしょう。

cat Fitness_Galaxy AAA United_MileagePlus | grep "John Smith"

マッチした数だけを見たい場合は、grepコマンドの-cオプションを使うことができます。

cat Fitness_Galaxy AAA United_MileagePlus | grep -c "John Smith"

あるいは、結果を「wc -l」にパイプすることもできます:

cat Fitness_Galaxy AAA United_MileagePlus | grep "John Smith" | wc -l

 

問題一覧はこちら

https://zenn.dev/comf_nakamura/articles/sadservers_sitemap

Discussion