凭据注入

当我们找到一个凭证后我们应该如何利用呢?

Runas 可以帮你解决这个问题。

当我们有一个 AD 的凭证时,我们可以在目标上运行 Runas ,将凭证注入内存中:

  1. runas.exe /netonly /user:<domain>\<username> cmd.exe
  • /netonly :
  • /user : 提供域和用户的信息
  • cmd.exe : 注入凭证后运行的程序

验证

当我们提供了密码进行登录后,我们如何验证我们的凭据是否正常工作,最可靠的方法时列出 SYSVOL ,任何 AD 账户都可以读取 SYSVOL 目录的内容。

  1. C:\Tools>dir \\za.tryhackme.com\SYSVOL\
  2. Volume in drive \\za.tryhackme.com\SYSVOL is Windows
  3. Volume Serial Number is 1634-22A9
  4. Directory of \\za.tryhackme.com\SYSVOL
  5. 02/24/2022 09:57 PM <DIR> .
  6. 02/24/2022 09:57 PM <DIR> ..
  7. 02/24/2022 09:57 PM <JUNCTION> za.tryhackme.com [C:\Windows\SYSVOL\domain]
  8. 0 File(s) 0 bytes
  9. 3 Dir(s) 51,835,408,384 bytes free

通过 MMC 进行枚举

:::info GUI 方法,比较繁琐,并且适用性不高

:::

TryHackMe | Enumerating Active Directory

利用 CMD

CMD 中有一个内置命令 net可以帮助我们枚举 AD 内容。

:::info Net 命令官方文档

:::

用户

  1. C:\>net user /domain
  2. The request will be processed at a domain controller for domain za.tryhackme.com
  3. User accounts for \\THMDC
  4. -------------------------------------------------------------------------------
  5. aaron.conway aaron.hancock aaron.harris
  6. aaron.johnson aaron.lewis aaron.moore
  7. aaron.patel aaron.smith abbie.joyce
  8. abbie.robertson abbie.taylor abbie.walker
  9. abdul.akhtar abdul.bates abdul.holt
  10. abdul.jones abdul.wall abdul.west
  11. abdul.wilson abigail.cox abigail.cox1
  12. abigail.smith abigail.ward abigail.wheeler
  13. [....]
  14. The command completed successfully.
  1. C:\>net user zoe.marshall /domain
  2. The request will be processed at a domain controller for domain za.tryhackme.com
  3. User name zoe.marshall
  4. Full Name Zoe Marshall
  5. Comment
  6. User's comment
  7. Country/region code 000 (System Default)
  8. Account active Yes
  9. Account expires Never
  10. Password last set 2/24/2022 10:06:06 PM
  11. Password expires Never
  12. Password changeable 2/24/2022 10:06:06 PM
  13. Password required Yes
  14. User may change password Yes
  15. Workstations allowed All
  16. Logon script
  17. User profile
  18. Home directory
  19. Last logon Never
  20. Logon hours allowed All
  21. Local Group Memberships
  22. Global Group memberships *Domain Users *Internet Access
  23. The command completed successfully.

  1. C:\>net group /domain
  2. The request will be processed at a domain controller for domain za.tryhackme.com
  3. Group Accounts for \\THMDC
  4. -------------------------------------------------------------------------------
  5. *Cloneable Domain Controllers
  6. *DnsUpdateProxy
  7. *Domain Admins
  8. *Domain Computers
  9. *Domain Controllers
  10. *Domain Guests
  11. *Domain Users
  12. [...]
  13. *Schema Admins
  14. *Server Admins
  15. *Tier 0 Admins
  16. *Tier 1 Admins
  17. *Tier 2 Admins
  18. The command completed successfully.
  1. C:\>net group "Tier 1 Admins" /domain
  2. The request will be processed at a domain controller for domain za.tryhackme.com
  3. Group name Tier 1 Admins
  4. Comment
  5. Members
  6. -------------------------------------------------------------------------------
  7. t1_arthur.tyler t1_gary.moss t1_henry.miller
  8. t1_jill.wallis t1_joel.stephenson t1_marian.yates
  9. t1_rosie.bryant
  10. The command completed successfully.

