MD To PDF
MD To PDF
Even after being a beginner level room, it took me quite some time to drill
down and complete the room. But to be honest, this room made me realize
the importance of enumeration.
As all the questions in this task are based on nmap, we can directly start a
nmap search first and then look at the questions
The answer to this question can be found by directly count the number of
open ports for which nmap has provided the details.
We can see that on what port nginx is running and along with that we are
provided the version of nginx as well.
The questions in this task require us to find hidden pages and files. Hence,
we can start dirb scan beforehand and then use all that information to
answer the questions.
Remember, on our nmap scan we saw two open ports; one for nginx and the
other for apache. So, we can start two different dirb scans for each port.
-----------------
DIRB v2.22
By The Dark Raver
-----------------
-----------------
GENERATED WORDS:
4612
-----------------
END_TIME: Wed Aug 5 04:20:18 2020
DOWNLOADED: 13836 - FOUND: 4
-----------------
DIRB v2.22
By The Dark Raver
-----------------
-----------------
GENERATED WORDS:
4612
-----------------
END_TIME: Wed Aug 5 04:17:13 2020
DOWNLOADED: 4612 - FOUND: 3
From dirb scan for port 80, we can see that a /hidden directory has been
found so we can go and check if we can find something useful over there.
Over there, we can see this one image and nothing else. Not even in the
HTML file.
hidden_dir
hidden_dir
hidden_80
hidden_80
Again, the same thing. There is just an image but this time in the HTML file,
we can see a value named hidden and the == at the end suggest that it is a
base64 encoded file. So, we can decode it as base64 and check what it
actually is. We can use GCHQ CyberChef for decoding.
Once decoded, we can see that we have got our first flag!
As for port 80, no other directories or files were detected (other than
robots.txt which did not contain anything useful) we can now move on to the
dirb results from port 65524.
We can also check the homepage that is hosted on port 65524 which
appears to be the default Apache page and hence, we can say that there is
nothing useful here.
In the dirb scan results for port 65524, another robots.txt was detected.
So, we can go and check this as well. There we can see one really odd kind
of an user-agent specified.
User-Agent:*
Disallow:/
Robots Not Allowed
User-Agent:a18672860d0510e5ab6699730763b250
Allow:/
This Flag Can Enter But Only This Flag No More Exceptions
tester@kali:~/Desktop$ hash-identifier
#########################################################################
# __ __ __ ______
_____ #
# /\ \/\ \ /\ \ /\__ _\ /\ _
`\ #
# \ \ \_\ \ __ ____ \ \ \___ \/_/\ \/ \ \ \/\
\ #
# \ \ _ \ /'__`\ / ,__\ \ \ _ `\ \ \ \ \ \ \
\ \ #
# \ \ \ \ \/\ \_\ \_/\__, `\ \ \ \ \ \ \_\ \__ \ \
\_\ \ #
# \ \_\ \_\ \___ \_\/\____/ \ \_\ \_\ /\_____\ \
\____/ #
# \/_/\/_/\/__/\/_/\/___/ \/_/\/_/ \/_____/ \/
___/ v1.2 #
#
By Zion3R #
#
www.Blackploit.com #
#
[email protected] #
#########################################################################
--------------------------------------------------
HASH: a18672860d0510e5ab6699730763b250
Possible Hashs:
[+] MD5
[+] Domain Cached Credentials - MD4(MD4(($pass)).
(strtolower($username)))
And we can see that it has been detected as possible MD5 or MD4 hash. We
can not look for some online md5 cracker tools and try to crack this hash. I
tried various websites but was not able to crack it until I found this website.
After select MD5 as the hash type and passing on the hash value, we can see
in the result that we now have flag 2 as well.
So with this, we got all the 3 flags but now the important part begins which
is gaining access to the machine.
1. Locate flag 3.
Check Task 2, Question 2 for the solution as it was found before flag 2.
We have browsed all the pages that were detected by dirb on both port 80
and 65524 but we did not find any hidden directory that gets accepted as
the solution to this question. Which means we have not observed something
that was present in the detected pages.
We can go through all the pages and directories that have been detected to
find out what we have missed. From the pages on port 80, we can’t find
anything. But on the index.html page on port 65524 from where we got our
third flag, we missed one important detail:
hidden_65524
hidden_65524
This value again appears to be some sort of hashed value or encoded value.
But in the statement, it is written that ‘its encoded with ba….:’ which
suggests that this is some sort of baseX encoded data. So, we can go back to
CyberChef and try different base encoding methods and determine which
one decodes this string. After multiple trials and errors with various base
encoding method, we can determine that this is the hidden directory
encoded using base62.
1. Using the file found in the hidden directory, find and crack a password
hidden in the file.
creds_crack
creds_crack
It can be seen that there is one full-screen background image on top which
there is another image named “binarycodepixabay.jpg” and below that
another text string. First, we can look at the string. Again, this appears like
a hash, so we can send it to hash-identifier.
tester@kali:~/Desktop$ hash-identifier
#########################################################################
# __ __ __ ______
_____ #
# /\ \/\ \ /\ \ /\__ _\ /\ _
`\ #
# \ \ \_\ \ __ ____ \ \ \___ \/_/\ \/ \ \ \/\
\ #
# \ \ _ \ /'__`\ / ,__\ \ \ _ `\ \ \ \ \ \ \
\ \ #
# \ \ \ \ \/\ \_\ \_/\__, `\ \ \ \ \ \ \_\ \__ \ \
\_\ \ #
# \ \_\ \_\ \___ \_\/\____/ \ \_\ \_\ /\_____\ \
\____/ #
# \/_/\/_/\/__/\/_/\/___/ \/_/\/_/ \/_____/ \/
___/ v1.2 #
#
By Zion3R #
#
www.Blackploit.com #
#
[email protected] #
#########################################################################
--------------------------------------------------
HASH:
940d71e8655ac41efb5f8ab850668505b86dd64186a66e57d1483e7f5fe6fd81
Possible Hashs:
[+] SHA-256
[+] Haval-256
This time the possible hashing methods that detected are SHA-256 and
Haval-256. So, we can go back to the same hash cracker website that we
used earlier and crack the hash. But even after multiple attempts, the hash
does not get cracked either as SHA-256 nor Haval-256. We can even the
least possible hashing methods.
When we select GHOST hashing method in hash type and pass our hash
value then the hash gets cracked. The cracked values appear to be the
password of something but what we don’t know yet.
But for now, this password can be submitted as the answer to this question.
Now, the secrettext.txt file we can get the username and the password
which is stored in binary.
So, we can again head back to GCHQ and convert this binary data to text to
get the password for this account. Also, this password can be submitted as
the answer to this question.
Now that we have both the username and password, we can easily access
the machine via SSH. But one thing to remember here is that the SSH was
not running on the default port 22 but some other custom port. So, while
connecting we need to mention that port number as well.
And we get the user flag (partially) but not in the exact state. It is also
mentioned in the user.txt file that the flag has been rotated. So, we can go
to CyberChef and rotate the flag using ROT13and get our desired flag!
We are already at the user level, so we just need to escalate ourselves to the
root level in order to gain root-level access on the machine.
As a regular process, we can check the /etc/passwd file, run sudo-l and
check /etc/crontab. We don’t find any useful information from the passwd
file and also we are not allowed to run any commands as sudo on this
machine. But in /etc/crontab we can find a job running every minute that
too with root as user:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
We can further check and confirm that we have access to this /var/
www/.mysecretcronjob.sh and also that we can modify it. So, now we can
simply enter the command cat /root/root.txt > /tmp/flag in this shell
file.
Also, we need to make a new file named flag in /tmp directory and change
it’s permissions so that root can write to it using the command: chmod 660
flag. We can wait for some time and then check the content of the flag file.
boring@kral4-PC:/tmp$ cd ..
boring@kral4-PC:/$ cd /tmp
boring@kral4-PC:/tmp$ touch flag
boring@kral4-PC:/tmp$ chmod 660 flag
boring@kral4-PC:/tmp$ nano /var/www/.mysecretcronjob.sh
In nano, we can add the command cat /root/root.txt > /tmp/flag and
save it. Once, all these steps are performed, we can wait for a minute so that
the cronjob gets executed and the flag gets printed to our /tmp/flag file.
But even after waiting for some considerable time, nothing gets printed to
the file. So, we need to check if the file root.txt is actually present at the
location or so. This can be done by adding the command: ls -la /root > /
tmp/flag to /var/www/.mysecretcronjob.sh and again wait for sometime
to see the output.
Here, we can see that the file has been named as .root.txt so we need to
change our previous command a little bit like: cat /root/.root.txt > /
tmp/flag and again wait for some time.
With this, we will get the root flag as well as complete the room!
As I said earlier, there was a lot of enumeration involved at the beginning to
gain the initial foothold whereas the privilege escalation part was pretty
simple. We could have used payloads to get a reverse shell as well if we
wanted to by exploiting the shell file.