Created
December 4, 2025 16:45
-
-
Save luca-m/3f274f4e672a92516d84c523a99a269d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .SYNOPSIS | |
| Scarica la lista Top 1M (sostituto Alexa), estrae i primi 10k domini | |
| e verifica l'SSL Inspection. | |
| #> | |
| # --- CONFIGURAZIONE --- | |
| $InspectionKeyword = "Fortigate" # <--- INSERISCI QUI IL NOME DEL TUO CERTIFICATO | |
| $MaxDomainsToCheck = 100000 # Metti 10000 per la scansione completa (100 per test veloce) | |
| $CsvReportPath = "$([Environment]::GetFolderPath('Desktop'))\SSL_Inspection_Top10k.csv" | |
| # URL della Tranco List (Il miglior sostituto open source di Alexa oggi) | |
| # Formato CSV nel ZIP: "rank,domain" | |
| $DownloadUrl = "https://tranco-list.eu/top-1m.csv.zip" | |
| # --- FASE 1: DOWNLOAD E ESTRAZIONE --- | |
| Write-Host "1. Download della lista Top 1 Million (Tranco/Alexa alternative)..." -ForegroundColor Cyan | |
| $ZipPath = "$env:TEMP\top1m.zip" | |
| $ExtractPath = "$env:TEMP\top1m_extracted" | |
| try { | |
| # Scarica il file ZIP | |
| Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipPath -ErrorAction Stop | |
| # Estrae il file | |
| if (Test-Path $ExtractPath) { Remove-Item $ExtractPath -Recurse -Force } | |
| Expand-Archive -Path $ZipPath -DestinationPath $ExtractPath -Force | |
| # Trova il file CSV estratto (il nome cambia spesso, prendiamo il primo .csv) | |
| $CsvFile = Get-ChildItem -Path $ExtractPath -Filter "*.csv" | Select-Object -First 1 | |
| Write-Host " File scaricato ed estratto: $($CsvFile.Name)" -ForegroundColor Green | |
| } | |
| catch { | |
| Write-Error "Errore durante il download o estrazione: $_" | |
| return | |
| } | |
| # --- FASE 2: CARICAMENTO DOMINI --- | |
| Write-Host "2. Caricamento dei primi $MaxDomainsToCheck siti..." -ForegroundColor Cyan | |
| # Legge il CSV. Tranco non ha header, è formato da: Rank, Domain | |
| $SiteList = Get-Content $CsvFile.FullName | Select-Object -First $MaxDomainsToCheck | ForEach-Object { | |
| $Parts = $_ -split "," | |
| if ($Parts.Count -ge 2) { | |
| "https://" + $Parts[1] # Prende la seconda colonna (dominio) e aggiunge https | |
| } | |
| } | |
| Write-Host " Caricati $($SiteList.Count) domini per l'analisi." -ForegroundColor Green | |
| Write-Host "---------------------------------------------------" | |
| # --- FASE 3: SCANSIONE SSL (Multi-Threaded per velocità) --- | |
| # Usiamo un approccio sequenziale semplice qui per stabilità, | |
| # per 10k siti ci vorrebbe tempo. Questo loop è ottimizzato con Timeout basso. | |
| $Results = @() | |
| [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 | |
| $Counter = 0 | |
| foreach ($Url in $SiteList) { | |
| $Counter++ | |
| $Status = "Unknown" | |
| $Issuer = "N/A" | |
| $Color = "White" | |
| # Percentuale progresso | |
| $Percent = [math]::Round(($Counter / $SiteList.Count) * 100) | |
| Write-Progress -Activity "Checking SSL Inspection" -Status "$Counter of $($SiteList.Count) ($Percent%)" -CurrentOperation "Checking $Url" | |
| try { | |
| $Request = [System.Net.HttpWebRequest]::Create($Url) | |
| $Request.Method = "HEAD" | |
| $Request.Timeout = 2000 # 2 secondi max per sito per velocizzare | |
| $Request.AllowAutoRedirect = $false # Non seguire redirect per risparmiare tempo | |
| $Response = $Request.GetResponse() | |
| $Response.Close() | |
| if ($Request.ServicePoint.Certificate) { | |
| $Cert = $Request.ServicePoint.Certificate | |
| $Issuer = $Cert.Issuer | |
| if ($Issuer -match $InspectionKeyword) { | |
| $Status = "⚠️ ISPEZIONATO" | |
| $Color = "Red" | |
| } else { | |
| $Status = "✅ BYPASSED" | |
| $Color = "Green" | |
| } | |
| } else { | |
| $Status = "No Cert" | |
| $Color = "Gray" | |
| } | |
| } catch { | |
| # Spesso errore 403/401 o Timeout su siti che bloccano HEAD requests | |
| $Status = "❌ ERR/TIMEOUT" | |
| $Color = "DarkGray" | |
| } | |
| Write-Host "[$Counter] $Status `t $Url" -ForegroundColor $Color | |
| $Results += [PSCustomObject]@{ | |
| Rank = $Counter | |
| URL = $Url | |
| Stato = $Status | |
| Issuer = $Issuer | |
| } | |
| } | |
| # --- FASE 4: ESPORTAZIONE --- | |
| $Results | Export-Csv -Path $CsvReportPath -NoTypeInformation -Encoding UTF8 | |
| Write-Host "" | |
| Write-Host "Scansione completata. Report salvato in: $CsvReportPath" -ForegroundColor Cyan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment