diff --git a/BrowserPasswordCheck.ps1 b/BrowserPasswordCheck.ps1 new file mode 100644 index 0000000..ead2a50 --- /dev/null +++ b/BrowserPasswordCheck.ps1 @@ -0,0 +1,69 @@ +# Speicherpfade für Chromium-basierte Browser (Edge/Chrome) und Firefox +$ChromiumPaths = @( + "AppData\Local\Google\Chrome\User Data\Default\Login Data", + "AppData\Local\Microsoft\Edge\User Data\Default\Login Data" +) +$FirefoxPathPart = "AppData\Roaming\Mozilla\Firefox\Profiles" + +# Zielnetzwerkfreigabe und Dateiname-Basis +$NetworkShare = "\\desvr-file02\password_Browser$" +$Hostname = [System.Environment]::MachineName + +Write-Host "Pruefe gespeicherte Browser-Passwoerter auf $Hostname ..." -ForegroundColor Cyan + +# Holt alle lokalen Benutzerprofile auf dem Rechner (außer Systemkonten) +$UserProfiles = Get-CimInstance -ClassName Win32_UserProfile | Where-Object { $_.Special -eq $false -and $_.LocalPath -notlike "*\Windows*" } + +foreach ($Profile in $UserProfiles) { + $UserName = Split-Path $Profile.LocalPath -Leaf + $Path = $Profile.LocalPath + + $HasSavedPasswords = $false + $DetectedBrowsers = @() + + # 1. Prüfe Chrome & Edge (Suchen nach der Datei 'Login Data') + foreach ($RelPath in $ChromiumPaths) { + $FullCheckPath = Join-Path $Path $RelPath + if (Test-Path $FullCheckPath) { + # Da die Datei immer existiert, prüfen wir, ob sie größer als die Standard-Leergröße ist (meist > 24KB) + if ((Get-Item $FullCheckPath).Length -gt 30000) { + $HasSavedPasswords = $true + $BrowserName = if ($RelPath -match "Chrome") { "Google Chrome" } else { "Microsoft Edge" } + $DetectedBrowsers += $BrowserName + } + } + } + + # 2. Prüfe Firefox (Suchen nach 'logins.json') + $FFProfilePath = Join-Path $Path $FirefoxPathPart + if (Test-Path $FFProfilePath) { + $LoginsFile = Get-ChildItem -Path $FFProfilePath -Filter "logins.json" -Recurse -ErrorAction SilentlyContinue + if ($LoginsFile -and $LoginsFile.Length -gt 100) { + $HasSavedPasswords = $true + $DetectedBrowsers += "Mozilla Firefox" + } + } + + # Ergebnis in Textdatei auf der Netzwerkfreigabe speichern + if ($HasSavedPasswords) { + $ReportEntry = [PSCustomObject]@{ + "Benutzer" = $UserName + "Speichert" = "Ja" + "Browser" = ($DetectedBrowsers -join ", ") + } + + # Dateiname: {Hostname}_{Username}.txt + $FileName = "$Hostname" + "_$($UserName).txt" + $OutputPath = Join-Path $NetworkShare $FileName + + try { + $ReportEntry | Format-Table -AutoSize | Out-String | Set-Content -LiteralPath $OutputPath + Write-Host " -> Bericht gespeichert: $OutputPath" -ForegroundColor Green + } + catch { + Write-Host " ! Fehler beim Speichern für Benutzer '$UserName': $_" -ForegroundColor Red + } + } +} + +Write-Host "Fertig. Berichte liegen unter $NetworkShare" -ForegroundColor Cyan diff --git a/BrowserPasswordCheck02.ps1 b/BrowserPasswordCheck02.ps1 new file mode 100644 index 0000000..2f967af --- /dev/null +++ b/BrowserPasswordCheck02.ps1 @@ -0,0 +1,116 @@ +# ============================================================ +# 1. Registry-Prüfung für einmalige Ausführung (Migration) +# Key-Pfad : HKCU:\Software\FUNKE +# Eigenschaft: Migration (DWORD-Wert) +# ============================================================ +$RegPath = "HKCU:\Software" +$PropName = "FUNKE\Migration" + +function Test-MigrationCompleted { + if (Test-Path -LiteralPath $RegPath) { + try { + $CurrentValue = (Get-ItemProperty -LiteralPath $RegPath -Name $PropName).$PropName + if ($CurrentValue -eq 1) { + Write-Host "Migration wurde bereits abgeschlossen (Registry-Wert = 1). Skript wird beendet." -ForegroundColor Yellow + exit + } + else { + Write-Host "Bestehender Registry-Key gefunden, Wert != 1. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + catch { + Write-Host "Eigenschaft '$PropName' nicht lesbar. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + else { + # Key nicht gefunden -> erstellen und auf 0 setzen + New-Item -LiteralPath $RegPath -Force | Out-Null + Set-ItemProperty -LiteralPath $RegPath -Name $PropName -Value 0 -Type DWord -Force | Out-Null + Write-Host "Registry-Key '$RegPath' erstellt und auf 0 gesetzt." -ForegroundColor Cyan + } +} + +function Set-MigrationCompleted { + # Nach Abschluss der Prüfung: Wert auf 1 setzen + if (-not (Test-Path -LiteralPath $RegPath)) { + New-Item -LiteralPath $RegPath -Force | Out-Null + } + Set-ItemProperty -LiteralPath $RegPath -Name $PropName -Value 1 -Type DWord -Force | Out-Null +} + +# --- Prüfung am Anfang ausführen --- +Test-MigrationCompleted + +# ============================================================ +# 2. Eigentliche Arbeit des Skripts (Browser-Passwort-Prüfung) +# ============================================================ +$ChromiumPaths = @( + "AppData\Local\Google\Chrome\User Data\Default\Login Data", + "AppData\Local\Microsoft\Edge\User Data\Default\Login Data" +) +$FirefoxPathPart = "AppData\Roaming\Mozilla\Firefox\Profiles" + +$NetworkShare = "\\desvr-file02\password_Browser$" +$Hostname = [System.Environment]::MachineName + +Write-Host "Pruefe gespeicherte Browser-Passwoerter auf $Hostname ..." -ForegroundColor Cyan + +# Holt alle lokalen Benutzerprofile auf dem Rechner (außer Systemkonten) +$UserProfiles = Get-CimInstance -ClassName Win32_UserProfile | Where-Object { $_.Special -eq $false -and $_.LocalPath -notlike "*\Windows*" } + +foreach ($Profile in $UserProfiles) { + $UserName = Split-Path $Profile.LocalPath -Leaf + $Path = $Profile.LocalPath + + $HasSavedPasswords = $false + $DetectedBrowsers = @() + + # 1. Prüfe Chrome & Edge (Suchen nach der Datei 'Login Data') + foreach ($RelPath in $ChromiumPaths) { + $FullCheckPath = Join-Path $Path $RelPath + if (Test-Path $FullCheckPath) { + if ((Get-Item $FullCheckPath).Length -gt 30000) { + $HasSavedPasswords = $true + $BrowserName = if ($RelPath -match "Chrome") { "Google Chrome" } else { "Microsoft Edge" } + $DetectedBrowsers += $BrowserName + } + } + } + + # 2. Prüfe Firefox (Suchen nach 'logins.json') + $FFProfilePath = Join-Path $Path $FirefoxPathPart + if (Test-Path $FFProfilePath) { + $LoginsFile = Get-ChildItem -Path $FFProfilePath -Filter "logins.json" -Recurse -ErrorAction SilentlyContinue + if ($LoginsFile -and $LoginsFile.Length -gt 100) { + $HasSavedPasswords = $true + $DetectedBrowsers += "Mozilla Firefox" + } + } + + # Ergebnis in Textdatei auf der Netzwerkfreigabe speichern + if ($HasSavedPasswords) { + $ReportEntry = [PSCustomObject]@{ + "Benutzer" = $UserName + "Speichert" = "Ja" + "Browser" = ($DetectedBrowsers -join ", ") + } + + # Dateiname: {Hostname}_{Username}.txt + $FileName = "$Hostname" + "_" + $UserName + ".txt" + $OutputPath = Join-Path $NetworkShare $FileName + + try { + $ReportEntry | Format-Table -AutoSize | Out-String | Set-Content -LiteralPath $OutputPath + Write-Host " -> Bericht gespeichert: $OutputPath" -ForegroundColor Green + } + catch { + Write-Host " ! Fehler beim Speichern für Benutzer '$UserName': $_" -ForegroundColor Red + } + } +} + +# ============================================================ +# 3. Prüfung abschließen: Registry-Wert auf 1 setzen +# ============================================================ +Set-MigrationCompleted +Write-Host "Fertig. Berichte liegen unter $NetworkShare" -ForegroundColor Cyan diff --git a/BrowserPasswordCheck03.ps1 b/BrowserPasswordCheck03.ps1 new file mode 100644 index 0000000..dfd7f76 --- /dev/null +++ b/BrowserPasswordCheck03.ps1 @@ -0,0 +1,130 @@ +# ============================================================ +# 1. Registry-Prüfung für einmalige Ausführung (Migration) +# Key-Pfad : HKCU:\Software\FUNKE +# Eigenschaft: Migration (DWORD-Wert) +# ============================================================ +$RegPath = "HKCU:\Software\FUNKE" +$PropName = "Migration" + +function Ensure-RegKey { + # Parent-Ordner HKCU:\Software sicherstellen + $ParentPath = "HKCU:\Software" + #if (-not (Test-Path -LiteralPath $ParentPath)) { + # New-Item -LiteralPath $ParentPath -Force | Out-Null + #} + #if (-not (Test-Path "HKCU:\Software\FUNKE")) { + # New-Item -Path "HKCU:\Software\FUNKE" -Force | Out-Null} + if (-not (Test-Path $RegPath)) { + New-Item -Path $RegPath -Force | Out-Null} + + # Unterordner 'FUNKE' erstellen und DWORD-Eigenschaft auf 0 setzen + New-Item $RegPath -Name $PropName -Value 0 -Type DWord -Force | Out-Null +} + +function Test-MigrationCompleted { + if (Test-Path -LiteralPath $RegPath) { + try { + $CurrentValue = (Get-ItemProperty -LiteralPath $RegPath -Name $PropName).$PropName + if ($CurrentValue -eq 1) { + Write-Host "Migration wurde bereits abgeschlossen (Registry-Wert = 1). Skript wird beendet." -ForegroundColor Yellow + exit + } + else { + Write-Host "Bestehender Registry-Key gefunden, Wert != 1. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + catch { + Write-Host "Eigenschaft '$PropName' nicht lesbar. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + else { + # Key nicht gefunden -> Unterordner FUNKE einlegen und auf 0 setzen + Ensure-RegKey + Write-Host "Registry-Key '$RegPath' erstellt und auf 0 gesetzt." -ForegroundColor Cyan + } +} + +function Set-MigrationCompleted { + if (-not (Test-Path -LiteralPath $RegPath)) { + Ensure-RegKey + } + # Nach Abschluss der Prüfung: Wert auf 1 setzen + Set-ItemProperty -LiteralPath $RegPath -Name $PropName -Value 1 -Type DWord -Force | Out-Null +} + +# --- Prüfung am Anfang ausführen --- +Test-MigrationCompleted + +# ============================================================ +# 2. Eigentliche Arbeit des Skripts (Browser-Passwort-Prüfung) +# ============================================================ +$ChromiumPaths = @( + "AppData\Local\Google\Chrome\User Data\Default\Login Data", + "AppData\Local\Microsoft\Edge\User Data\Default\Login Data" +) +$FirefoxPathPart = "AppData\Roaming\Mozilla\Firefox\Profiles" + +$NetworkShare = "\\desvr-file02\password_Browser$" +$Hostname = [System.Environment]::MachineName + +Write-Host "Pruefe gespeicherte Browser-Passwoerter auf $Hostname ..." -ForegroundColor Cyan + +# Holt alle lokalen Benutzerprofile auf dem Rechner (außer Systemkonten) +$UserProfiles = Get-CimInstance -ClassName Win32_UserProfile | Where-Object { $_.Special -eq $false -and $_.LocalPath -notlike "*\Windows*" } + +foreach ($Profile in $UserProfiles) { + $UserName = Split-Path $Profile.LocalPath -Leaf + $Path = $Profile.LocalPath + + $HasSavedPasswords = $false + $DetectedBrowsers = @() + + # 1. Prüfe Chrome & Edge (Suchen nach der Datei 'Login Data') + foreach ($RelPath in $ChromiumPaths) { + $FullCheckPath = Join-Path $Path $RelPath + if (Test-Path $FullCheckPath) { + if ((Get-Item $FullCheckPath).Length -gt 30000) { + $HasSavedPasswords = $true + $BrowserName = if ($RelPath -match "Chrome") { "Google Chrome" } else { "Microsoft Edge" } + $DetectedBrowsers += $BrowserName + } + } + } + + # 2. Prüfe Firefox (Suchen nach 'logins.json') + $FFProfilePath = Join-Path $Path $FirefoxPathPart + if (Test-Path $FFProfilePath) { + $LoginsFile = Get-ChildItem -Path $FFProfilePath -Filter "logins.json" -Recurse -ErrorAction SilentlyContinue + if ($LoginsFile -and $LoginsFile.Length -gt 100) { + $HasSavedPasswords = $true + $DetectedBrowsers += "Mozilla Firefox" + } + } + + # Ergebnis in Textdatei auf der Netzwerkfreigabe speichern + if ($HasSavedPasswords) { + $ReportEntry = [PSCustomObject]@{ + "Benutzer" = $UserName + "Speichert" = "Ja" + "Browser" = ($DetectedBrowsers -join ", ") + } + + # Dateiname: {Hostname}_{Username}.txt + $FileName = "$Hostname" + "_" + $UserName + ".txt" + $OutputPath = Join-Path $NetworkShare $FileName + + try { + $ReportEntry | Format-Table -AutoSize | Out-String | Set-Content -LiteralPath $OutputPath + Write-Host " -> Bericht gespeichert: $OutputPath" -ForegroundColor Green + } + catch { + Write-Host " ! Fehler beim Speichern für Benutzer '$UserName': $_" -ForegroundColor Red + } + } +} + +# ============================================================ +# 3. Prüfung abschließen: Registry-Wert auf 1 setzen +# ============================================================ +Set-MigrationCompleted +Write-Host "Fertig. Berichte liegen unter $NetworkShare" -ForegroundColor Cyan diff --git a/BrowserPasswordCheck04.ps1 b/BrowserPasswordCheck04.ps1 new file mode 100644 index 0000000..d2e306a --- /dev/null +++ b/BrowserPasswordCheck04.ps1 @@ -0,0 +1,125 @@ +# ============================================================ +# 1. Registry-Prüfung für einmalige Ausführung (Migration) +# Key-Pfad : HKCU:\Software\FUNKE +# Eigenschaft: Migration (DWORD-Wert) +# ============================================================ +$RegPath = "HKCU:\Software\FUNKE" +$PropName = "Migration" + +function Ensure-RegKey { + # Parent-Ordner HKCU:\Software sicherstellen + $ParentPath = "HKCU:\Software" + if (-not (Test-Path $RegPath)) { + New-Item -Path $RegPath -Force | Out-Null} + + # Unterordner 'FUNKE' erstellen und DWORD-Eigenschaft auf 0 setzen + New-Item $RegPath -Name $PropName -Value 0 -Type DWord -Force | Out-Null +} + +function Test-MigrationCompleted { + if (Test-Path -LiteralPath $RegPath) { + try { + $CurrentValue = (Get-ItemProperty $RegPath -Name $PropName).$PropName + if ($CurrentValue -eq 1) { + #Write-Host "Migration wurde bereits abgeschlossen (Registry-Wert = 1). Skript wird beendet." -ForegroundColor Yellow + exit + } + else { + #Write-Host "Bestehender Registry-Key gefunden, Wert != 1. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + catch { + #Write-Host "Eigenschaft '$PropName' nicht lesbar. Prüfung fortgesetzt." -ForegroundColor Cyan + } + } + else { + # Key nicht gefunden -> Unterordner FUNKE einlegen und auf 0 setzen + Ensure-RegKey + #Write-Host "Registry-Key '$RegPath' erstellt und auf 0 gesetzt." -ForegroundColor Cyan + } +} + +function Set-MigrationCompleted { + if (-not (Test-Path $RegPath)) { + Ensure-RegKey + } + # Nach Abschluss der Prüfung: Wert auf 1 setzen + Set-ItemProperty $RegPath -Name $PropName -Value 1 -Type DWord -Force | Out-Null +} + +# --- Prüfung am Anfang ausführen --- +Test-MigrationCompleted + +# ============================================================ +# 2. Eigentliche Arbeit des Skripts (Browser-Passwort-Prüfung) +# ============================================================ +$ChromiumPaths = @( + "AppData\Local\Google\Chrome\User Data\Default\Login Data", + "AppData\Local\Microsoft\Edge\User Data\Default\Login Data" +) +$FirefoxPathPart = "AppData\Roaming\Mozilla\Firefox\Profiles" + +$NetworkShare = "\\desvr-file02\password_Browser$" +$Hostname = [System.Environment]::MachineName + +#Write-Host "Pruefe gespeicherte Browser-Passwoerter auf $Hostname ..." -ForegroundColor Cyan + +# Holt alle lokalen Benutzerprofile auf dem Rechner (außer Systemkonten) +$UserProfiles = Get-CimInstance -ClassName Win32_UserProfile | Where-Object { $_.Special -eq $false -and $_.LocalPath -notlike "*\Windows*" } + +foreach ($Profile in $UserProfiles) { + $UserName = Split-Path $Profile.LocalPath -Leaf + $Path = $Profile.LocalPath + + $HasSavedPasswords = $false + $DetectedBrowsers = @() + + # 1. Prüfe Chrome & Edge (Suchen nach der Datei 'Login Data') + foreach ($RelPath in $ChromiumPaths) { + $FullCheckPath = Join-Path $Path $RelPath + if (Test-Path $FullCheckPath) { + if ((Get-Item $FullCheckPath).Length -gt 30000) { + $HasSavedPasswords = $true + $BrowserName = if ($RelPath -match "Chrome") { "Google Chrome" } else { "Microsoft Edge" } + $DetectedBrowsers += $BrowserName + } + } + } + + # 2. Prüfe Firefox (Suchen nach 'logins.json') + $FFProfilePath = Join-Path $Path $FirefoxPathPart + if (Test-Path $FFProfilePath) { + $LoginsFile = Get-ChildItem -Path $FFProfilePath -Filter "logins.json" -Recurse -ErrorAction SilentlyContinue + if ($LoginsFile -and $LoginsFile.Length -gt 100) { + $HasSavedPasswords = $true + $DetectedBrowsers += "Mozilla Firefox" + } + } + + # Ergebnis in Textdatei auf der Netzwerkfreigabe speichern + if ($HasSavedPasswords) { + $ReportEntry = [PSCustomObject]@{ + "Benutzer" = $UserName + "Speichert" = "Ja" + "Browser" = ($DetectedBrowsers -join ", ") + } + + # Dateiname: {Hostname}_{Username}.txt + $FileName = "$Hostname" + "_" + $UserName + ".txt" + $OutputPath = Join-Path $NetworkShare $FileName + + try { + $ReportEntry | Format-Table -AutoSize | Out-String | Set-Content $OutputPath + #Write-Host " -> Bericht gespeichert: $OutputPath" -ForegroundColor Green + } + catch { + #Write-Host " ! Fehler beim Speichern für Benutzer '$UserName': $_" -ForegroundColor Red + } + } +} + +# ============================================================ +# 3. Prüfung abschließen: Registry-Wert auf 1 setzen +# ============================================================ +Set-MigrationCompleted +#Write-Host "Fertig. Berichte liegen unter $NetworkShare" -ForegroundColor Cyan diff --git a/Pruefung_werden_Passworter_im_Browser_gespeischert.ps1 b/Pruefung_werden_Passworter_im_Browser_gespeischert.ps1 index f025364..6ecb077 100644 --- a/Pruefung_werden_Passworter_im_Browser_gespeischert.ps1 +++ b/Pruefung_werden_Passworter_im_Browser_gespeischert.ps1 @@ -50,5 +50,5 @@ foreach ($Profile in $UserProfiles) { } } -# Ausgabe des Berichts +# Ausgabe des Berichts in Datei Hostname_User.txt unter Netzwerkfreigabe \\desvr-file02\password_Browser$ $Report | Format-Table -AutoSize