In this box you will learn about:
- Brute-force
- Hash cracking
- Privilege escalation
Connect to the TryHackMe network, and deploy the machine.
Enumerate
How many ports are open? 2
What version of SSH is running? OpenSSH 7.6p1
What version of Apache is running? 2.4.29
Which Linux distribution is running? Ubuntu
Next we'll check out for hidden directories with gobuster
What is the hidden directory? /admin
Always a good idea to check the source code.
We also want to make sure we fully enumerate so we're going to run gobuster again, telling it to look inside the admin directory too.
For the next part, we're needing to brute force the admin login portal we found. In order to do this we'll need the info from the form and the page so let's copy down all the info:
We're also going to need to grab a web request from the Mozilla web tools. Just open the network tab, submit some info into the form and get the request. When we submit some info we should get a response back and we need to grab that info too.
K, so let's break this down a bit 'cause if this is your first time (like me), it was a bit to put together - thank you to Null Byte ( https://null-byte.wonderhowto.com/how-to/hack-like-pro-crack-online-web-form-passwords-with-thc-hydra-burp-suite-0160643/ ):
hydra -l admin -P /usr/share/wordlist/rockyou.txt 10.10.123.199 http-post-form "/admin/index.php:user=^USER^&pass=^PASS^&p=Login:username or password invalid"
Okay so we start with the hydra command and then break each item we gathered out
-l The username we got from the source code on the page
-P The password list we're using (rockyou in this case)
http-post-form use POST to send to the form
The next part is where it gets tricky.
/admin/index.php The page where the form is hosted
user=^USER^ the first part is the form field name we got from the page, the second half is a variable place holder that's passed from the -l switch above
pass=^PASS^ is like the user part but the ^PASS^ variable will be filled from our rockyou.txt list of passwords
p=Login this is the response of bad login we get. The response is held in a <p> html field and we're simply telling this is the Login response
Username or password invalid is the ACTUAL response we get from the server if it fails.
What is the user:password of the admin panel? admin:xavier
When we click on that link we get a text file with an RSA key:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,E32C44CDC29375458A02E94F94B280EA
JCPsentybdCSx8QMOcWKnIAsnIRETjZjz6ALJkX3nKSI4t40y8WfWfkBiDqvxLIm
UrFu3+/UCmXwceW6uJ7Z5CpqMFpUQN8oGUxcmOdPA88bpEBmUH/vD2K/Z+Kg0vY0
BvbTz3VEc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702VC7EpxiHGeJ
mJZ/cDXFDhJ1lBnkF8qhmTQtziEoEyB3D8yiUvW8xRaZGlOQnZWikyKGtJRIrGZv
OcD6BKQSzYoo36vNPK4U7QAVLRyNDHyeYTo8LzNsx0aDbu1rUC+83DyJwUIxOCmd
6WPCj80p/mnnjcF42wwgOVtXduekQBXZ5KpwvmXjb+yoyPCgJbiVwwUtmgZcUN8B
zQ8oFwPXTszUYgNjg5RFgj/MBYTraL6VYDAepn4YowdaAlv3M8ICRKQ3GbQEV6ZC
miDKAMx3K3VJpsY4aV52au5x43do6e3xyTSR7E2bfsUblzj2b+mZXrmxst+XDU6u
x1a9TrlunTcJJZJWKrMTEL4LRWPwR0tsb25tOuUr6DP/Hr52MLaLg1yIGR81cR+W
-----END RSA PRIVATE KEY-----
We use ssh2john to convert it to a hash then use john the ripper to crack.
What is John's RSA Private Key passphrase? rockinroll
Okay so now we should be able to ssh into johns account. First we need to change the permissions on the rsa_id file we downloaded by using
chmod 400 id_rsa
The we use this to connect
ssh john@[ip] -i id_rsa
It will ask you for a password, which we provide from the crack and we're in! Let's cat out the user.txt
user.txt THM{a_password_is_not_a_barrier}
The web flag we got from the /admin login page
web flag THM{brut3_f0rce_is_e4sy}
Let's check what we have sudo to:
Looks like we don't need a password to run cat as admin. So let's just cat out that file
Unfotunately that's not really the way they want us to do it because they want us to find the root password so let's look around for a bit.
Using the same command we can read the /etc/shadow file to get all the password hashes
root:$6$zdk0.jUm$Vya24cGzM1duJkwM5b17Q205xDJ47LOAg/OpZvJ1gKbLF8PJBdKJA4a6M.JYPUTAaWu4infDjI88U9yUXEVgL.:18490:0:99999:7:::
We copy that to a file on our local attack box and then use John to crack it.
What is the root's password? football
We COULD su to root and get the file but we've already got it earlier ;)
root.txt THM{pr1v1l3g3_3sc4l4t10n}
תגובות