| Holiday Hack Challenge 2023 Report | Cody Travis <cwtravis@gmail.com> |
Difficulty: |
|
These "101" style objectives are always time consuming but can be very educational if you are new to the particular subject matter. I consider myself proficient at the Linux command line and this challenge still had me looking at help documentation to get the correct arguments for my commands. I can say I came out the other side of this objective knowing more than going in.
The terminal is separated into a top panel and a bottom panel. The top panel will present a small challenge and the user must execute the appropriate command to satisfy the challenge.
| Task: | Perform a directory listing of your home directory to find a troll and retrieve a present! |
| Command: | ls |
The "ls" command stands for "List Directory" and is a very common command used at the Linux terminal. It will list directory contents as well as file size, permissions, and ownership info.
| Task: | Now find the troll inside the troll. |
| Command: | cat troll_19315479765589239 |
"cat" prints the contents of a file to the terminal.
| Task: | Great, now remove the troll in your home directory. |
| Command: | rm troll_19315479765589239 |
"rm" removes (deletes) a file or files if a wildcard is specified or multiple files are listed.
| Task: | Print the present working directory using a command. |
| Command: | pwd |
pwd means "Print Working Directory". It prints the current working directory to the terminal.
| Task: | Good job but it looks like another troll hid itself in your home directory. Find the hidden troll! |
| Command: | ls -a |
ls lists the contents of a directory. The -a argument means to list all files, including hidden or "dot" files. Those are ones that begin with a period.
| Task: | Excellent, now find the troll in your command history. |
| Command: | cat .bash_history |
The .bash_history file contains a list of the previous commands run for the user. "cat" prints the contents of a file to the terminal.
| Task: | Find the troll in your environment variables. |
| Command: | env |
The env utility prints the environment variables available to the user.
| Task: | Next, head into the workshop. |
| Command: | cd workshop |
cd changes the working directory to the one specified.
| Task: | A troll is hiding in one of the workshop toolboxes. Use "grep" while ignoring case to find which toolbox the troll is in. |
| Command: | grep -i "troll" toolbox_* |
grep is a utility that can search through file contents as well as file/dir names for regular expression matches. It is very powerful and I encourage anyone to check out the help documentation for it.
| Task: | A troll is blocking the present_engine from starting. Run the present_engine binary to retrieve this troll. |
| Command: | chmod +x present_engine && ./present_engine |
chmod modifies the permissions of the specified file. In this case the +x changes the file to be "executable". It can then be run by calling it in the terminal.
| Task: | Trolls have blown the fuses in /home/elf/workshop/electrical. cd into electrical and rename blown_fuse0 to fuse0. |
| Command: | cd /home/elf/workshop/electrical && mv blown_fuse0 fuse0 |
The cd command changes the working directory to the specified one. The mv utility moves a file from one place to another, but can also be used to rename a file.
| Task: | Now, make a symbolic link (symlink) named fuse1 that points to fuse0 |
| Command: | ln -s fuse0 fuse1 |
This command creates a symlink (fuse1) that points to the target file (fuse0).
| Task: | Make a copy of fuse1 named fuse2. |
| Command: | cp fuse1 fuse2 |
The cp utility simply copies a target file (first arg) to a source file (2nd arg).
| Task: | We need to make sure trolls don't come back. Add the characters "TROLL_REPELLENT" into the file fuse2. |
| Command: | echo TROLL_REPELLENT > fuse2 |
The echo command simply prints the argument back to the terminal. The greater than (>) symbol redirects the output of the echo command to a file. In this case fuse2. Double greater than (>>) can be used to append data instead of overwrite it.
| Task: | Find the file somewhere in /opt/troll_den |
| Command: | find /opt/troll_den -iname troll* |
The find utility searches the directory specified for files and directories that match the criteria set by the arguments. In this case the argument -iname is used to search for any file or directory inside the /opt/troll_den directory that has a name (case insensitive) of "troll". It also uses a wildcard that can match names that start with troll too.
| Task: | Find the file somewhere in /opt/troll_den that is owned by the user troll. |
| Command: | find /opt/troll_den -user troll |
This find command uses the -user argument to only search for files (or directories in this case) owned by the user "troll".
| Task: | Find the file created by trolls that is greater than 108 kilobytes and less than 110 kilobytes located somewhere in /opt/troll_den. |
| Command: | find /opt/troll_den -size +108k -size -110k |
This find command uses the -size argument to only search for files that are greater than 108k and below 110k. The plus (+) and minus(-) indicate greater than or less than.
| Task: | List running processes to find another troll. |
| Command: | ps aux |
The ps utility will list running processes and other metadata around running processes. The flags "aux" lists processes owned by all users, user info, and the command that launched it.
| Task: | The 14516_troll process is listening on a TCP port. Use a command to have the only listening port display to the screen. |
| Command: | netstat -l |
netstat is a utility to view statistics around network connections and listening ports. The -l flag is to list only listening processes and their ports.
| Task: | The service listening on port 54321 is an HTTP server. Interact with this server to retrieve the last troll. |
| Command: | curl http://127.0.0.1:54321 |
CURL is a command that can make HTTP requests. It can be useful for making all sorts of web related requests.
| Task: | Your final task is to stop the 14516_troll process to collect the remaining presents. |
| Command: | kill 14491 |
The kill command is a useful way to kill a process by its process ID (pid).