Exam Bash Scripting

Attachment : To solve questions 14 and 15, you need to download the attached files.

FILE NAME matryoshka_bash.zip
PASS hackviser
MD5 b5c6693d3cdf12c56c1dd3cb2a5fc6a8
---------------------------------
FILE NAME decoder_bash.zip
PASS hackviser
MD5 4f9445e7939b6d2797ef3737b75df89a

Question 1: What symbol is used for a single-line comment within a shell script?

==> The Answer : #


Question 2: Shell script files typically have which file extension?

==> The Answer : sh


Question 3: Which of the following variable names is invalid?

  • username
  • _username
  • username2
  • 2username

Question 4: What symbol is used to access a variable?

  • $
  • #
  • &
  • %

Question 5: Which of the following is incorrect for defining an array in the shell?

  • array_name[index]=value
  • declare -a array_name
  • array_name=(value1 value2 … valueN)
  • array_name={value1, value2, … valueN}

Question 6: What is the method to access the first element of an array in the shell?

  • ${arr[1]}
  • ${arr[0]}
  • ${arr[-1]}
  • ${arr[first]}

Question 7: How is an if statement ended in a shell script?

==> The Answer : fi


Question 8: Which condition checks if a number is greater than 10?

  • [ $number -lt 10 ]
  • [ $number -eq 10 ]
  • [ $number -gt 10 ]
  • [ $number -ne 10 ]

Question 9: Which expression checks if a number is even?

  • [ $((number % 2)) -eq 0 ]
  • [ $((number / 2)) -eq 0 ]
  • [ $number -eq 2 ]
  • [ $number % 2 -eq 0 ]

Question 10: What keyword is used to exit the current loop?

==> The Answer : break


Question 11: What keyword is used to skip the current iteration in a loop?

==> The Answer : continue


Question 12: What keyword is used to return a value from a function?

==> The Answer : return


Question 13: What is the syntax for defining a function in shell scripts?

  • myFunc() { commands }
  • def myFunc() { commands }
  • def myFunc: { commands }
  • func myFunc = {commands}

Question 14: What is the password found in the “password.txt” file obtained after extracting the nested zip files within “matryoshka_bash.zip” using shell scripting?

-Tôi dùng scrip như sau :

kai0kid@Kai0Kid:~/Temp$ cat uzip.sh
#!/bin/bash

name=10000

while [ $name -gt 0 ]; do
    echo "[+] Extracting $name.zip ..."
    unzip -o "$name.zip" >/dev/null 2>&1

    name=$((name - 1))

    if [ ! -f "$name.zip" ]; then
        echo "[✓] Hết file ZIP. Dừng lại."
        break
    fi
done
kai0kid@Kai0Kid:~/Temp$ chmod +777 unzip.sh
kai0kid@Kai0Kid:~/Temp$ ./unzip.sh
....

Sau khi giải nén toàn bộ thì sẽ có 1 tệp tin :

kai0kid@Kai0Kid:~/Temp$ cat password.txt
capella
kai0kid@Kai0Kid:~/Temp$

==> The Answer : capella


Question 15: What is the plaintext obtained after successfully running the corrected shell script within “decoder_bash.zip”?

==> The Answer : canopus

Exam Bash Scripting

Author

Kai0Kid

Publish Date

12 - 03 - 2025

License

Unlicensed

Avatar
Kai0Kid

Bạn tìm gì ở tôi ?