Skip to content

Commit 5c8b397

Browse files
committed
Update scripts to dynamically pull files
1 parent bd38376 commit 5c8b397

File tree

8 files changed

+232
-87
lines changed

8 files changed

+232
-87
lines changed

README.md

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
# Machine Set-Up
22

3-
## The Easy Way
3+
## The Easy Way (`install_tool.sh`)
44

5-
- **Get a fresh linux VM with the following specs:**
5+
- **Get a fresh linux VM with the following minimum specs:**
66
- Ubuntu Server 20.04 LTS
77
- 2 cores
88
- 4GB RAM
99
- 128GB Standard SSD
1010

11-
- **Download this Repo, extract into `~` so that `~/Scripts` and `~/Files` are valid paths**
12-
- **From the `~` directory, run script: `./Scripts/setup.sh`**
13-
- This will install all the tools and place all the files needed for the course
11+
- **Download and run the `install_tool.sh` script**
12+
- This script will install all the tools and place all the files needed for the course
1413
- This might take a while (est 30-45m), so open Youtube or something
15-
- You will need to press `enter` between each script -- this is so if you need to stop, you can!
16-
- The script **is** safe to run multiple times if you need to stop and start again
14+
- You will be able to choose between installing all units or just one unit at a time
1715

18-
## The Hard Way
16+
## The Hard Way (Manual Set-Up)
1917

2018
### RDP Setup
2119

@@ -37,17 +35,11 @@
3735

3836
### Unit 2: Lab
3937

40-
- N/A - Students install their account-specific Wazuh agents during lab
38+
- N/A - Students download files during lab
4139

4240
### Unit 2: Project
4341

44-
- Run script: `~/scripts/unit2_project.sh`
45-
- Tool(s) installed: N/A - Same as lab
46-
- Files placed:
47-
- `/etc/wazuh/static.txt`
48-
- `/etc/wazuh/thisisit.txt`
49-
- `attack-part1`
50-
- `attack-part2`
42+
- N/A - Students download files during project
5143

5244
### Unit 3: Lab
5345

@@ -120,21 +112,11 @@ ftp_project
120112

121113
### Unit 7: Lab
122114

123-
- Run script: `~/scripts/unit7_lab.sh`
124-
- Tool(s) installed: `MISP`
125-
- Files placed: None
126-
127-
#### 🚨 Manual Steps
128-
129-
- Login to 127.0.0.1 on the local machine (No port needed)
130-
- Change the user/password from `[email protected]/admin` to `[email protected]/Codepath123!`
131-
- Click on `Sync Actions` > `Load Default Feed Metadata` > `Fetch and Store all feed data`
132-
- Check all the options and select `Cache All Feeds`
133-
- (Note: This is NOT the blue button that says `Fetch and store all feed Data`!)
115+
- N/A - Students download files during lab
134116

135117
### Unit 7: Project
136118

137-
- N/A - Same as Lab
119+
- N/A - Students download files during project
138120

139121
### Unit 8+
140122

Scripts/setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/bin/bash
22

3+
# Check if wget is installed
4+
if ! command -v wget &> /dev/null; then
5+
echo -e "Installing wget..."
6+
sudo apt install -y wget
7+
fi
8+
39
# Call the rdp_setup.sh script
410
./Scripts/rdp_setup.sh
511

Scripts/unit1_lab.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
red='\033[0;31m'
33
green='\033[0;32m'
44
none='\033[0m'
5+
scripts_repo="https://raw.githubusercontent.com/codepath/cyb102-vm-setup/main/Files/"
56

67
echo "[UNIT 1 LAB] Starting script..."
78

@@ -32,14 +33,26 @@ else
3233
exit 1
3334
fi
3435

35-
# Move everything in ../Files/lab-1 to ~ and rename it to lab_1
36-
if [ -e ~/lab_1 ]; then
37-
echo -e "${green}[UNIT 1 LAB]${none} lab_1 already exists."
36+
# Download the required files into the lab_1 directory
37+
if [ -e "$HOME/lab_1/SMTP.pcap" ]; then
38+
echo -e "${green}[UNIT 1 LAB]${none} Files already found at ~/lab_1."
3839
else
39-
if [ -e ~/Files/lab-1 ]; then
40-
sudo mv ~/Files/lab-1 ~/lab_1 && echo -e "${green}[UNIT 1 PROJECT]${none} Moved lab 1 files to ~/lab_1"
41-
else
42-
echo -e "${red}[UNIT 1 LAB]${none} Error: Directory ~/Files/lab-1 does not exist."
40+
# Ensure the lab_1 directory exists
41+
if [ ! -d "$HOME/lab_1" ]; then
42+
mkdir -p "$HOME/lab_1"
43+
fi
44+
45+
# Download the files
46+
wget "${scripts_repo}unit1/DHCP.txt" -O "$HOME/lab_1/DHCP.txt"
47+
wget "${scripts_repo}unit1/Security_log.rtf" -O "$HOME/lab_1/Security_log.rtf"
48+
wget "${scripts_repo}unit1/SMTP.pcap" -O "$HOME/lab_1/SMTP.pcap"
49+
50+
# Verify download was successful
51+
if ! [ "$HOME/lab_1/SMTP.pcap" ]; then
52+
echo -e "${red}[UNIT 1 LAB]${none} Error: Could not download files to $HOME/lab_1 folder"
53+
echo -e "${red}[UNIT 1 LAB]${none} Try downloading manually from ${scripts_repo}unit1 and placing in ~/lab_1."
4354
exit 1
55+
else
56+
echo -e "${green}[UNIT 1 LAB]${none} Files downloaded successfully."
4457
fi
4558
fi

