In this walkthrough, we will be going through Bash Scripting room by Tryhackme. This covers the basics of bash scripting covering topics like variables, parameters and some test scripts to work on. After completing this room, you will be able to develop basic scripts in bash which can help you in automating the mundane tasks related to cyber. So, let’s get started.
Task 1 – Introduction
Question 1 – Are you ready to go!
Task 2 – Our first simple bash scripts
Question 1 – What piece of code can we insert at the start of a line to comment out our code?
Question 2 – What will the following script output to the screen, echo “BishBashBosh”
Task 3 – Variables
Question 1 – What would this code return?
Jammy is 21 years old
Question 2 – How would you print out the city to the screen?
Question 3 – How would you print out the country to the screen?
Task 4 – Parameters
Question 1 – How can we get the number of arguments supplied to a script?
Question 2 – How can we get the filename of our current script(aka our first argument)?
Question 3 – How can we get the 4th argument supplied to the script?
Question 4 – If a script asks us for input how can we direct our input into a variable called ‘test’ using “read”
Question 5 – What will the output of “echo $1 $3” if the script was ran with “./script.sh hello hola aloha”
Task 5 – Arrays
Question 1 – What would be the command to print audi to the screen using indexing.
Question 2 – If we wanted to remove tesla from the array how would we do so?
Question 3 – How could we insert a new value called toyota to replace tesla?
Task 6 – Conditionals
Question 1 – What is the flag to check if we have read access to a file?
Question 2 – What is the flag to check to see if it’s a directory?
Task 7 – Further reading
Also Read: Tryhackme – Anonymous
So that was it. This was an introductory room to covers the basics of the Bash scripting which will definitely come in handy in automation. Try to make some scripts that automate your enumeration and information gathering flow. On that note, i will take your leave for the next time, till then “Keep Scripting!!!”.