Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve VM-Assert-Signature & restore hash installation for RegCool #1157

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/common.vm/common.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>common.vm</id>
<version>0.0.0.20241029</version>
<version>0.0.0.20241106</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
18 changes: 9 additions & 9 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ function VM-Assert-Path {
}
}

# Raise an exception if the Signature of $file_path is invalid
# Raise an exception if the signtool.exe is not found or if the signature of $filePath is invalid
# vcbuildtools.vm installs signtool.exe
function VM-Assert-Signature {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[String] $file_path
[String] $filePath
)
$signature_status = (Get-AuthenticodeSignature -FilePath $file_path).Status
if ($signature_status -eq 'Valid') {
VM-Write-Log "INFO" "Valid signature: $file_path"
} else {
$err_msg = "Invalid signature: $file_path"
VM-Write-Log "ERROR" $err_msg
throw $err_msg
$signtoolPath = Get-ChildItem -Path "C:\Program Files*\Windows Kits\10\bin\*\x86\signtool.exe" | Select-Object -Last 1
if (-Not $signtoolPath) { throw "signtool.exe not found" }

& $signtoolPath verify /pa /all /tw /q $filePath
if ($LASTEXITCODE) {
throw "INVALID SIGNATURE: $filePath"
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/googlechrome.vm/googlechrome.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>googlechrome.vm</id>
<version>0.0.0.20241002</version>
<version>0.0.0.20241106</version>
<authors>Google LLC.</authors>
<description>Chrome is a popular web browser.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240425" />
<dependency id="common.vm" version="0.0.0.20241106" />
<dependency id="vcbuildtools.vm" />
</dependencies>
</metadata>
</package>
5 changes: 3 additions & 2 deletions packages/metasploit.vm/metasploit.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>metasploit.vm</id>
<version>6.4.13.20240614</version>
<version>6.4.13.20241106</version>
<authors>Rapid7</authors>
<description>A computer security project that provides information about security vulnerabilities, aids in penetration testing, and IDS signature development.</description>
<dependencies>
<dependency id="common.vm" />
<dependency id="common.vm" version="0.0.0.20241106" />
<dependency id="vcbuildtools.vm" />
</dependencies>
</metadata>
</package>
2 changes: 1 addition & 1 deletion packages/regcool.vm/regcool.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>regcool.vm</id>
<version>0.0.0.20240411</version>
<version>2.015</version>
<authors>Kurt Zimmermann</authors>
<description>In addition to all the features that you can find in RegEdit and RegEdt32, RegCool adds many powerful features that allow you to work faster and more efficiently with registry related tasks</description>
<dependencies>
Expand Down
34 changes: 2 additions & 32 deletions packages/regcool.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,8 @@ Import-Module vm.common -Force -DisableNameChecking

$toolName = 'RegCool'
$category = 'Registry'
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName

$zipUrl = 'https://kurtzimmermann.com/files/RegCoolX64.zip'
$zipSha256 = '8fde37cf66024eb68be3c0e34125540f855626935f1cffc0fb7409f3ba343870'

try {
# Download zip
$packageArgs = @{
packageName = $env:ChocolateyPackageName
file = Join-Path ${Env:TEMP} $toolName
url = $zipUrl
}
$filePath = Get-ChocolateyWebFile @packageArgs

# Extract zip
Get-ChocolateyUnzip -FileFullPath $filePath -Destination $toolDir

# Check signature of all unzip files
Get-ChildItem -Path "$toolDir\*.{exe,dll}" | ForEach-Object {
VM-Assert-Signature $_.FullName
}
} catch {
# Remove files with invalid signature
Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null
VM-Write-Log-Exception $_
}

try {
$shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category
$shortcut = Join-Path $shortcutDir "$toolname.lnk"
$toolPath = Join-Path $toolDir "$toolName.exe"
Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $toolPath
VM-Assert-Path $shortcut
} catch {
VM-Write-Log-Exception $_
}
VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp $false -innerFolder $false
5 changes: 3 additions & 2 deletions packages/sysinternals.vm/sysinternals.vm.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>sysinternals.vm</id>
<version>0.0.0.20240717</version>
<version>0.0.0.20241106</version>
<authors>Mark Russinovich, Bryce Cogswell</authors>
<description>Sysinternals suite.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20240111" />
<dependency id="common.vm" version="0.0.0.20241106" />
<dependency id="vcbuildtools.vm" />
</dependencies>
</metadata>
</package>
Loading