Scripts/unit3_project.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
red='\033[0;31m'
33
green='\033[0;32m'
44
none='\033[0m'
5+
scripts_repo="https://raw.githubusercontent.com/codepath/cyb102-vm-setup/main/Files/"
56

67
echo "[UNIT 3 PROJECT] Starting script..."
78

@@ -30,14 +31,20 @@ else
3031
fi
3132
fi
3233

33-
# Move everything in ../Files/ftp-3 to ~ and rename it to ftp_folder
34+
# Download the required files into the lab_1 directory
3435
if [ -e ~/ftp_folder ]; then
3536
echo -e "${green}[UNIT 3 PROJECT]${none} ftp_folder already exists."
3637
else
37-
if [ -e ~/Files/ftp-3 ]; then
38-
sudo mv ~/Files/ftp-3 ~/ftp_folder && echo -e "${green}[UNIT 3 PROJECT]${none} Moved ftp-3 files to ~/ftp_folder"
39-
else
40-
echo -e "${red}[UNIT 3 PROJECT]${none} Error: File ~/Files/ftp-3 does not exist."
38+
# Download the files
39+
wget "${scripts_repo}unit3/ftp_folder.zip" -O "$HOME/ftp_folder.zip"
40+
unzip ~/ftp_folder.zip -d ~/
41+
42+
# Verify download was successful
43+
if ! [ "$HOME/ftp_folder" ]; then
44+
echo -e "${red}[UNIT 3 PROJECT]${none} Error: Could not download files to $HOME/ftp_folder"
45+
echo -e "${red}[UNIT 3 PROJECT]${none} Try downloading manually from ${scripts_repo}unit3/ftp_folder.zip and placing in $HOME."
4146
exit 1
47+
else
48+
echo -e "${green}[UNIT 3 PROJECT]${none} Files downloaded successfully."
4249
fi
43-
fi
50+
fi

Scripts/unit5_lab.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
red='\033[0;31m'
33
green='\033[0;32m'
44
none='\033[0m'
5+
scripts_repo="https://raw.githubusercontent.com/codepath/cyb102-vm-setup/main/Files/"
56

67
echo "[UNIT 5 LAB] Starting script..."
78

@@ -44,14 +45,31 @@ EOF
4445
fi
4546
fi
4647

47-
# Add data to Splunk
48+
######## Add data to Splunk
49+
50+
# Ensure the tmp_splunk directory exists
51+
if [ ! -d "$HOME/tmp_splunk" ]; then
52+
mkdir -p "$HOME/tmp_splunk"
53+
fi
54+
55+
# Download the files
56+
wget "${scripts_repo}unit5/netflix_titles.csv" -O "$HOME/tmp_splunk/netflix_titles.csv"
57+
wget "${scripts_repo}unit5/Top Video Game sales.csv" -O "$HOME/tmp_splunk/Top Video Game sales.csv"
58+
wget "${scripts_repo}unit5/webauth.csv" -O "$HOME/tmp_splunk/webauth.csv"
59+
60+
# Verify download was successful
61+
if ! [ "$HOME/tmp_splunk/webauth.csv" ]; then
62+
echo -e "${red}[UNIT 1 LAB]${none} Error: Could not download Splunk files to $HOME/tmp_splunk folder"
63+
echo -e "${red}[UNIT 1 LAB]${none} Try downloading manually from ${scripts_repo}unit5 and placing in ~/tmp_splunk."
64+
exit 1
65+
fi
4866

4967
# Paths of the CSV files you want to add to Splunk for index "main" and their associated hostnames.
5068
declare -A MAIN_DATA
5169
MAIN_DATA=(
52-
["Files/Splunk-5-6-7/netflix_titles.csv"]="Netflix"
53-
["Files/Splunk-5-6-7/Top Video Game sales.csv"]="SalesData"
54-
["Files/Splunk-5-6-7/webauth.csv"]="WebServer01"
70+
["$HOME/tmp_splunk/netflix_titles.csv"]="Netflix"
71+
["$HOME/tmp_splunk/Top Video Game sales.csv"]="SalesData"
72+
["$HOME/tmp_splunk/webauth.csv"]="WebServer01"
5573
)
5674

