-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscan_logs.ps1
43 lines (35 loc) · 1.35 KB
/
scan_logs.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
param (
[string]$dir
)
function Main {
param (
[string]$dir
)
if (-not (Test-Path -Path (Join-Path -Path $dir -ChildPath "CrushFTP.jar"))) {
Write-Output "[!] The following directory does not look like a CrushFTP installation folder: $dir"
exit 1
}
$logFiles = @(
(Join-Path -Path $dir -ChildPath "CrushFTP.log")
) + (Get-ChildItem -Path (Join-Path -Path $dir -ChildPath "logs/session_logs/*/session_HTTP_*.log") -File).FullName + (Get-ChildItem -Path (Join-Path -Path $dir -ChildPath "logs/CrushFTP.log*") -File).FullName
foreach ($fname in $logFiles) {
if ([string]::IsNullOrEmpty($fname)) {
continue
}
if (Test-Path -Path $fname) {
$txt = Get-Content -Path $fname -Raw
if ($txt -match "<INCLUDE>") {
$lines = $txt -split "`n" | Where-Object { $_ -match "<INCLUDE>" }
foreach ($line in $lines) {
try {
$ip = ($line -split "\|")[2] -split ":" | Select-Object -Last 1 -split "\]" | Select-Object -First 1
Write-Output "$fname`: traces of exploitation by $ip"
} catch {
Write-Output "$fname`: traces of exploitation"
}
}
}
}
}
}
Main -dir $dir