Active directory enumeration

액티브 디렉토리에서 정보 확인하기

By Hong

윈도우 시스템에 접속했을 때 도메인 정보를 파악하기 위한 단계들.

winrm 보다는 RDP접속 후 실행하는게 좋음 (double hop 문제 때문에 같은 명령어를 입력해도 winrm의 경우 출력이 안되는 경우가 있다.)

net.exe

net.exe를 이용.

기본으로 설치되어있는 프로그램.

  • 도메인 유저들 출력

net user /domain 으로 도메인의 유저들을 출력.

The request will be processed at a domain controller for domain corp.com.

User accounts for \\DC1.corp.com

-------------------------------------------------------------------------------
Administrator            Guest                      hong  
iis_service              krbtgt                     
                                            

The command completed successfully.
  • 특정 유저의 도메인 정보

net user hong /domain 명령어로 특정 유저의 도메인 정보를 볼 수 있다.

The request will be processed at a domain controller for domain corp.com.

User name                    hong
Full Name
Comment
User's comment
Country/region code          000 (System Default)
Account active               Yes
Account expires              Never

Password last set            9/2/2022 4:26:48 PM
Password expires             Never
Password changeable          9/3/2022 4:26:48 PM
Password required            Yes
User may change password     Yes

Workstations allowed         All
Logon script
User profile
Home directory
Last logon                   9/20/2022 1:36:09 AM

Logon hours allowed          All

Local Group Memberships      *Administrators
Global Group memberships     *Domain Users         *Domain Admins
The command completed successfully.

PowerView

AD enum 툴 powerview를 사용하는 방법.

PowerView.ps1 파일을 윈도우 타겟 머신으로 전송.

깃허브에서 다운받거나 kali의 경우 다음 디렉토리에 있다.

/usr/share/windows-resources/powersploit/Recon

PowerView 매뉴얼을 참고

아래의 명령어로 PowerView를 로드

Import-Module .\PowerView.ps1

  • 도메인 정보를 획득
PS C:\Tools> Get-NetDomain

Forest                  : corp.com
DomainControllers       : {DC1.corp.com}
Children                : {}
DomainMode              : Unknown
DomainModeLevel         : 7
Parent                  :
PdcRoleOwner            : DC1.corp.com
RidRoleOwner            : DC1.corp.com
InfrastructureRoleOwner : DC1.corp.com
Name                    : corp.com
  • 도메인 유저 정보

Get-NetUser

logoncount             : 113
iscriticalsystemobject : True
description            : Built-in account for administering the computer/domain
distinguishedname      : CN=Administrator,CN=Users,DC=corp,DC=com
objectclass            : {top, person, organizationalPerson, user}
lastlogontimestamp     : 9/13/2022 1:03:47 AM
name                   : Administrator
objectsid              : S-1-5-21-1987370270-658905905-1781884369-500
samaccountname         : Administrator
admincount             : 1
codepage               : 0
samaccounttype         : USER_OBJECT
accountexpires         : NEVER
cn                     : Administrator
whenchanged            : 9/13/2022 8:03:47 AM
instancetype           : 4
usncreated             : 8196
objectguid             : e5591000-080d-44c4-89c8-b06574a14d85
lastlogoff             : 12/31/1600 4:00:00 PM
objectcategory         : CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=com
dscorepropagationdata  : {9/2/2022 11:25:58 PM, 9/2/2022 11:25:58 PM, 9/2/2022 11:10:49 PM, 1/1/1601 6:12:16 PM}
memberof               : {CN=Group Policy Creator Owners,CN=Users,DC=corp,DC=com, CN=Domain Admins,CN=Users,DC=corp,DC=com, CN=Enterprise
                         Admins,CN=Users,DC=corp,DC=com, CN=Schema Admins,CN=Users,DC=corp,DC=com...}
lastlogon              : 9/14/2022 2:37:15 AM
...

속성이 너무 많기 때문에 관심있는 속성은 select를 이용해서 필터링한다.

PS C:\Tools> Get-NetUser | select cn

cn
--
Administrator
Guest
krbtgt
hong
  • 그룹 정보 ```powershell PS C:\Tools> Get-NetGroup | select cn

cn

… Key Admins Enterprise Key Admins DnsAdmins DnsUpdateProxy Sales Department Management Department Development Department Debug

- 현재 로그인 유저가 관리자 권한을 가지고 있는 컴퓨터를 검색
  
`Find-LocalAdminAccess`

# SPN 탐색 (서비스 어카운트)
SPN을 조사하면 포트 스캔을 하지 않아도 어떤 포트에서 어떤 서비스가 사용중인지 알 수 있다.
spn의 정보를 찾기 위해서 [setspn.exe](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc731241(v=ws.11)#viewing-spns)라는 디폴트 프로그램을 이용. 
-l 뒤에 호스트네임이나 서비스네임을 입력.
```cmd
c:\Tools>setspn -l S2003A

c:\Tools>setspn -L iis_service

powerview를 이용

Get-NetUser -SPN | select samaccountname,serviceprincipalname

samaccountname serviceprincipalname
-------------- --------------------
krbtgt         kadmin/changepw
iis_service    {HTTP/web.corp.com, HTTP/web, HTTP/web.corp.com:80}

nslookup으로 서버의 IP주소도 알 수 있다.

PS C:\Tools\> nslookup.exe web.corp.com
Server:  UnKnown
Address:  192.168.50.70

Name:    web.corp.com
Address:  192.168.50.72

위의 명령어들을 사용해서 기본적인 AD의 구조를 파악 할 수 있다.

도메인 이름은 자주 사용되기 때문에 파악해두면 좋다.

Share: X (Twitter) Facebook LinkedIn