A comprehensive Windows security auditing and threat detection toolkit. Features 58 production-ready PowerShell functions organized into 14 modules for enterprise-grade security assessment, compliance validation, and incident response.
PowerShell
Final solidity review: E2E docs, contract and security fixes
Okan YILDIZ58acb06e1939
diff --git a/CloudSecurity/Get-CloudComplianceStatus.ps1 b/CloudSecurity/Get-CloudComplianceStatus.ps1index 8361fa5..183417c 100644--- a/CloudSecurity/Get-CloudComplianceStatus.ps1+++ b/CloudSecurity/Get-CloudComplianceStatus.ps1@@ -181,7 +181,7 @@ function Get-CloudComplianceStatus {if ($Format -in @('HTML', 'All')) {$htmlPath = Join-Path $ExportPath "Compliance_${Framework}_$timestamp.html"- $htmlContent = Generate-ComplianceHTML -Results $results+ $htmlContent = Generate-CloudComplianceHTML -Results $results$htmlContent | Out-File $htmlPath -Encoding UTF8Write-Host "Exported HTML: $htmlPath" -ForegroundColor Green}@@ -219,7 +219,7 @@ function Get-CloudComplianceStatus {}}-function Generate-ComplianceHTML {+function Generate-CloudComplianceHTML {param($Results)$hasScore = ($null -ne $Results) -and ($null -ne $Results.ComplianceScore)diff --git a/Forensics/Export-MemoryDump.ps1 b/Forensics/Export-MemoryDump.ps1index 484f4bd..b9212ff 100644--- a/Forensics/Export-MemoryDump.ps1+++ b/Forensics/Export-MemoryDump.ps1@@ -77,6 +77,33 @@ function Export-MemoryDump {Method = $nullErrorMessage = $null}++ # Memory dumps (LSASS especially) can contain plaintext credentials, so restrict+ # the dump file to Administrators and SYSTEM instead of the inherited default+ # that grants every local user read access (mirrors the generated-script lockdown+ # in Register-ScheduledSecurityScan)+ function Protect-DumpFile {+ param([Parameter(Mandatory = $true)][string]$Path)+ if ($env:OS -ne 'Windows_NT') { return }+ try {+ $fileAcl = Get-Acl -Path $Path -ErrorAction Stop+ $fileAcl.SetAccessRuleProtection($true, $false)+ foreach ($existingRule in @($fileAcl.Access)) {+ $null = $fileAcl.RemoveAccessRule($existingRule)+ }+ foreach ($identity in @('NT AUTHORITY\SYSTEM', 'BUILTIN\Administrators')) {+ $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(+ $identity,+ [System.Security.AccessControl.FileSystemRights]::FullControl,+ [System.Security.AccessControl.AccessControlType]::Allow)+ $fileAcl.AddAccessRule($accessRule)+ }+ Set-Acl -Path $Path -AclObject $fileAcl -ErrorAction Stop+ }+ catch {+ Write-Warning "Could not restrict permissions on '$Path'; the dump may contain credentials and may be readable by other local users: $_"+ }+ }}process {@@ -131,11 +158,13 @@ function Export-MemoryDump {if ($UseProcDump) {Write-Host "`n[1/3] Attempting ProcDump method..." -ForegroundColor Cyan+ # Only search admin-controlled fixed paths. This function runs elevated+ # (and can target LSASS), so a procdump.exe planted in a user-writable+ # location (TEMP, current directory) would execute attacker-controlled+ # code with elevated privileges$procDumpPaths = @("C:\Tools\procdump.exe",- "C:\Tools\procdump64.exe",- "$env:TEMP\procdump.exe",- ".\procdump.exe"+ "C:\Tools\procdump64.exe")$foundProcDump = $null@@ -336,7 +365,8 @@ public class ProcessDump {if ($result.Success -and (Test-Path $dumpFilePath)) {$dumpFile = Get-Item $dumpFilePath$result.FileSize = $dumpFile.Length-+ Protect-DumpFile -Path $dumpFilePath+$fileSizeMB = [Math]::Round($dumpFile.Length / 1MB, 2)Write-Host "`n[SUCCESS] Memory dump created!" -ForegroundColor GreenWrite-Host " File: $dumpFilePath" -ForegroundColor Cyan@@ -352,6 +382,7 @@ public class ProcessDump {Compress-Archive -Path $dumpFilePath -DestinationPath $zipPath -CompressionLevel Optimalif (Test-Path $zipPath) {+ Protect-DumpFile -Path $zipPath$zipFile = Get-Item $zipPath$zipSizeMB = [Math]::Round($zipFile.Length / 1MB, 2)$compressionRatio = [Math]::Round((1 - ($zipFile.Length / $dumpFile.Length)) * 100, 1)diff --git a/Hardening/Invoke-SecurityRemediation.ps1 b/Hardening/Invoke-SecurityRemediation.ps1index 216d80b..8eb67f8 100644--- a/Hardening/Invoke-SecurityRemediation.ps1+++ b/Hardening/Invoke-SecurityRemediation.ps1@@ -19,10 +19,10 @@ function Invoke-SecurityRemediation {.PARAMETER RollbackDirectoryDirectory where the rollback script is written (default: current location).EXAMPLE- Invoke-SecurityRemediation -AssessmentPath "C:\Assessments\AssessmentResults.json" -WhatIf+ Invoke-SecurityRemediation -AssessmentPath "C:\Assessments\SecurityAssessment.json" -WhatIfPreview every remediation that would be applied without changing any state.EXAMPLE- Invoke-SecurityRemediation -AssessmentPath "C:\Assessments\AssessmentResults.json" -MaxSeverity Critical -GenerateRollback+ Invoke-SecurityRemediation -AssessmentPath "C:\Assessments\SecurityAssessment.json" -MaxSeverity Critical -GenerateRollbackRemediate only Critical findings and write a rollback script with pre-change values.EXAMPLEInvoke-SecurityAssessment -OutputPath "C:\Assessments" | Invoke-SecurityRemediation -GenerateRollback -Confirm@@ -438,7 +438,11 @@ function Invoke-SecurityRemediation {}if ($GenerateRollback -and @($capturedRollback).Count -gt 0) {- $rollbackScriptLines += "# Rollback for: $findingText"+ # Finding text comes from a JSON file / pipeline input; a newline+ # would break out of the comment and inject lines into the+ # elevated rollback script, so collapse line breaks+ $rollbackFindingText = $findingText -replace '[\r\n]+', ' '+ $rollbackScriptLines += "# Rollback for: $rollbackFindingText"$rollbackScriptLines += "# Remediation applied: $($matched.Name) on $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"$rollbackScriptLines += $capturedRollback$rollbackScriptLines += ""diff --git a/README.md b/README.mdindex a2d5a12..83ced11 100644--- a/README.md+++ b/README.md@@ -323,6 +323,8 @@ Import-Module ".\WindowsSecurityAudit.psd1" -Force```### Method 2: Direct Download+> **Note:** The `WindowsSecurityAudit.zip` asset is **not currently attached** to GitHub releases (the publish workflow only targets the PowerShell Gallery), so this download URL returns a 404 for now. Use Method 1 or 3 until a release ships the ZIP asset.+```powershell# Download latest release$url = "https://github.com/okanyildiz/WindowsSecurityAudit/releases/latest/download/WindowsSecurityAudit.zip"@@ -403,7 +405,7 @@ Write-Host "Security Score: $($security.SecurityScore)/100" -ForegroundColor Yel$threats = Find-SuspiciousProcessesif ($threats) {Write-Warning "Found $($threats.Count) suspicious processes!"- $threats | Format-Table Name, Path, RiskLevel+ $threats | Format-Table ProcessName, Path, SuspicionScore}```@@ -412,11 +414,11 @@ if ($threats) {# Run full security assessment$report = Invoke-SecurityAssessment -Verbose-# Export professional report-$report | Export-SecurityReport -Format HTML -Path "C:\SecurityReports"+# Export professional report (collects its own data; returns the generated file paths)+$files = Export-SecurityReport -ReportType Technical -Format HTML -OutputPath "C:\SecurityReports"-# Open report-Start-Process "C:\SecurityReports\SecurityReport.html"+# Open report (file name is timestamped: SecurityReport_Technical_yyyyMMdd_HHmmss.html)+Start-Process ($files | Where-Object { $_ -match '\.html$' } | Select-Object -First 1)```### Real CVEs & Live Threat Feeds (New in v1.2.0)@@ -454,8 +456,7 @@ Find-DefenseEvasion -IncludeLogGapAnalysisGet-CredentialAccessEvents -IncludeLSASSAccess# Export findings as SIEM-ready NDJSON without opening a browser-$report = Invoke-SecurityAssessment-$report | Export-SecurityReport -Format NDJSON -NoAutoOpen+Export-SecurityReport -ReportType Technical -Format NDJSON -NoAutoOpen```### Fleet Scanning & Smart Alerts (New in v1.5.0)@@ -483,9 +484,9 @@ New-ConsolidatedReport -OutputPath .\Report -FromJsonPath .\Report\ConsolidatedR### Visualize Threats in MITRE ATT&CK Navigator (New in v1.1.0)```powershell-# Hunt for persistence mechanisms, then pipe straight into a+# Map live findings to ATT&CK techniques, then pipe straight into a# Navigator layer with severity-based scoring and colors-Find-PersistenceMechanisms | Export-AttackNavigatorLayer -OutputPath .\attack-layer.json+Get-MITREAttackMapping -FullAnalysis | Export-AttackNavigatorLayer -OutputPath .\attack-layer.json# Import .\attack-layer.json at https://mitre-attack.github.io/attack-navigator/# to see exactly which techniques your findings cover — and where the gaps arediff --git a/Reporting/New-SecurityDashboard.ps1 b/Reporting/New-SecurityDashboard.ps1index dad2f85..2659f55 100644--- a/Reporting/New-SecurityDashboard.ps1+++ b/Reporting/New-SecurityDashboard.ps1@@ -882,7 +882,7 @@ function New-SecurityDashboard {if ($DetailLevel -eq 'Detailed') {try {- $script:dashboardData.Enterprise.MultiSystemAudit = Get-MultiSystemAudit -ErrorAction Stop+ $script:dashboardData.Enterprise.MultiSystemAudit = Get-MultiSystemAudit -ComputerName $env:COMPUTERNAME -ErrorAction Stop$functionCount++Write-Host " [50/54] Get-MultiSystemAudit: OK" -ForegroundColor Green} catch {