@echo off
setlocal EnableExtensions
chcp 65001 >nul
fltmc >nul 2>&1
if errorlevel 1 (
  powershell.exe -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)
echo.
echo SOS - Activation de la protection Windows
echo ----------------------------------------
echo Windows va appliquer uniquement des reglages de securite standards et un DNS anti-menaces.
echo.
powershell.exe -NoProfile -Command "$ErrorActionPreference='Stop'; $root=Join-Path $env:ProgramData 'SOS'; New-Item -ItemType Directory -Path $root -Force ^| Out-Null; $domain=$false; try{$domain=[bool](Get-CimInstance Win32_ComputerSystem).PartOfDomain}catch{}; $ad=Get-NetAdapter ^| Where-Object {$_.Status -eq 'Up' -and $_.HardwareInterface}; if(-not $ad){throw 'Aucune connexion reseau active trouvee.'}; $backup=@(); foreach($a in $ad){$old=(Get-DnsClientServerAddress -InterfaceIndex $a.ifIndex -AddressFamily IPv4).ServerAddresses; $backup += [pscustomobject]@{InterfaceIndex=$a.ifIndex;Name=$a.Name;IPv4=$old}}; $backup ^| ConvertTo-Json -Depth 5 ^| Set-Content -Encoding UTF8 (Join-Path $root 'dns-before-profile.json'); if(-not $domain){foreach($a in $ad){Set-DnsClientServerAddress -InterfaceIndex $a.ifIndex -ServerAddresses @('9.9.9.9','149.112.112.112')}}; try{netsh dnsclient add encryption server=9.9.9.9 dohtemplate=https://dns.quad9.net/dns-query autoupgrade=yes udpfallback=no ^| Out-Null}catch{}; try{netsh dnsclient add encryption server=149.112.112.112 dohtemplate=https://dns.quad9.net/dns-query autoupgrade=yes udpfallback=no ^| Out-Null}catch{}; try{netsh dnsclient set global doh=yes ^| Out-Null}catch{}; try{Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled True}catch{}; if(Get-Command Set-MpPreference -ErrorAction SilentlyContinue){try{Set-MpPreference -PUAProtection Enabled}catch{}; try{Set-MpPreference -DisableRealtimeMonitoring $false}catch{}}; Clear-DnsClientCache; if($domain){Write-Host 'PC rattache a un domaine : SOS n a pas remplace le DNS de l entreprise.' -ForegroundColor Yellow}else{Write-Host 'DNS anti-menaces chiffre configure.' -ForegroundColor Green}; Write-Host 'Pare-feu Windows active lorsque disponible.' -ForegroundColor Green; Write-Host 'Protection Microsoft Defender renforcee lorsque disponible.' -ForegroundColor Green"
if errorlevel 1 (
  echo.
  echo SOS n'a pas pu appliquer tous les reglages. Aucun logiciel n'a ete installe.
  pause
  exit /b 1
)
echo.
echo Protection SOS configuree. Vous pouvez fermer cette fenetre.
start "" "https://www.suiteofsecurity.com/?sos_profile=windows"
timeout /t 3 >nul
exit /b 0
