Skip to content

Commit 413574e

Browse files
authored
Merge pull request #2 from N0tHorizon/🌕Nextgen
Update 0.7-pre & 0.7-post
2 parents 0287328 + 527be49 commit 413574e

6 files changed

Lines changed: 292 additions & 11 deletions

File tree

.github/workflows/env-matrix.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Environment Compatibility Matrix
2+
3+
on:
4+
push:
5+
branches: [ "🌕Nextgen", "📦Current" ]
6+
pull_request:
7+
branches: [ "🌕Nextgen", "📦Current" ]
8+
9+
jobs:
10+
matrix-test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [windows-2019, windows-2022]
16+
shell: [pwsh, powershell]
17+
admin: [true, false]
18+
locale: [en-US, de-DE]
19+
name: Env: ${{ matrix.os }} | Shell: ${{ matrix.shell }} | Admin: ${{ matrix.admin }} | Locale: ${{ matrix.locale }}
20+
steps:
21+
- name: Checkout repo
22+
uses: actions/checkout@v4
23+
24+
- name: Set locale
25+
run: |
26+
Set-WinSystemLocale ${{ matrix.locale }}
27+
shell: powershell
28+
continue-on-error: true
29+
30+
- name: Run as admin (if required)
31+
if: ${{ matrix.admin == 'true' }}
32+
run: |
33+
Start-Process -FilePath ${{ matrix.shell }} -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File windows-telemetry-blocker.ps1 -dryrun' -Verb RunAs
34+
shell: powershell
35+
continue-on-error: true
36+
37+
- name: Run as non-admin (if required)
38+
if: ${{ matrix.admin == 'false' }}
39+
run: |
40+
${{ matrix.shell }} -NoProfile -ExecutionPolicy Bypass -File windows-telemetry-blocker.ps1 -dryrun
41+
shell: powershell
42+
continue-on-error: true
43+
44+
- name: Upload logs and report
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: logs-${{ matrix.os }}-${{ matrix.shell }}-${{ matrix.admin }}-${{ matrix.locale }}
48+
path: |
49+
telemetry-blocker.log
50+
telemetry-blocker-errors.log
51+
telemetry-blocker-report.md
52+
if-no-files-found: ignore

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
- Only the latest release is actively supported for security updates.
5+
- Older versions may not receive security patches.
6+
7+
## Reporting a Vulnerability
8+
If you discover a security vulnerability, please do **not** open a public issue. Instead, report it privately:
9+
10+
- Email: security@n0thorizon.dev (or use GitHub's private vulnerability reporting)
11+
- Include a detailed description, steps to reproduce, and any relevant logs or screenshots.
12+
- We will respond as quickly as possible and coordinate a fix.
13+
14+
## Security Best Practices
15+
- Always download releases from the official repository.
16+
- Review scripts before running, especially if you modify them.
17+
- Run the script in a test environment before deploying to production systems.
18+
- Keep your system and PowerShell up to date.
19+
20+
## Disclosure Policy
21+
- We follow responsible disclosure. Vulnerabilities will be fixed promptly and disclosed after a patch is released.
22+
23+
## Hall of Fame
24+
- Security researchers who responsibly disclose vulnerabilities may be credited here (with permission).
25+
26+
---
27+
For any other security concerns, contact the maintainer directly.

modules/common.ps1

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
11
# Common functions for all modules
2+
3+
# Enhanced Write-ModuleLog: robust fallback, cross-env
24
function Write-ModuleLog {
35
param([string]$msg)
4-
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
5-
Write-Log $msg
6+
try {
7+
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
8+
Write-Log $msg
9+
} else {
10+
$logFile = Join-Path $PSScriptRoot '..' 'telemetry-blocker.log'
11+
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
12+
"$timestamp $msg" | Out-File -FilePath $logFile -Append -Encoding utf8
13+
}
14+
} catch {
15+
Write-Host "[LOG ERROR] $msg" -ForegroundColor Red
616
}
717
}
818

