Skip to main content

Command Palette

Search for a command to run...

My Solution & Approach for: Command-line Murder Mystery

There's been a murder in Terminal City, and TCPD needs your help. To figure out whodunit, you need access to a command line.

Published
5 min read
My Solution & Approach for: Command-line Murder Mystery
S

I am a CS graduate from IIEST Shibpur (2023). I love to go deep into computers and the Internet and find out how both of them work from first principles. I want to be capable of understanding both of them with full depth to make them more secure and truly understand and harness their capabilities.

I also love to build scalable systems in the backend and test them to their limits. I aim to build products people want, at scale.

Repo: https://github.com/veltman/clmystery

git clone https://github.com/veltman/clmystery.git

cd clmystery

less instructions
# based on it, we need to collect all CLUE from crimescene file

cd mystery

ls
# crimescene  interviews  memberships people      streets     vehicles
# we have interviews for each person, membership lists, streets list, people and vehicle details

# crimescene file is too big to read, so we'll grep for CLUE
grep -n -r "CLUE" *
# crimescene:9213:CLUE: Footage from an ATM security camera is blurry but shows that the perpetrator is a tall male, at least 6'.
# crimescene:9370:CLUE: Found a wallet believed to belong to the killer: no ID, just loose change, and membership cards for AAA, Delta SkyMiles, the local library, and the Museum of Bash History. The cards are totally untraceable and have no name, for some reason.
# crimescene:11002: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.

# current suspects and details:
# tall Male, taller than 6', has memberships to AAA, Delta SkyMiles, the local library, and the Museum of Bash History
# someone named Annabel could possibly lead us to more information or could be the suspect itself if it's a Male

# let's start with Annabel
grep -r "Annabel" *
# crimescene: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.
# memberships/REI:Annabel Church
# memberships/Rotary_Club:Annabel Sun
# memberships/Rotary_Club:Annabel Fuglsang
# memberships/Rotary_Club:Annabel Church
# memberships/AAA:Annabel Church
# memberships/AAdvantage:Annabel Fuglsang
# memberships/AAdvantage:Annabel Church
# memberships/Fitness_Galaxy:Oluwasegun Annabel
# memberships/Fitness_Galaxy:Annabel Church
# memberships/Museum_of_Bash_History:Annabel Church
# memberships/Museum_of_Bash_History:Oluwasegun Annabel
# people:Annabel Sun    F    26    Hart Place, line 40
# people:Oluwasegun Annabel    M    37    Mattapan Street, line 173
# people:Annabel Church    F    38    Buckingham Place, line 179
# people:Annabel Fuglsang    M    40    Haley Street, line 176
# vehicles:Owner: Oluwasegun Annabel
# vehicles:Owner: Annabel Church
# vehicles:Owner: Annabel Sun
# vehicles:Owner: Annabel Fuglsang

# There's no Annabel with membership to all 4 of the ones above, so Annabel is ruled out
# we got 3 Annabel named females, let's read their interviews

# output from line 40 from top, then get only first line
tail -n +40 streets/Hart_Place | head -n 1
# SEE INTERVIEW #47246024

cat interviews/interview-47246024
# Ms. Sun has brown hair and is not from New Zealand.  Not the witness from the cafe.

tail -n +179 streets/Buckingham_Place | head -n 1
# SEE INTERVIEW #699607

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"

# now we need to search people via their vehicle details for which i wrote this piped command
# it searches based on the vehicle details and height > 6'
# i've used -B/-A before/after flags to print lines before/after the matching line
grep -A 6 "L337" vehicles | grep -B 1 -A 5 Honda | grep -B 2 -A 4 Blue | grep -B 4 -A 2 "6'"
# License Plate L337QE9
# Make: Honda
# Color: Blue
# Owner: Erika Owens
# Height: 6'5"
# Weight: 220 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

# now we'll read interviews for all these 4 people using the commands we had used above to find their interview files
# we'll read Erika's & Jacqui's files as well even though they're possibly female names

grep "Erika Owens" people
# Erika Owens    F    56    Trapelo Street, line 98

tail -n +98 streets/Trapelo_Street | head -n 1
# SEE INTERVIEW #5455315

# we'll do the same for others and finally we get for each of them
# Erika Owens: Owens has an alibi for the morning in question, she was in Toronto for the Mozilla All Hands Meeting.  Multiple sources, including a person in a fox costume, corroborate this.  Not a suspect.
# Joe Germuska: Should not be considered a suspect, has no SkyMiles membership and has never been a member of the Museum of Bash History.
# Jeremy Bowers: Home appears to be empty, no answer at the door. After questioning neighbors, appears that the occupant may have left for a trip recently. Considered a suspect until proven otherwise, but would have to eliminate other suspects to confirm.
# Jacqui Maher: Maher is not considered a suspect.  Video evidence confirms that she was away at a professional soccer game on the morning in question, even though it was a workday.

# only 2 of them were male of which only Jeremy Bowers is still a suspect but we need hard evidence to prove if he's the perpetrator
# since Joe Germuska was ruled out cuz of his memberships, let's check Jeremy Bowers' memberships

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

# BOOM! We've caught him.

cd ../

echo "Jeremy Bowers" | $(command -v md5 || command -v md5sum) | grep -qif /dev/stdin encoded && echo CORRECT\! GREAT WORK, GUMSHOE. || echo SORRY, TRY AGAIN.
# CORRECT! GREAT WORK, GUMSHOE.

Well, that was fun. How would you have approached this investigation? What better commands would you have used? Let us know in the comments below.