Box Stats
Box Info | Details |
---|---|
Box Name : | DC 2 |
Series : | DC |
Difficulty : | Easy/Medium |
Release Date : | 22 Mar 2019 |
OS : | GNU/Linux |
Maker : | DCAU |
Download : | DC 2 |
Recommended : | Yes ![]() |
Summary
Hello all, let’s continue the DC series. This box it’s about wordpress exploitation, we enumerate wordpress and we find out 3 users and we start a brute force on them. The users use the same password on the system so we get access using SSH. Once we get shell we have to bypass rbash. Then we can use switch to user jerry and privesc to root is a simple sudo -l exploitation. Let’s pwn it!
PoC
Target IP
Always first step is to find target IP address, i prefer to use the arp-scan
utility. Then we’ll save the IP address in a variable.
1 |
|
Enumeration/Reconnaissance
Now as always let’s continue with a nmap scan.
1 |
|
We can see nmap
tell us an important thing: http-title: Did not follow redirect to http://dc-2/
We have to add dc-2
to our /etc/hosts
file.
For beginners, /etc/hosts
file translate hostnames to IP addresses. In CTF we use it for 2 reasons:
-
It’s easier to remember the box name than remembering the IP address.
-
The main reason it to deal with virtual hosts. Virtual hosts allow us to host multiple domains or sites on a single server. If we browse the box if the raw IP address, the host header won’t be set properly and we’ll end up with a default page or error page.
1 |
|
Now if we visit the website, we can see it loads without errors & is running wordpress:
Since it’s running wordpress, let’s fire up a wpscan.
1 |
|
We have 3 users, perfect. In wordpress menu we can see a flag
that provide us a really important tip!
Let’s use cewl
to generate a custom wordlist.
1 |
|
Shell as tom
Now let’s start a brute force attack on 3 users, using wpscan
.
1 |
|
Perfect, i tried to login as tom using SSH and it worked! But sadly we’re into a restricted shell. A restricted shell only allows us to perform specific system commands.
1 |
|
To understand if we’re into a restricted shell we can simply check which shell we are using:
1 |
|
To bypass that now there are ton of ways we can try, but in CTF there is a common way using vi/vim
:
Execute vi
and type:
1 |
|
Now we’re into bash but we still can’t execute commands.
1 |
|
Seems like PATH
environment variable is broken, i googled for a default PATH
and i found the ubuntu’s default and i used it and it worked!
1 |
|
Shell as jerry
Now we can simply switch to user jerry using the password from the brute force.
1 |
|
Shell as root
Privilege escalation to root is simple, we just have to check sudo -l
that tell us we can execute git
as root.
1 |
|
1 |
|
Reading the flag(s)
1 |
|
Thank You
Thank you for taking the time to read my writeup. If you don’t understand something from the writeup or want to ask me something feel free to contact me through discord(0xatom#8707) or send me a message through twitter 0xatom
Until next time keep pwning hard!