-
Notifications
You must be signed in to change notification settings - Fork 10
/
iis_log_parse.ps1
28 lines (18 loc) · 959 Bytes
/
iis_log_parse.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Function Out-GridViewIISLog ($File) {
#.Synopsis - Thanks to this dude - https://www.catapultsystems.com/blogs/easy-iis-log-reading-with-powershell/
$Headers = @((Get-Content -Path $File -ReadCount 4 -TotalCount 4)[3].split(' ') | Where-Object { $_ -ne '#Fields:' });
Import-Csv -Delimiter ' ' -Header $Headers -Path $File | Where-Object { $_.date -notlike '#*' } | Out-GridView -Title "IIS log: $File";
};
$logs = get-childitem -path "C:\inetpub\logs\LogFiles" -Recurse -Filter *.log | ? {$_.LastWriteTime -gt (Get-Date).AddDays(-30)}
foreach($log in $logs){
$logdata = $log | Get-Content
if($logdata -match 'autodiscover.*powershell')
{
write-host "Detected possible IOC in: " $log.FullName -ForegroundColor Yellow
write-host "IOC located, please investigate" -ForegroundColor Red
sleep -Seconds 5
#$matches = $logdata -match 'autodiscover.*powershell'
#write-host $matches -ForegroundColor Gray
Out-GridViewIISLog -File $log.FullName
}
}