密码策略

  1. C:\>net accounts /domain
  2. The request will be processed at a domain controller for domain za.tryhackme.com
  3. Force user logoff how long after time expires?: Never
  4. Minimum password age (days): 0
  5. Maximum password age (days): Unlimited
  6. Minimum password length: 0
  7. Length of password history maintained: None
  8. Lockout threshold: Never
  9. Lockout duration (minutes): 30
  10. Lockout observation window (minutes): 30
  11. Computer role: PRIMARY
  12. The command completed successfully.

利用 Powershell

:::info AD-RSAT 官方文档

:::

用户

  1. PS C:\> Get-ADUser -Identity gordon.stevens -Server za.tryhackme.com -Properties *
  2. AccountExpirationDate :
  3. accountExpires : 9223372036854775807
  4. AccountLockoutTime :
  5. [...]
  6. Deleted :
  7. Department : Consulting
  8. Description :
  9. DisplayName : Gordon Stevens
  10. DistinguishedName : CN=gordon.stevens,OU=Consulting,OU=People,DC=za,DC=tryhackme,DC=com
  11. [...]
  • Identity : 正在枚举的账户名称
  • Server : 指定 DC
  • Properties : 显示那些属性

  1. PS C:\> Get-ADGroup -Identity Administrators -Server za.tryhackme.com
  2. DistinguishedName : CN=Administrators,CN=Builtin,DC=za,DC=tryhackme,DC=com
  3. GroupCategory : Security
  4. GroupScope : DomainLocal
  5. Name : Administrators
  6. ObjectClass : group
  7. ObjectGUID : f4d1cbcd-4a6f-4531-8550-0394c3273c4f
  8. SamAccountName : Administrators
  9. SID : S-1-5-32-544
  1. PS C:\> Get-ADGroupMember -Identity Administrators -Server za.tryhackme.com
  2. distinguishedName : CN=Domain Admins,CN=Users,DC=za,DC=tryhackme,DC=com
  3. name : Domain Admins
  4. objectClass : group
  5. objectGUID : 8a6186e5-e20f-4f13-b1b0-067f3326f67c
  6. SamAccountName : Domain Admins
  7. SID : S-1-5-21-3330634377-1326264276-632209373-512
  8. [...]
  9. distinguishedName : CN=Administrator,CN=Users,DC=za,DC=tryhackme,DC=com name : Administrator
  10. objectClass : user
  11. objectGUID : b10fe384-bcce-450b-85c8-218e3c79b30fSamAccountName : Administrator
  12. SID : S-1-5-21-3330634377-1326264276-632209373-500

查看特定域的信息

  1. PS C:\> Get-ADDomain -Server za.tryhackme.com
  2. AllowedDNSSuffixes : {}
  3. ChildDomains : {}
  4. ComputersContainer : CN=Computers,DC=za,DC=tryhackme,DC=com
  5. DeletedObjectsContainer : CN=Deleted Objects,DC=za,DC=tryhackme,DC=com
  6. DistinguishedName : DC=za,DC=tryhackme,DC=com
  7. DNSRoot : za.tryhackme.com
  8. DomainControllersContainer : OU=Domain Controllers,DC=za,DC=tryhackme,DC=com
  9. [...]
  10. UsersContainer : CN=Users,DC=za,DC=tryhackme,DC=com

Bloodhound

我们可以利用 BloodHound 进行 AD 枚举,基本上涉及到 AD 攻击就会使用到该工具

LDAP 枚举

389, 636, 3268, 3269 - Pentesting LDAP - HackTricks

Powerview

PowerView.ps1

PowerView 备忘单:PowerView 备忘单

  1. # 使用 powershell -ep bypass 绕过 PowerSHELL 执行策略
  2. controller\administrator@DOMAIN-CONTROLL C:\Users\Administrator>powershell -ep bypass
  3. Windows PowerShell
  4. Copyright (C) Microsoft Corporation. All rights reserved.
  5. PS C:\Users\Administrator>

WMI 枚举

Offensive WMI - Active Directory Enumeration (Part 5)

参考

TryHackMe | Enumerating Active Directory