Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
winlogbeat [2025/03/25 22:55] jango angelegt |
winlogbeat [2025/04/16 11:34] (aktuell) jango |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | Winlogbeat ist ein Tool um [[Windows]] Eventlogs aufzubereiten und in einen [[Elasticsearch]]bzw. [[Opensearch]] | + | Winlogbeat ist ein Tool um [[Windows]] Eventlogs aufzubereiten und in einen [[Elasticsearch]]bzw. [[Opensearch]] |
+ | |||
+ | <code bash> | ||
+ | # jq | ||
+ | curl -X GET " | ||
+ | # jq | ||
+ | curl -X GET " | ||
+ | |||
+ | # Liste alle Agents | ||
+ | curl -X GET " | ||
+ | </ | ||
+ | |||
+ | <box red> | ||
+ | |||
+ | =====Installation===== | ||
+ | |||
+ | Im Installationsordner von Winlogbeat findet sich ein ps1 Script. | ||
+ | < | ||
+ | .\install-service-winlogbeat.ps1 | ||
+ | </ | ||
<code yaml> | <code yaml> | ||
+ | # Diese Konfiguration speichert die Logs aller Server im selben Index | ||
winlogbeat.event_logs: | winlogbeat.event_logs: | ||
+ | |||
- name: Application | - name: Application | ||
ignore_older: | ignore_older: | ||
Zeile 9: | Zeile 30: | ||
- name: Security | - name: Security | ||
- | envent_id: 4800, 4801 | + | envent_id: 4800, 4801 # nur diese event ids |
+ | event_id: -1000, | ||
+ | | ||
- name: Microsoft-Windows-Sysmon/ | - name: Microsoft-Windows-Sysmon/ | ||
Zeile 20: | Zeile 43: | ||
- name: ForwardedEvents | - name: ForwardedEvents | ||
tags: [forwarded] | tags: [forwarded] | ||
+ | | ||
+ | - name: Microsoft-Windows-Windows Firewall With Advanced Security/ | ||
+ | level: critical, error, warning | ||
+ | language: 0x0409 # en-US | ||
+ | processors: | ||
+ | - drop_event.when.not.or: | ||
+ | - equals.winlog.event_id: | ||
+ | - equals.winlog.event_id: | ||
+ | - equals.winlog.event_id: | ||
+ | tags: [" | ||
+ | include_xml: | ||
+ | provider: # (Get-WinEvent -ListLog Security).ProviderNames | ||
+ | - Application Error | ||
+ | - Application Hang | ||
+ | - Windows Error Reporting | ||
+ | - EMET | ||
+ | |||
+ | |||
+ | - id: dhcp-server-logs | ||
+ | xml_query: > | ||
+ | < | ||
+ | <Query Id=" | ||
+ | <Select Path=" | ||
+ | <Select Path=" | ||
+ | <Select Path=" | ||
+ | </ | ||
+ | </ | ||
# ====================== Elasticsearch template settings ======================= | # ====================== Elasticsearch template settings ======================= | ||
Zeile 55: | Zeile 105: | ||
when.not.contains.tags: | when.not.contains.tags: | ||
- add_cloud_metadata: | - add_cloud_metadata: | ||
+ | </ | ||
+ | |||
+ | =====Windows Deployment===== | ||
+ | |||
+ | Not good | ||
+ | <code powershell> | ||
+ | #$servers = Get-ADComputer -Filter * | Where-Object { $_.Name -like " | ||
+ | |||
+ | $servers = @( | ||
+ | " | ||
+ | " | ||
+ | ) | ||
+ | |||
+ | foreach ($server in $servers) { | ||
+ | |||
+ | # If the service is running, stop it so we can overwrite files | ||
+ | $status = (Get-Service Winlogbeat -ComputerName $server).Status | ||
+ | if($status -like " | ||
+ | Write-Host " | ||
+ | $r = (Get-Service Winlogbeat -ComputerName $server).Stop() | ||
+ | } else { | ||
+ | Write-Host " | ||
+ | } | ||
+ | |||
+ | | ||
+ | |||
+ | Invoke-Command -ComputerName $server -ErrorAction Continue -ScriptBlock { | ||
+ | | ||
+ | # Copy new files | ||
+ | $source = " | ||
+ | $destination = " | ||
+ | $xcopyArgs = " | ||
+ | Start-Process -FilePath " | ||
+ | | ||
+ | $scriptPath = " | ||
+ | | ||
+ | if (Test-Path $scriptPath) { | ||
+ | | ||
+ | # Execute install script | ||
+ | powershell.exe -ExecutionPolicy Bypass -File $scriptPath | ||
+ | # Start service | ||
+ | Start-Service winlogbeat | ||
+ | # Set startup type to automatic | ||
+ | Set-Service winlogbeat -StartUpType Auto | ||
+ | # Check status | ||
+ | |||
+ | } else { | ||
+ | |||
+ | Write-Host " | ||
+ | |||
+ | } | ||
+ | |||
+ | $status = (Get-Service winlogbeat).Status | ||
+ | Write-Output " | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | Good | ||
+ | <code powershell> | ||
+ | # | ||
+ | # Last run stopped at vie-srv-admin01 (not finished) | ||
+ | # | ||
+ | |||
+ | <# | ||
+ | $servers = Get-ADComputer -Filter * -Properties * | Where-Object { | ||
+ | $_.Name -like " | ||
+ | -and $_.OperatingSystem -like " | ||
+ | -and $_.DistinguishedName -notlike " | ||
+ | } | Select-Object -ExpandProperty Name | ||
+ | #> | ||
+ | |||
+ | $servers = @( | ||
+ | " | ||
+ | ) | ||
+ | |||
+ | $logfile = " | ||
+ | $online = " | ||
+ | $offline = " | ||
+ | |||
+ | #$servers = @(" | ||
+ | |||
+ | foreach ($server in $servers) { | ||
+ | |||
+ | # If the service is running, stop it so we can overwrite files | ||
+ | | ||
+ | $status = (Get-Service -Name Winlogbeat -ComputerName $server).Status | ||
+ | if($status -like " | ||
+ | Write-Output " | ||
+ | $r = (Get-Service Winlogbeat -ComputerName $server).Stop() | ||
+ | Write-Output " | ||
+ | } else { | ||
+ | Write-Output " | ||
+ | } | ||
+ | | ||
+ | |||
+ | $session = New-PSSession -ComputerName $server | ||
+ | Copy-Item -Path " | ||
+ | |||
+ | try { | ||
+ | |||
+ | Invoke-Command -ComputerName $server -ErrorAction Stop -ScriptBlock { | ||
+ | | ||
+ | Param($srv) | ||
+ | |||
+ | #whoami | ||
+ | |||
+ | # Copy new files | ||
+ | <# | ||
+ | Write-Output " | ||
+ | $source = " | ||
+ | $destination = " | ||
+ | $xcopyArgs = " | ||
+ | | ||
+ | $output = cmd /c "xcopy `" | ||
+ | # | ||
+ | | ||
+ | Write-Output " | ||
+ | #> | ||
+ | |||
+ | $scriptPath = " | ||
+ | |||
+ | if (Test-Path $scriptPath) { | ||
+ | |||
+ | # Execute install script | ||
+ | powershell.exe -ExecutionPolicy Bypass -File $scriptPath | ||
+ | # Start service | ||
+ | Start-Service winlogbeat | ||
+ | # Set startup type to automatic | ||
+ | Set-Service winlogbeat -StartUpType Auto | ||
+ | # Check status | ||
+ | Write-Output " | ||
+ | |||
+ | } else { | ||
+ | |||
+ | Write-Output " | ||
+ | |||
+ | } | ||
+ | | ||
+ | |||
+ | $status = (Get-Service winlogbeat).Status | ||
+ | Write-Output " | ||
+ | |||
+ | # | ||
+ | |||
+ | } -ArgumentList $server | ||
+ | |||
+ | #$stat >> $online | ||
+ | |||
+ | | ||
+ | } catch { | ||
+ | | ||
+ | $connection = Test-Connection -ComputerName $server -Count 1 -Quiet | ||
+ | |||
+ | # Wenn der Server nicht erreichbar ist, schreibe es ins Log | ||
+ | if (-not $connection) { | ||
+ | Write-Output " | ||
+ | } else { | ||
+ | Write-Output " | ||
+ | } | ||
+ | |||
+ | } | ||
+ | | ||
+ | } | ||
</ | </ |