19+
# Enhanced Set-RegistryValue: supports more types, error handling, cross-env
920
function Set-RegistryValue {
10-
param($Path, $Name, $Value, $Type = "DWord")
21+
param(
22+
[Parameter(Mandatory)]$Path,
23+
[Parameter(Mandatory)]$Name,
24+
[Parameter(Mandatory)]$Value,
25+
[ValidateSet("DWord","QWord","String","ExpandString","Binary","MultiString")]
26+
[string]$Type = "DWord"
27+
)
1128
if ($global:dryrun) {
1229
Write-Host "[DRY-RUN] Would set $Path\$Name = $Value ($Type)" -ForegroundColor DarkYellow
13-
Write-ModuleLog "[DRY-RUN] Would set $Path\$Name = $Value ($Type)"
30+
Write-ModuleLog "[DRY-RUN] Would set $($Path)\$($Name) = $Value ($Type)"
1431
} else {
15-
Set-ItemProperty -Path $Path -Name $Name -Value $Value -Type $Type
16-
Write-ModuleLog "Set $Path\$Name = $Value ($Type)"
32+
try {
33+
if ($Type -eq "DWord" -or $Type -eq "QWord") {
34+
Set-ItemProperty -Path $Path -Name $Name -Value ([Convert]::ToInt64($Value)) -Type $Type
35+
} elseif ($Type -eq "String" -or $Type -eq "ExpandString") {
36+
Set-ItemProperty -Path $Path -Name $Name -Value "$Value" -Type $Type
37+
} elseif ($Type -eq "Binary") {
38+
Set-ItemProperty -Path $Path -Name $Name -Value ([byte[]]$Value) -Type $Type
39+
} elseif ($Type -eq "MultiString") {
40+
Set-ItemProperty -Path $Path -Name $Name -Value ([string[]]$Value) -Type $Type
41+
} else {
42+
Set-ItemProperty -Path $Path -Name $Name -Value $Value -Type $Type
43+
}
44+
Write-ModuleLog "Set $($Path)\$($Name) = $Value ($Type)"
45+
} catch {
46+
Write-Host "[ERROR] Failed to set $($Path)\$($Name): $_" -ForegroundColor Red
47+
Write-ModuleLog "[ERROR] Failed to set $($Path)\$($Name): $_"
48+
}
1749
}
1850
}