5775
# Name of the main index you want to add data to.

Scripts/unit5_project.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,30 @@
22
red='\033[0;31m'
33
green='\033[0;32m'
44
none='\033[0m'
5+
scripts_repo="https://raw.githubusercontent.com/codepath/cyb102-vm-setup/main/Files/"
56

67
echo "[UNIT 5 PROJECT] Starting script..."
78

9+
# Ensure the tmp_splunk directory exists
10+
if [ ! -d "$HOME/tmp_splunk" ]; then
11+
mkdir -p "$HOME/tmp_splunk"
12+
fi
13+
14+
# Download the files
15+
wget "${scripts_repo}unit5/webserver02.csv" -O "$HOME/tmp_splunk/webserver02.csv"
16+
wget "${scripts_repo}unit5/uploadedhashes.csv" -O "$HOME/tmp_splunk/uploadedhashes.csv"
17+
wget "${scripts_repo}unit5/failedlogins64.csv" -O "$HOME/tmp_splunk/failedlogins64.csv"
18+
wget "${scripts_repo}unit5/BlueCoatProxy01.csv" -O "$HOME/tmp_splunk/BlueCoatProxy01.csv"
19+
20+
# Verify download was successful
21+
if ! [ "$HOME/tmp_splunk/BlueCoatProxy01.csv" ]; then
22+
echo -e "${red}[UNIT 1 LAB]${none} Error: Could not download Splunk files to $HOME/tmp_splunk folder"
23+
echo -e "${red}[UNIT 1 LAB]${none} Try downloading manually from ${scripts_repo}unit5 and placing in ~/tmp_splunk."
24+
exit 1
25+
fi
26+
827
# Paths of the CSV files you want to add to Splunk for index "pathcode".
9-
PATHCODE_CSV_FILE_PATHS=("Files/Splunk-5-6-7/webserver02.csv" "Files/Splunk-5-6-7/uploadedhashes.csv" "Files/Splunk-5-6-7/failedlogins64.csv" "Files/Splunk-5-6-7/BlueCoatProxy01.csv")
28+
PATHCODE_CSV_FILE_PATHS=("$HOME/tmp_splunk/webserver02.csv" "$HOME/tmp_splunk/uploadedhashes.csv" "$HOME/tmp_splunk/failedlogins64.csv" "$HOME/tmp_splunk/BlueCoatProxy01.csv")
1029

1130
# Name of the second index you want to add data to.
1231
PATHCODE_INDEX_NAME="pathcode"

Scripts/unit7_lab.sh

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,5 @@
11
#!/bin/bash
2-
red='\033[0;31m'
3-
green='\033[0;32m'
4-
yellow='\033[33m'
52
none='\033[0m'
6-
7-
warn () {
8-
echo -e "${yellow}[UNIT 7 LAB]${none} MANUAL INSTALL STEPS NEEDED:"
9-
echo -e " Login to 127.0.0.1 on the local machine (No port needed)"
10-
echo -e " Change the password from [email protected]/admin to [email protected]/Codepath123!"
11-
echo -e " Click on 'Sync Actions' > 'Feeds' > 'Load Default Feed Metadata' > 'Fetch and Store all feed data'"
12-
echo -e " Check all the options and select 'Cache All Feeds'"
13-
echo -e " (Note: This is NOT the blue button that says 'Fetch and store all feed Data'!)"
14-
}
3+
green='\033[0;32m'
154
echo "[UNIT 7 LAB] Starting script..."
16-
17-
# Make sure we are not root
18-
if [ "$EUID" -eq 0 ]
19-
then echo "Please do not run as root"
20-
exit
21-
fi
22-
23-
if systemctl is-active --quiet misp-modules; then
24-
echo -e "${green}[UNIT 7 LAB]${none} MISP is already installed."
25-
warn
26-
exit 0
27-
fi
28-
29-
# Create a new user 'misp'
30-
sudo adduser --disabled-password --gecos "" misp
31-
32-
# Download the MISP installation script
33-
wget --no-cache -O /tmp/INSTALL.sh https://raw.githubusercontent.com/MISP/MISP/2.4/INSTALL/INSTALL.sh
34-
35-
# Run the MISP installation script
36-
bash /tmp/INSTALL.sh -c -M
37-
38-
if systemctl is-active --quiet misp-modules; then
39-
echo -e "${green}[UNIT 7 LAB]${none} MISP installed correctly"
40-
else
41-
echo -e "${red}[UNIT 7 LAB]${none} ERROR: MISP did not install correctly!"
42-
exit 1
43-
fi
44-
warn
5+
echo -e "${green}[UNIT 7 LAB]${none} N/A - Nothing required for this lab."

0 commit comments

Comments
 (0)