Powershell script ile DC üzerinden ön kimlik doğrulaması başarısız olan aktiviteleri kolay anlaşılır tablo (Sabit genişlikli csv dosya ) biçiminde alan scripti paylaşacağım.
4771_Kerberos_Authentication_Failure.ps1
# ===========================================================
# NAME: 4771_Kerberos_Authentication_Failure.ps1
# AUTHOR: Bekir Yalçın
# DATE: 10/12/2012
# COMMENT: Kerberos pre-authentication failed. - EventID: 4771
# VERSION: 1
# ===========================================================
#
Clear
$Events=Get-Eventlog security -InstanceId 4771 -After (Get-Date).AddDays(-1) | # Son 1 gün
# $Events=Get-Eventlog security -InstanceId 4771 -After (Get-Date).AddHours(-1) | # Son 1 saat
Select TimeGenerated,ReplacementStrings |
% {
New-Object PSObject -Property @{
EventID = $_.EventID
MachineName = $_.MachineName
Data = $_.Data
Index = $_.Index
Category = $_.Category
CategoryNumber = $_.CategoryNumber
EntryType = $_.EntryType
Message = $_.Message
Source = $_.Source
ReplacementStrings = $_.ReplacementStrings
InstanceId = $_.InstanceId
TimeGenerated = $_.TimeGenerated
TimeWritten = $_.TimeWritten
UserName = $_.UserName
Site = $_.Site
Container = $_.Container
TargetUserName = $_.ReplacementStrings[0]
TargetUserSid = $_.ReplacementStrings[1]
ServiceName = $_.ReplacementStrings[2]
TicketOptions = $_.ReplacementStrings[3]
Status = $_.ReplacementStrings[4]
PreAuthType = $_.ReplacementStrings[5]
Source_IPAddress = $_.ReplacementStrings[6]
Source_IpPort = $_.ReplacementStrings[7]
CertIssuerName = $_.ReplacementStrings[8]
CertSerialNumber = $_.ReplacementStrings[9]
CertThumbprint = $_.ReplacementStrings[10]
}
}
$Events |
# $Events | Where {$_.TargetUserName -notlike "*$"} | # Sadece user accountlar için uygulanacak filtre
# $Events | Where {$_.TargetUserName -like "*$"} | # Sadece computer accountlar için uygulanacak filtre
Sort-Object -Descending TimeGenerated |`
Format-Table TimeGenerated,Source_IPAddress,Source_IpPort,ServiceName,TargetUserName,
@{Label="Status"; Expression={
switch ($_.Status){
("0x18") {"BadPassord"}
("0x17") {"PassExpired"}
("0x12") {"AccountDisabledExpiredLockedOutLogonHours"}
("0xC") {"WorkstationRestriction"}
("0x6") {"BadUserNameorNewComputer..."}
("0x25") {"ClockSkewTooGreat"}
("0x20") {"TicketExpired"}
default {"Unknown"}
}
}
},
Status,TargetUserSid,MachineName,Data,Index,Category,CategoryNumber,EntryType,
Source,InstanceId,TimeWritten,UserName,Site,Container,
TicketOptions,PreAuthType,CertIssuerName,CertSerialNumber,CertThumbprint -AutoSize |
Out-File -Width 1000 -Append -FilePath "4771_Reports.csv" -Encoding Unicode
Notepad "4771_Reports.csv"
Script çalıştırıldığında 4771_Reports.csv adında bir rapor dosyası oluşmaktadır. Bu dosya sabit genişlikli csv dosyasıdır. Microsoft Excel vb. uygulamalar ile açabilir ve otomatik sütunlara dönüştürebilirsiniz. Ayrıca kolonlara filtre ekleyerek istediğiniz gibi inceleye bilirsiniz.

NOT: TargetUserName kolonunda $ ile biten hesaplar computer accountlardır. Bilgisayar hesabının yanlış şifre girmesi ile ilgili http://siberblog.org/index.php/tag/bu-is-istasyonu-ile-birinci-etki-alani-arasindaki-guven-iliskisi-basarisiz/ etiketini inceleyebilirsiniz.
Event Viewer görünümü ile kolonların eşleşmesi:

Status kolonu ile ilgili bilgi tablosu (sadece sık kullanılanları scripte ekledim):

Download script: http://siberblog.org/wp-content/uploads/2012/12/4771_Kerberos_Authentication_Failure.rar
Referans: http://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4771
Hiç yorum yok:
Yorum Gönder