From ecda1d9ec26bb0df9e6ad90f10baa2398fc9a4eb Mon Sep 17 00:00:00 2001
From: gpotter2 <gabriel@potter.fr>
Date: Sun, 26 Feb 2017 20:08:48 +0100
Subject: [PATCH] Added download checksum check

---
 .appveyor/InstallWindump.ps1 | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/.appveyor/InstallWindump.ps1 b/.appveyor/InstallWindump.ps1
index c4f2cc0a..0ceb3d23 100644
--- a/.appveyor/InstallWindump.ps1
+++ b/.appveyor/InstallWindump.ps1
@@ -1,4 +1,11 @@
-wget https://github.com/hsluoyz/WinDump/releases/download/v0.2/WinDump-for-Npcap-0.2.zip -UseBasicParsing -OutFile $PSScriptRoot"\npcap.zip"
+# Config
+$urlPath = "https://github.com/hsluoyz/WinDump/releases/download/v0.2/WinDump-for-Npcap-0.2.zip"
+$checksum = "9182934bb822511236b4112ddaa006c95c86c864ecc5c2e3c355228463e43bf2"
+
+############
+############
+# Download the file
+wget $urlPath -UseBasicParsing -OutFile $PSScriptRoot"\npcap.zip"
 Add-Type -AssemblyName System.IO.Compression.FileSystem
 function Unzip
 {
@@ -8,5 +15,14 @@ function Unzip
 }
 Unzip $PSScriptRoot"\npcap.zip" $PSScriptRoot"\npcap"
 Remove-Item $PSScriptRoot"\npcap.zip"
+# Now let's check its checksum
+$_chksum = $(CertUtil -hashfile $PSScriptRoot"\npcap\x64\WinDump.exe" SHA256)[1] -replace " ",""
+if ($_chksum -ne $checksum){
+    echo "Checksums does NOT match !"
+    exit
+} else {
+    echo "Checksums matches !"
+}
+# Finally, move it and remove tmp files
 Move-Item -Force $PSScriptRoot"\npcap\x64\WinDump.exe" "C:\Windows\System32\windump.exe"
 Remove-Item $PSScriptRoot"\npcap" -recurse
-- 
GitLab