diff --git a/cybersecurity/Network Reputation Service/script-nrs.ps1 b/cybersecurity/Network Reputation Service/script-nrs.ps1
index 5a7b48c..f3f2097 100644
--- a/cybersecurity/Network Reputation Service/script-nrs.ps1
+++ b/cybersecurity/Network Reputation Service/script-nrs.ps1
@@ -1,7 +1,7 @@
# Script d'Audit Firewall - Network Reputation Service
# Auteur: Hubert Cornet
# Date: 03/09/2025
-# Version: 1.0
+# Version: 1.1
Clear-Host
@@ -9,6 +9,22 @@ Clear-Host
$ErrorActionPreference = "Continue"
$WarningPreference = "SilentlyContinue"
+# Couleurs pour les grades
+$GradeColors = @{
+ 'A+' = '#28a745'
+ 'A' = '#52b83a'
+ 'B+' = '#7ac92e'
+ 'B' = '#a3da23'
+ 'C+' = '#cceb17'
+ 'C' = '#f5f90c'
+ 'D+' = '#f7d808'
+ 'D' = '#f9b604'
+ 'E+' = '#fb9500'
+ 'E' = '#fd7300'
+ 'F+' = '#ff5100'
+ 'F' = '#dc3545'
+}
+
### Functions ###
## Function Write-ColorOutput
@@ -337,89 +353,285 @@ Function Generate-HtmlReport {
$Grade = Convert-ScoreToGrade -Score $Score
$CategoryScores += [PSCustomObject]@{
- Category = $cat.Name
- Score = $score
- Grade = $grade
- Color = $GradeColors[$grade]
- TotalUrls = $cat.Group.Count
- CorrectResults = ($cat.Group | Where-Object IsCorrect).Count
+ Category = $Cat.Name
+ Score = $Score
+ Grade = $Grade
+ Color = $GradeColors[$grade]
+ TotalUrls = $Cat.Group.Count
+ CorrectResults = ($Cat.Group | Where-Object IsCorrect).Count
+ Results = $Cat.Group
}
}
# Score global
- $globalScore = Calculate-CategoryScore -Results $Results
- $globalGrade = Convert-ScoreToGrade -Score $globalScore
+ $GlobalScore = Calculate-CategoryScore -Results $Results
+ $GlobalGrade = Convert-ScoreToGrade -Score $GlobalScore
+ $GlobalColor = $GradeColors[$globalGrade]
- # Création du rapport HTML
- New-HTML -TitleText "Audit Firewall - Network Reputation Service" -Online -FilePath $OutputPath {
- New-HTMLHeader {
- New-HTMLText -Text "Audit Firewall - Network Reputation Service" -FontSize 28 -FontWeight bold -Color Blue -Alignment center
- New-HTMLText -Text "Rapport généré le $(Get-Date -Format 'dd/MM/yyyy à HH:mm')" -FontSize 14 -Color Gray -Alignment center
+ # Génération du HTML
+ $HtmlContent = @"
+
+
+
+
+
🛡️ Audit Firewall - Network Reputation Service
+
Rapport généré le $(Get-Date -Format 'dd/MM/yyyy à HH:mm')
- New-HTMLSection -HeaderText "Scores par Catégorie" -BackgroundColor LightGray {
- New-HTMLTable -DataTable $categoryScores -HideFooter {
- New-HTMLTableHeader -Names "Category", "Score", "Grade", "TotalUrls", "CorrectResults" -Title "Scores par Catégorie"
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'A+' -BackgroundColor '#28a745' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'A' -BackgroundColor '#52b83a' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'B+' -BackgroundColor '#7ac92e' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'B' -BackgroundColor '#a3da23' -Color Black
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'C+' -BackgroundColor '#cceb17' -Color Black
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'C' -BackgroundColor '#f5f90c' -Color Black
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'D+' -BackgroundColor '#f7d808' -Color Black
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'D' -BackgroundColor '#f9b604' -Color Black
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'E+' -BackgroundColor '#fb9500' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'E' -BackgroundColor '#fd7300' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'F+' -BackgroundColor '#ff5100' -Color White
- New-HTMLTableCondition -Name 'Grade' -ComparisonType string -Operator eq -Value 'F' -BackgroundColor '#dc3545' -Color White
- }
- }
+
+
+
📊 Résumé Exécutif
+
+
+
$globalGrade
+
$globalScore%
+
Score Global
+
+
+
📋 Total des URLs testées : $($Results.Count)
+
✅ URLs correctement filtrées : $(($Results | Where-Object IsCorrect).Count)
+
🎯 Taux de réussite : $([math]::Round((($Results | Where-Object IsCorrect).Count / $Results.Count) * 100, 2))%
+
📅 Date du test : $(Get-Date -Format 'dd/MM/yyyy HH:mm')
+
+
+
- New-HTMLSection -HeaderText "Détail des Tests par Catégorie" -BackgroundColor White {
- foreach ($category in $categories) {
- $catScore = ($categoryScores | Where-Object Category -eq $category.Name).Score
- $catGrade = ($categoryScores | Where-Object Category -eq $category.Name).Grade
-
- New-HTMLSection -HeaderText "$($category.Name) - Score: $catScore% ($catGrade)" -BackgroundColor LightYellow -Collapsible {
- $detailedResults = $category.Group | Select-Object Url, Reputation, ExpectedAction, Status, IsCorrect, Error
- New-HTMLTable -DataTable $detailedResults -HideFooter {
- New-HTMLTableCondition -Name 'IsCorrect' -ComparisonType string -Operator eq -Value 'True' -BackgroundColor '#d4edda' -Color '#155724'
- New-HTMLTableCondition -Name 'IsCorrect' -ComparisonType string -Operator eq -Value 'False' -BackgroundColor '#f8d7da' -Color '#721c24'
- }
- }
- }
- }
-
- New-HTMLSection -HeaderText "Barème de Notation" -BackgroundColor LightGreen -Collapsible {
- $gradingScale = @(
- [PSCustomObject]@{Grade='A+'; Score='95-100%'; Interpretation='Excellent / Parfait'}
- [PSCustomObject]@{Grade='A'; Score='90-95%'; Interpretation='Très bon niveau de filtrage'}
- [PSCustomObject]@{Grade='B+'; Score='85-90%'; Interpretation='Très bon'}
- [PSCustomObject]@{Grade='B'; Score='80-85%'; Interpretation='Bon, mais quelques ajustements nécessaires'}
- [PSCustomObject]@{Grade='C+'; Score='75-80%'; Interpretation='Assez bon'}
- [PSCustomObject]@{Grade='C'; Score='70-75%'; Interpretation='Moyen, lacunes importantes'}
- [PSCustomObject]@{Grade='D+'; Score='65-70%'; Interpretation='Passable'}
- [PSCustomObject]@{Grade='D'; Score='60-65%'; Interpretation='Faible, filtrage inefficace'}
- [PSCustomObject]@{Grade='E+'; Score='55-60%'; Interpretation='Très faible'}
- [PSCustomObject]@{Grade='E'; Score='50-55%'; Interpretation='Insuffisant'}
- [PSCustomObject]@{Grade='F+'; Score='45-50%'; Interpretation='Critique'}
- [PSCustomObject]@{Grade='F'; Score='0-45%'; Interpretation='Très faible, action immédiate requise'}
- )
-
- New-HTMLTable -DataTable $gradingScale -HideFooter
- }
+
+
+
📈 Scores par Catégorie
+
+
+
+ Catégorie |
+ Score (%) |
+ Note |
+ URLs Totales |
+ Résultats Corrects |
+
+
+
+"@
+
+ # Ajout des lignes du tableau
+ Foreach ($CatScore in $CategoryScores) {
+ $htmlContent += @"
+
+ $($catScore.Category) |
+ $($catScore.Score)% |
+ $($catScore.Grade) |
+ $($catScore.TotalUrls) |
+ $($catScore.CorrectResults) |
+
+"@
}
+
+ $HtmlContent += @"
+
+
+
+
+
+
+
🔍 Détail des Tests par Catégorie
+
+"@
+
+ # Ajout des catégories
+ $categoryIndex = 0
+
+ Foreach ($CatScore in $CategoryScores) {
+ $CategoryIndex++
+ $HtmlContent += @"
+
+
+
+
+
+
+ URL |
+ Réputation |
+ Action Attendue |
+ Statut |
+ Correct |
+
+
+
+"@
+
+ # Ajout des résultats de chaque URL
+ Foreach ($result in $catScore.Results) {
+ $rowClass = if ($result.IsCorrect) { "correct" } else { "incorrect" }
+ $correctText = if ($result.IsCorrect) { "✅ Oui" } else { "❌ Non" }
+
+ $htmlContent += @"
+
+ $($result.Url.Substring(0, [Math]::Min(30, $result.Url.Length)))$(if($result.Url.Length -gt 30){"..."}) |
+ $($result.Reputation) |
+ $($result.ExpectedAction) |
+ $($result.Status) |
+ $correctText |
+
+"@
+ }
+
+ $htmlContent += @"
+
+
+
+
+"@
+ }
+
+ $htmlContent += @"
+
+
+
+
+
+
📏 Barème de Notation
+
+"@
+
+ # Ajout du barème de notation
+ $gradingScale = @(
+ @{Grade='A+'; Score='95-100%'; Interpretation='Excellent / Parfait'; Color='#28a745'}
+ @{Grade='A'; Score='90-95%'; Interpretation='Très bon niveau de filtrage'; Color='#52b83a'}
+ @{Grade='B+'; Score='85-90%'; Interpretation='Très bon'; Color='#7ac92e'}
+ @{Grade='B'; Score='80-85%'; Interpretation='Bon, quelques ajustements nécessaires'; Color='#a3da23'}
+ @{Grade='C+'; Score='75-80%'; Interpretation='Assez bon'; Color='#cceb17'}
+ @{Grade='C'; Score='70-75%'; Interpretation='Moyen, lacunes importantes'; Color='#f5f90c'}
+ @{Grade='D+'; Score='65-70%'; Interpretation='Passable'; Color='#f7d808'}
+ @{Grade='D'; Score='60-65%'; Interpretation='Faible, filtrage inefficace'; Color='#f9b604'}
+ @{Grade='E+'; Score='55-60%'; Interpretation='Très faible'; Color='#fb9500'}
+ @{Grade='E'; Score='50-55%'; Interpretation='Insuffisant'; Color='#fd7300'}
+ @{Grade='F+'; Score='45-50%'; Interpretation='Critique'; Color='#ff5100'}
+ @{Grade='F'; Score='0-45%'; Interpretation='Très faible, action immédiate requise'; Color='#dc3545'}
+ )
+
+ Foreach ($gradeInfo in $gradingScale) {
+ $htmlContent += @"
+
+
$($gradeInfo.Grade)
+
+ $($gradeInfo.Score)
+ $($gradeInfo.Interpretation)
+
+
+"@
+ }
+
+ $htmlContent += @"
+
+
+
- Write-ColorOutput "✓ Rapport généré: $OutputPath" "Green"
+
+
+
+"@
+
+ # Écriture du fichier HTML
+ Try {
+ $htmlContent | Out-File -FilePath $OutputPath -Encoding UTF8
+ Write-ColorOutput "✓ Rapport généré: $OutputPath" "Green"
+ }
+ Catch {
+ Write-ColorOutput "ERREUR: Impossible de générer le rapport: $($_.Exception.Message)" "Red"
+ }
}
## Function Main
@@ -495,11 +707,11 @@ Function Main {
Write-ColorOutput "✓ Résultats sauvegardés: $JsonResultsPath" "Green"
Write-ColorOutput "`n=== AUDIT TERMINÉ ===" "Green"
- Write-ColorOutput "Rapport disponible à: $ReportPath" "Cyan"
+ Write-ColorOutput "`n Rapport disponible à: $ReportPath" "Cyan"
# Ouverture automatique du rapport
If (Get-Command "Start-Process" -ErrorAction SilentlyContinue) {
- $OpenReport = Read-Host "Voulez-vous ouvrir le rapport maintenant? (O/N)"
+ $OpenReport = Read-Host "`n Voulez-vous ouvrir le rapport maintenant? (O/N)"
If ($OpenReport -eq "O" -or $OpenReport -eq "o" -or $OpenReport -eq "Y" -or $OpenReport -eq "y") {
Start-Process $ReportPath
}