Bash Scripting:
Link to challenge:
https://academy.hackthebox.com/module/21/section/123
(log in required)
Class: Tier I | Easy | General
Working Components:
Conditional Execution:
Question: Create an "If-Else" condition in the "For"-Loop of the "Exercise
Script" that prints you the number of characters of the 35th generated value of
the variable "var". Submit the number as the answer.
Answer: 1197735
Command:
“if [ $counter -eq 35 ]
then
echo $var | wc -c
fi”
Arguments, Variables, and Arrays:
Question: Submit the echo statement that would print
"www2.inlanefreight.com" when running the last "Arrays.sh" script.
Answer: echo ${domains[1]}
Comparison Operators:
Question: Create an "If-Else" condition in the "For"-Loop that checks if the
variable named "var" contains the contents of the variable named "value".
Additionally, the variable "var" must contain more than 113,450 characters. If
these conditions are met, the script must then print the last 20 characters of
the variable "var". Submit these last 20 characters as the answer.
Answer: 2paTlJYTkxDZz09Cg==
Command:
if [[ $var == *"$value"* && $(echo "$var" | wc -c) -gt 113450 ]]
then
echo "$(echo "$var" | tail -c 20)"
fi
Script Control:
Flow Control – Loops:
Question: Create a "For" loop that encodes the variable "var" 28 times in
"base64". The number of characters in the 28th hash is the value that must be
assigned to the "salt" variable.
Answer: HTBL00p5r0x
Command:
for i in {1..28}
do
var=$(echo $var | base64)
done
salt=$(echo $var | wc -c)