Professional Documents
Culture Documents
Scenario
You have just been hired by Lucky Duck Casino as a security analyst.
● Lucky Duck has lost a significant amount of money on the roulette tables over the
last month.
● The largest losses occurred on March 10, 12, and 15.
● Your manager believes there is a player working with a Lucky Duck dealer to
steal money at the roulette tables.
● The casino has a large database with data on wins and losses, player analysis,
and dealer schedules.
● You are tasked with navigating, modifying, and analyzing these data files to
gather evidence on the rogue player and dealer.
● You will prepare several evidence files to assist the prosecution.
● You must work quickly as Lucky Duck can't afford any more losses.
Lucky Duck Casino has provided you with the following files if required:
Note: The instructions ask you to set up the files using a wget command, but the files
are also provided in compressed zip format if the command does not work.
Lab Environment
● You will use your local Vagrant virtual machine for today's activities. Please note
that instructors and students have different access credentials.
○ Username: sysadmin
○ Password: cybersecurity
Instructions
Use your command-line skills to uncover the identities of the rogue casino player and
dealer colluding to scam Lucky Duck out of thousands of dollars.
After your investigation, you will provide a summary of your findings to the casino.
mkdir Lucky_Duck_Investigations
cd Lucky_Duck_Investigations
mkdir Roulette_Loss_Investigation
cd Roulette_Loss_Investigation
# build bash script
nano crnts.sh
#Inside crnts.sh stores command
#!/bin/bash
mkdir Player_Analysis
cd Player_Analysis
touch Notes_Player_Analysis
cd ..
mkdir Dealer_Analysis
cd Dealer_Analysis
touch Notes_Dealer_Analysis
cd ..
mkdir Player_Dealer_Correlation
cd Player_Dealer_Correlation
touch Notes_Player_Dealer_Correlation
#save crnts.sh by ^x + Y + return
sh crnts.sh
ls
cd ..
wget "https://tinyurl.com/3-HW-setup-evidence" && chmod +x ./3-HW-setup-evidence && ./3-
HW-setup-evidence
#recheck step
ls
3-HW-setup-evidence Dealer_Schedules_0310 Roulette_Loss_Investigation
Roulette_Player_WinLoss_0310
cd Dealer_Schedules_0310
ls
0310_Dealer_schedule 0312_Dealer_schedule 0314_Dealer_schedule 0316_Dealer_schedule
0311_Dealer_schedule 0313_Dealer_schedule 0315_Dealer_schedule 0317_Dealer_schedule
cd ..
cd Roulette_Player_WinLoss_0310
ls
0310_win_loss_player_data 0312_win_loss_player_data 0314_win_loss_player_data
0316_win_loss_player_data
0311_win_loss_player_data 0313_win_loss_player_data 0315_win_loss_player_data
0317_win_loss_player_data
#recheck step
cd ..
cd Roulette_Loss_Investigation/Dealer_Analysis
ls
0310_Dealer_schedule 0312_Dealer_schedule 0315_Dealer_schedule Notes_Dealer_Analysis
cd ..
cd Player_Analysis
ls
0310_win_loss_player_data 0312_win_loss_player_data 0315_win_loss_player_data
Notes_Player_Analysis
Note: Winnings for Lucky Duck Casino are indicated with a positive number and losses
are indicated with a negative number.
cd Roulette_Loss_Investigation/Player_Analysis
# build bash script
nano badguy.sh
#Inside badguy.sh stores command
#!/bin/bash
cat 03* | grep - > Roulette_Losses
cat 03* | grep "Mylie Schmidt" | wc -l
#save badguy.sh by ^x + y + return
sh badguy.sh
Complete the dealer analysis.
cd ..
cd Dealer_Analysis
2. This file contains the dealer schedules for the various Lucky Duck casino games:
Blackjack, Roulette, and Texas Hold 'Em.
○ Preview the schedule to view the format and to understand how the data
is separated.
#recheck
ls
0310_Dealer_schedule 0312_Dealer_schedule 0315_Dealer_schedule
Notes_Dealer_Analysis
cat 0310_Dealer_schedule = 0312_Dealer_schedule = 0315_Dealer_schedule
3. Using your findings from the player analysis, create a separate script to look at
each day and time that you determined losses occurred. Use awk, pipes, and
grep to isolate out the following four fields:
○ Time
○ a.m./p.m.
○ First name of roulette dealer
○ Last name of roulette dealer
For example, if a loss occurred on March 10 at 2 p.m., you would write one script
to find the roulette dealer who was working at that specific day and time.
○ Hint: You will have many scripts, but only a small change is required for
each script.
4. Run all of the scripts and append those results to a file called
Dealers_working_during_losses.
nano 0312_Dealers_Loss.sh
#Inside 0312_Dealers_Loss.sh stores command
#!/bin/bash
echo "March 12"
awk '/0[58].+ AM|(0[28]|11).+ PM/ {print $1,$2,$5,$6}' 0312_Dealer_schedule
#save nano 0310_Dealers_Loss.sh by ^x + y + return
sh 0312_Dealers_Loss.sh
nano 0315_Dealers_Loss.sh
#Inside 0315_Dealers_Loss.sh stores command
#!/bin/bash
echo "March 15"
awk '/0[58].+ AM|02.+ PM/ {print $1,$2,$5,$6}' 0315_Dealer_schedule
#save nano 0310_Dealers_Loss.sh by ^x + y + return
sh 0315_Dealers_Loss.sh
sh 0310_Dealers_Loss.sh > Dealers_working_during_losses
sh 0312_Dealers_Loss.sh >> Dealers_working_during_losses
sh 0315_Dealers_Loss.sh >> Dealers_working_during_losses
cat Dealers_working_during_losses
SUMMARY
According to all information, during the Roulette Games when a major loss occurred, Mylie
Schmidt was the one who plays at the table, and the dealer worker at these times was Billy
Jones. So, it is a high possibility that the two of them are colluding to scam Lucky Duck Casino.
INFORMATION:
The primary dealer working at the times where losses occurred:
ANS = Billy Jones
They tasked you with building a shell script that can easily analyze future employee
schedules. They will use this to determine which employee was working at a specific
time in the case of future losses.
nano roulette_dealer_finder_by_time.sh
#Inside nano roulette_dealer_finder_by_time.sh store commands
#!/bin/bash
#the time
time=${2//[!0-9]/}
#AM/PM
clock='AM'
if [[ "$2" == *'p'* ]]; then
clock='PM'
fi
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$5,$6}'
#save nano roulette_dealer_finder_by_time.sh by ^x + y + return
2. Test your script on the schedules to confirm it outputs the correct dealer at the
time specified.
Bonus https://stackoverflow.com/questions/24752120/bash-reduce-comparing-line-to-short-
way/24754997#24754997
https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
● In case there is future fraud on the other Lucky Duck games, create a shell script
called roulette_dealer_finder_by_time_and_game.sh that has the three
following arguments:
○ Specific time
○ Specific date
○ Casino game being played
Hint: The argument does not need to name the specific casino game.
nano roulette_dealer_finder_by_time_and_game.sh
#Inside roulette_dealer_finder_by_time_and_game.sh stores command
#!/bin/bash
#time
time=${2//[!0-9]/}
#AM or PM
clock='AM'
if [[ "$2" == *'p'* ]]; then
clock='PM'
fi
#case-insensitive
shopt -s nocasematch
#match game and print
if [[ "BlackJack" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$3,$4}'
else
if [[ "Roulette" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$5,$6}'
else
if [[ "Texas Hold Em" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$7,$8}'
fi
fi
fi
#save roulette_dealer_finder_by_time_and_game.sh by ^x + y + return
Notes_Player_Analysis
Notes_Dealer_Analysis
Notes_Player_Dealer_Correlation
○ Evidence files:
■ Roulette_Losses
■ Dealers_working_during_losses
○ Shell script(s)
0310_Dealers_Loss.sh
#Inside 0310_Dealers_Loss.sh stores command
#!/bin/bash
echo "March 10"
awk '/0[58].+ AM|(0[28]|11).+ PM/ {print $1,$2,$5,$6}' 0310_Dealer_schedule
#save 0310_Dealers_Loss.sh by ^x + y + return
0312_Dealers_Loss.sh
#Inside 0312_Dealers_Loss.sh stores command
#!/bin/bash
echo "March 12"
awk '/0[58].+ AM|(0[28]|11).+ PM/ {print $1,$2,$5,$6}' 0312_Dealer_schedule
#save 0312_Dealers_Loss.sh by ^x + y + return
0315_Dealers_Loss.sh
#Inside 0315_Dealers_Loss.sh stores command
#!/bin/bash
echo "March 15"
awk '/0[58].+ AM|02.+ PM/ {print $1,$2,$5,$6}' 0315_Dealer_schedule
#save 0315_Dealers_Loss.sh by ^x + y + return
Roulette_dealer_finder_by_time.sh
#Inside Roulette_dealer_finder_by_time.sh stores command
#!/bin/bash
# usage: ./roulette_dealer_finder_by_time.sh [DATE] [TIME]
# example: ./roulette_dealer_finder_by_time.sh 0310 02p.m.
# this script outputs the name of dealer at the time and date specified
roulette_dealer_finder_by_time_and_game.sh
#Inside roulette_dealer_finder_by_time_and_game.sh stores command
#!/bin/bash
# usage: ./roulette_dealer_finder_by_time_and_game.sh [DATE] [TIME] [GAME]
# example: ./roulette_dealer_finder_by_time_and_game.sh 0310 02p.m. roulette
# this script outputs the name of dealer at the time, date and game specified
#extract the time from the argument
time=${2//[!0-9]/}
#extract AM/PM value
clock='AM'
if [[ "$2" == *'p'* ]]; then
clock='PM'
fi
# turn on case insensitive match
shopt -s nocasematch
# match the game and print corresponding fields
if [[ "BlackJack" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$3,$4}'
else
if [[ "Roulette" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$5,$6}'
else
if [[ "Texas Hold Em" =~ .*"$3".* ]]; then
cat $1_Dealer_schedule | grep $time | grep $clock | awk '{print $1,$2,$7,$8}'
fi
fi
fi
#save roulette_dealer_finder_by_time_and_game.sh by ^x + y + return