From d352a8e6e70b20576a9d885f3c655568576f4395 Mon Sep 17 00:00:00 2001 From: rolen Date: Sun, 20 Jan 2019 23:37:09 +0000 Subject: [PATCH] Correct GZip code to work on v2 --- Modules/PortScanner.ps1 | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Modules/PortScanner.ps1 b/Modules/PortScanner.ps1 index 2c7336e..f4a9cfc 100644 --- a/Modules/PortScanner.ps1 +++ b/Modules/PortScanner.ps1 @@ -58,9 +58,25 @@ param( [System.IO.MemoryStream] $output = New-Object System.IO.MemoryStream(45000) [System.IO.MemoryStream] $gzdll = New-Object System.IO.MemoryStream(,[System.Convert]::FromBase64String($ps)) $gzipStream = New-Object System.IO.Compression.GzipStream $gzdll, ([IO.Compression.CompressionMode]::Decompress) - $gzipStream.CopyTo($output) - $gzipStream.Close() - $gzdll.Close() + try { + $buffer = New-Object byte[](32000); + while ($true) + { + $read = $gzipStream.Read($buffer, 0, 32000) + if ($read -le 0) + { + break; + } + $output.Write($buffer, 0, $read) + } + } + finally + { + Write-Verbose "Closing streams and newly decompressed file" + $gzipStream.Close(); + $output.Close(); + $gzdll.Close(); + } $assembly = [System.Reflection.Assembly]::Load($output.ToArray()) } }