run.bat

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,94 @@
11
@echo off
2+
:: Windows Telemetry Blocker Launcher (Critical Features Enhanced)
3+
:: Ensures admin, supports spaces in paths, and works from any directory
4+
5+
setlocal
6+
set "SCRIPT_DIR=%~dp0"
7+
set "PS_SCRIPT=%SCRIPT_DIR%windows-telemetry-blocker.ps1"
8+
9+
:: --- Critical: Check for script existence ---
10+
if not exist "%PS_SCRIPT%" (
11+
echo [FATAL] Main PowerShell script not found: %PS_SCRIPT%
12+
echo Please ensure all files are extracted and try again.
13+
pause
14+
exit /b 1
15+
)
16+
17+
:: --- Critical: Print script version if available ---
18+
for /f "tokens=3 delims=' " %%A in ('findstr /C:"$ScriptVersion = '" "%PS_SCRIPT%"') do set SCRIPT_VERSION=%%A
19+
if defined SCRIPT_VERSION (
20+
echo [INFO] Script version: %SCRIPT_VERSION%
21+
)
22+
23+
:: QoL: Clear screen and color title (if supported)
24+
cls
225
title Windows Telemetry Blocker
326
echo ===================================
427
echo Windows Telemetry Blocker
528
echo ===================================
629
echo.
7-
echo Starting script with administrator privileges...
30+
echo [INFO] This launcher will ensure you have admin rights and run the script with the best available PowerShell.
31+
echo [INFO] If you see errors, right-click and 'Run as administrator'.
32+
echo [INFO] Logs and reports will be saved in the script folder.
833
echo.
934

10-
PowerShell -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0windows-telemetry-blocker.ps1""' -Verb RunAs}"
35+
:: Check for admin rights
36+
net session >nul 2>&1
37+
if %errorlevel% neq 0 (
38+
echo [WARN] Requesting administrator privileges...
39+
PowerShell -ExecutionPolicy Bypass -Command "Start-Process '%~dpnx0' -Verb RunAs"
40+
exit /b
41+
)
42+
43+
echo [OK] Running with administrator privileges.
44+
echo.
45+
46+
:: --- Critical: Check PowerShell version ---
47+
set "PS_VER_OK=0"
48+
where pwsh >nul 2>&1
49+
if %errorlevel%==0 (
50+
for /f "delims=" %%V in ('pwsh -NoProfile -Command "$PSVersionTable.PSVersion.ToString()"') do set PSVER=%%V
51+
echo [INFO] Using PowerShell Core (pwsh) version %PSVER%...
52+
set "PS_VER_OK=1"
53+
pwsh -NoProfile -ExecutionPolicy Bypass -File "%PS_SCRIPT%"
54+
set "PS_EXIT=%ERRORLEVEL%"
55+
) else (
56+
where powershell >nul 2>&1
57+
if %errorlevel%==0 (
58+
for /f "delims=" %%V in ('powershell -NoProfile -Command "$PSVersionTable.PSVersion.ToString()"') do set PSVER=%%V
59+
echo [INFO] Using Windows PowerShell version %PSVER%...
60+
set "PS_VER_OK=1"
61+
powershell -NoProfile -ExecutionPolicy Bypass -File "%PS_SCRIPT%"
62+
set "PS_EXIT=%ERRORLEVEL%"
63+
) else (
64+
echo [ERROR] PowerShell is not installed or not in PATH.
65+
pause
66+
exit /b 1
67+
)
68+
)
69+
if "%PS_VER_OK%" == "0" (
70+
echo [FATAL] No compatible PowerShell found.
71+
pause
72+
exit /b 1
73+
)
74+
75+
:: --- Critical: Pause and show result, print log/report if error ---
76+
if "%PS_EXIT%" NEQ "0" (
77+
echo.
78+
echo [ERROR] The script exited with error code %PS_EXIT%.
79+
if exist "%SCRIPT_DIR%telemetry-blocker-errors.log" (
80+
echo --- Error Log ---
81+
type "%SCRIPT_DIR%telemetry-blocker-errors.log"
82+
)
83+
if exist "%SCRIPT_DIR%telemetry-blocker-report.md" (
84+
echo --- Report ---
85+
type "%SCRIPT_DIR%telemetry-blocker-report.md"
86+
)
87+
echo Please check the log and report files for details.
88+
) else (
89+
echo.
90+
echo [SUCCESS] Script completed. Review the report and logs for results.
91+
)
92+
echo.
93+
pause
94+
endlocal

telemetry-blocker-report.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Windows Telemetry Blocker - Change Report
2+
3+
This report will be generated by the script after each run (or dry-run), summarizing all actions taken or that would be taken.
4+
5+
- **Windows Version:**
6+
- **Build Number:**
7+
- **Script Version:**
8+
- **Execution Time:**
9+
- **Modules Run:**
10+
- **Summary:**
11+
- **Errors:**
12+
- **Rollback Modules:**
13+
14+
---
15+
16+
*This file is a template. The script will overwrite or update a file like this after each run.*

windows-telemetry-blocker.ps1

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ $ScriptVersion = 'nextgen-0.1-DB6'
88
param(
99
[switch]$all,
1010
[string[]]$modules,
11+
[string[]]$exclude,
1112
[switch]$interactive,
12-
[switch]$dryrun
13+
[switch]$dryrun,
14+
[switch]$whatif
1315
)
1416

1517
# --- Version Banner ---
@@ -26,15 +28,43 @@ Write-Host "Script started at: $(Get-Date)" -ForegroundColor Yellow
2628
Write-Host "Running from: $PSScriptRoot" -ForegroundColor Yellow
2729
Write-Host "================================`n"
2830

31+
# Registry backup/export before changes
32+
function Export-RegistryBackup {
33+
$backupDir = Join-Path $PSScriptRoot "registry-backups"
34+
if (-not (Test-Path $backupDir)) { New-Item -ItemType Directory -Path $backupDir | Out-Null }
35+
$timestamp = Get-Date -Format 'yyyyMMdd_HHmmss'
36+
$backupFile = Join-Path $backupDir "regbackup_$timestamp.reg"
37+
Write-Host "Exporting registry backup to $backupFile ..." -ForegroundColor Cyan
38+
reg export HKLM $backupFile /y | Out-Null
39+
Write-Host "✓ Registry backup complete." -ForegroundColor Green
40+
}
41+
42+
# Only export backup if not dryrun
43+
if (-not $dryrun) { Export-RegistryBackup }
44+
45+
2946
# Logging setup
3047
$logFile = Join-Path $PSScriptRoot "telemetry-blocker.log"
3148
function Write-Log {
32-
param([string]$msg)
49+
param([string]$msg, [switch]$Error)
3350
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
34-
"$timestamp $msg" | Out-File -FilePath $logFile -Append -Encoding utf8
51+
$entry = "$timestamp $msg"
52+
$entry | Out-File -FilePath $logFile -Append -Encoding utf8
53+
if ($Error) {
54+
$errorLogFile = Join-Path $PSScriptRoot "telemetry-blocker-errors.log"
55+
$entry | Out-File -FilePath $errorLogFile -Append -Encoding utf8
56+
}
3557
}
3658

59+
# Log Windows version and build number at the start
60+
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
61+
$winVersion = $osInfo.Version
62+
$winBuild = $osInfo.BuildNumber
3763
Write-Log "=== Script started ==="
64+
Write-Log "Windows Version: $winVersion"
65+
Write-Log "Windows Build: $winBuild"
66+
Write-Log "Script Version: $ScriptVersion"
67+
$reportFile = Join-Path $PSScriptRoot "telemetry-blocker-report.md"
3868

3969
# Check if modules directory exists
4070
$modulesDir = Join-Path $PSScriptRoot "modules"
@@ -378,6 +408,7 @@ foreach ($mod in $toRunResolved) {
378408
}
379409
}
380410

