-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
124 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
$i18n = Data { | ||
# culture="en-US" | ||
ConvertFrom-StringData @' | ||
# culture="en-US" | ||
ConvertFrom-StringData @' | ||
Create = create | ||
Delete = delete | ||
UserAccountManagement = User Account Management | ||
'@ | ||
} | ||
|
||
if ($PSUICulture -ne 'en-US') { | ||
Import-LocalizedData -BindingVariable i18n | ||
Import-LocalizedData -BindingVariable i18n | ||
} | ||
|
||
function Test($config) { | ||
if (-not (IsLocalAdministrator)) { | ||
$ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) | ||
Write-RequireAdministrator($ruleName) | ||
return | ||
} | ||
$days = [int]::Parse($config.UserAccountManagement.Days) * -1 | ||
# https://learn.microsoft.com/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable | ||
$events = Get-WinEvent -FilterHashtable @{ | ||
LogName = 'Security' | ||
Id = 4720, 4726 | ||
StartTime = (get-date).AddDays($days) | ||
} -ErrorAction SilentlyContinue | ||
if ($events.Count -eq 0) { | ||
return | ||
} | ||
Write-Output "`n## $($i18n.UserAccountManagement)`n" | ||
foreach ($event in $events) { | ||
$username = $event.Properties[0].Value | ||
$actor = $event.Properties[4].Value | ||
# https://learn.microsoft.com/windows/security/threat-protection/auditing/event-4720 | ||
if ($event.Id -eq 4720) { | ||
Write-Output ("- {0:yyyy-MM-dd'T'HH:mm:ssK} | ``$($actor)`` $($i18n.Create) ``$($username)``" -f $event.TimeCreated) | ||
} | ||
# https://learn.microsoft.com/windows/security/threat-protection/auditing/event-4726 | ||
elseif ($event.Id -eq 4726) { | ||
Write-Output ("- {0:yyyy-MM-dd'T'HH:mm:ssK} | ``$($actor)`` $($i18n.Delete) ``$($username)``" -f $event.TimeCreated) | ||
} | ||
} | ||
$ruleName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) | ||
if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.Platform -ne 'Win32NT') { | ||
Write-UnsupportedPlatform($ruleName) | ||
return | ||
} | ||
if (-not (IsLocalAdministrator)) { | ||
Write-RequireAdministrator($ruleName) | ||
return | ||
} | ||
$days = [int]::Parse($config.UserAccountManagement.Days) * -1 | ||
# https://learn.microsoft.com/powershell/scripting/samples/creating-get-winevent-queries-with-filterhashtable | ||
$events = Get-WinEvent -FilterHashtable @{ | ||
LogName = 'Security' | ||
Id = 4720, 4726 | ||
StartTime = (get-date).AddDays($days) | ||
} -ErrorAction SilentlyContinue | ||
if ($events.Count -eq 0) { | ||
return | ||
} | ||
Write-Output "`n## $($i18n.UserAccountManagement)`n" | ||
foreach ($event in $events) { | ||
$username = $event.Properties[0].Value | ||
$actor = $event.Properties[4].Value | ||
# https://learn.microsoft.com/windows/security/threat-protection/auditing/event-4720 | ||
if ($event.Id -eq 4720) { | ||
Write-Output ("- {0:yyyy-MM-dd'T'HH:mm:ssK} | ``$($actor)`` $($i18n.Create) ``$($username)``" -f $event.TimeCreated) | ||
} | ||
# https://learn.microsoft.com/windows/security/threat-protection/auditing/event-4726 | ||
elseif ($event.Id -eq 4726) { | ||
Write-Output ("- {0:yyyy-MM-dd'T'HH:mm:ssK} | ``$($actor)`` $($i18n.Delete) ``$($username)``" -f $event.TimeCreated) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# culture="zh-TW" | ||
ConvertFrom-StringData -StringData @' | ||
Error = 錯誤 | ||
RequireAdministrator = 需要管理者權限 | ||
SkipRule = 略過規則 | ||
SystemInfo = 系統資訊 | ||
Error = 錯誤 | ||
UnsupportedPlatform = 不支援的作業系統 | ||
'@ |