misDIRection is a miscellaneous challenge in hackthebox, the zipped file contains a hidden folder with many subdirectories, and not every subdirectories have a file, the filenames are all unique numbers and a total of 36 of them, there are no contents within the files. This is a clueless challenge to be honest…, I depended on guessing and a bit of intuition to get the flag.
Strategy to own this challenge
- Unzip the contents
unzip misdirection.zip
, the output is important, I copied and pasted the output into a text file.
the output looks like this:
- Check if the files have contents
ls -lAhR . > dir_file.lst
, I realized the files within the directories are all empty, a sample withfile 6
showed that the file is empty as well. Partial output of thels -lAhR
looks like this:/.secret/0: total 0 -rw-r--r-- 1 root root 0 May 3 2018 6 ./.secret/1: total 0 -rw-r--r-- 1 root root 0 May 3 2018 22 -rw-r--r-- 1 root root 0 May 3 2018 30 ./.secret/2: total 0 -rw-r--r-- 1 root root 0 May 3 2018 34 ./.secret/3: total 0 ./.secret/4: total 0 ./.secret/5: total 0 -rw-r--r-- 1 root root 0 May 3 2018 16 ./.secret/6: total 0 ./.secret/7: total 0 ./.secret/8: total 0 ./.secret/9: total 0 -rw-r--r-- 1 root root 0 May 3 2018 36 ./.secret/a: total 0
- With a graphical text editor, I remove the unzip outputs that have “creating: .secret/Z/” and so on, so that I only see those with “extracting: .secret/X/17” because I want to remove things that do not have filename.
- Sort the edit contents according to the filename, the filenames are actually numbers and there is no content within the file, so I sorted from 1 until 36 and the end result is like this (yes manual sorting, if you know a script to help you do this would be good.):
- By the time I sorted all these manually I was brainfucked, the sorted content clearly shows a message, but remember for the challenges there will be a flag that looks like HTB{something_else}, so I wrote a script to make out the message row by row, I do not want to get my brain fuck again:
file = "/root/htb/misdirection/sorted.txt" secret = "" with open(file, "r") as f: data = f.read() for item in data.split(): secret += item[0] print(secret)
The product of the script is this:
- Use
python3 ../tools/misdirection.py | base64 --decode | tee flag.txt
, cat the contents of flag.txt and I got my HTB flag.
Bro, i was stucked w the files. i use tree and then: find -L . -type f -size 0. I write a python script who sort this its exhaustin doing it manually i know. https://pastebin.com/NBBsXDqb