411+
381412
$endTime = Get-Date
382413
$duration = $endTime - $startTime
383414
Write-Stats "Execution started: $startTime"
@@ -408,5 +439,44 @@ Write-Host "Error log: $errorLogFile" -ForegroundColor Yellow
408439
if ($rollbackModules.Count -gt 0) {
409440
Write-Host "Rollback modules executed: $($rollbackModules -join ', ')" -ForegroundColor Red
410441
}
442+
443+
# --- Generate Markdown/HTML Report ---
444+
$reportContent = @()
445+
$reportContent += "# Windows Telemetry Blocker - Change Report"
446+
$reportContent += ""
447+
$reportContent += "**Date:** $(Get-Date)"
448+
$reportContent += "**Script Version:** $ScriptVersion"
449+
$reportContent += "**Windows Version:** $winVersion"
450+
$reportContent += "**Windows Build:** $winBuild"
451+
$reportContent += "**Execution Time:** $($duration.ToString())"
452+
$reportContent += ""
453+
$reportContent += "## Modules Run"
454+
$moduleKeys = $moduleResults.Keys
455+
foreach ($mod in $moduleKeys) {
456+
$res = $moduleResults[$mod]
457+
$line = "- $mod $($res.Status) (Start: $($res.Start), End: $($res.End))"
458+
if ($res.Error) { $line += " - Error: $($res.Error)" }
459+
$reportContent += $line
460+
}
461+
$reportContent += ""
462+
$reportContent += "## Summary"
463+
foreach ($item in $summary) {
464+
$reportContent += "- $item"
465+
}
466+
$reportContent += ""
467+
if ($rollbackModules.Count -gt 0) {
468+
$reportContent += "## Rollback Modules"
469+
$reportContent += "- $($rollbackModules -join ', ')"
470+
}
471+
$reportContent += ""
472+
$errors = Get-Content -Path $errorLogFile -ErrorAction SilentlyContinue
473+
if ($errors -and $errors.Count -gt 0) {
474+
$reportContent += "## Errors"
475+
foreach ($err in $errors) { $reportContent += "- $err" }
476+
}
477+
478+
$reportContent | Set-Content -Path $reportFile -Encoding utf8
479+
480+
Write-Host "Report written to: $reportFile" -ForegroundColor Green
411481
Write-Host "Press any key to exit..."
412482
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

0 commit comments

Comments
 (0)