Skip to content

Commit

Permalink
Merge pull request #1088 from d35ha/fix-VM-Uninstall-With-Uninstaller…
Browse files Browse the repository at this point in the history
…-category

Fix the calls to VM-Uninstall-With-Uninstaller
  • Loading branch information
emtuls committed Jun 20, 2024
2 parents a0c9e86 + c7065fc commit 1b8dcd8
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/7zip-15-05.vm/7zip-15-05.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>7zip-15-05.vm</id>
<version>15.05.0.20240507</version>
<version>15.05.0.20240614</version>
<authors>Igor Pavlov</authors>
<description>7-Zip file archiver. This version is able to extract NSIS scripts.</description>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages/7zip-15-05.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $category = 'Productivity Tools'
VM-Uninstall $toolName $category

# Manually silently uninstall
VM-Uninstall-With-Uninstaller "7-Zip 15.05*" "EXE" "/S"
VM-Uninstall-With-Uninstaller "7-Zip 15.05*" $category "EXE" "/S"

$extensions = @(".7z", ".bzip2", ".gzip", ".tar", ".wim", ".xz", ".txz", ".zip", ".rar")
foreach ($extension in $extensions) {
Expand Down
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.20240607</version>
<version>0.0.0.20240620</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
25 changes: 21 additions & 4 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,6 @@ function VM-Uninstall-With-Uninstaller {
# Remove tool shortcut
VM-Remove-Tool-Shortcut $toolName $category

# Remove tool files
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName
Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null

# Attempt to find and execute the uninstaller, may need to use wildcards
# See: https://docs.chocolatey.org/en-us/create/functions/get-uninstallregistrykey
[array]$key = Get-UninstallRegistryKey -SoftwareName $toolName
Expand All @@ -821,6 +817,10 @@ function VM-Uninstall-With-Uninstaller {
$key | ForEach-Object {VM-Write-Log "WARN" " - $($_.DisplayName)"}
VM-Write-Log "WARN" "Now allowing Chocolatey's auto uninstaller a chance to run."
}

# Remove tool files
$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName
Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null
}

function VM-Write-Log-Exception {
Expand Down Expand Up @@ -1789,3 +1789,20 @@ function VM-Uninstall-With-Pip {
VM-Pip-Uninstall $toolName
VM-Remove-Tool-Shortcut $toolName $category
}

# Converts image file to .ico needed for file icons
function VM-Create-Ico {
param (
[string]$imagePath
)
Add-Type -AssemblyName System.Drawing
$imageDirPath = Split-Path -Path $imagePath -Parent
$filenameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($imagePath)
$iconLocation = Join-Path $imageDirPath "$($filenameWithoutExtension).ico"
$bitmap = [System.Drawing.Bitmap]::FromFile($imagePath)
$icon = [System.Drawing.Icon]::FromHandle($bitmap.GetHicon())
$fs = New-Object System.IO.FileStream($iconLocation, 'OpenOrCreate')
$icon.Save($fs)
$fs.Close()
return $iconLocation
}
2 changes: 1 addition & 1 deletion packages/cyberchef.vm/cyberchef.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>cyberchef.vm</id>
<version>10.18.6</version>
<version>10.18.6.20240620</version>
<authors>GCHQ</authors>
<description>The Cyber Swiss Army Knife - a web app for encryption, encoding, compression, data analysis, and more.</description>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages/cyberchef.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ try {
Install-ChocolateyZipPackage @packageArgs
VM-Assert-Path $toolDir

$iconLocation = VM-Create-Ico (Join-Path $toolDir "images\cyberchef-128x128.png") # Create .ico for cyberchef icon
$shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category
$shortcut = Join-Path $shortcutDir "$toolName.lnk"
$executableCmd = Join-Path ${Env:WinDir} "system32\cmd.exe" -Resolve
$htmlPath = Join-Path $toolDir "CyberChef_v10.18.6.html" -Resolve
$arguments = "start chrome $htmlPath && exit"
$executableArgs = "/C $arguments"
$iconLocation = "%ProgramFiles%\Google\Chrome\Application\chrome.exe"

Install-ChocolateyShortcut -ShortcutFilePath $shortcut -TargetPath $executableCmd -Arguments $executableArgs -WorkingDirectory $toolDir -WindowStyle 7 -IconLocation $iconLocation

Expand Down
2 changes: 1 addition & 1 deletion packages/explorersuite.vm/explorersuite.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>explorersuite.vm</id>
<version>0.0.0.20230925</version>
<version>0.0.0.20240614</version>
<authors>Erik Pistelli</authors>
<description>A suite of tools including CFF Explorer and a process viewer.</description>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages/explorersuite.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ foreach ($subtoolName in $subtoolNames) {

VM-Remove-From-Right-Click-Menu 'CFF explorer'

VM-Uninstall-With-Uninstaller "Explorer Suite IV" "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
VM-Uninstall-With-Uninstaller "Explorer Suite IV" $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
2 changes: 1 addition & 1 deletion packages/metasploit.vm/metasploit.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>metasploit.vm</id>
<version>6.4.13.20240613</version>
<version>6.4.13.20240614</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>
Expand Down
2 changes: 1 addition & 1 deletion packages/metasploit.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $category = 'Command & Control'
VM-Uninstall $toolName $category

# Silently uninstall
VM-Uninstall-With-Uninstaller $toolName "MSI" "/q /norestart"
VM-Uninstall-With-Uninstaller $toolName $category "MSI" "/q /norestart"

# Remove directory, shortcut, shim
VM-Uninstall $toolName $category
2 changes: 1 addition & 1 deletion packages/nmap.vm/nmap.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>nmap.vm</id>
<version>7.93.20230418.20240102</version>
<version>7.93.20230418.20240614</version>
<authors>Fyodor, Nmap Project</authors>
<description>Port scanning utility and nc replacement with extended features</description>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages/nmap.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try {
Uninstall-BinFile -Name "zenmap"

# Silently uninstall
VM-Uninstall-With-Uninstaller "Nmap*" "EXE" "/S"
VM-Uninstall-With-Uninstaller "Nmap*" $category "EXE" "/S"
} catch {
VM-Write-Log-Exception $_
}
Expand Down
2 changes: 1 addition & 1 deletion packages/npcap.vm/npcap.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>npcap.vm</id>
<version>1.79.0.20240606</version>
<version>1.79.0.20240614</version>
<authors>Nmap Project</authors>
<description>Npcap is an architecture for packet capture and network analysis for Windows operating systems, consisting of a software library and a network driver.</description>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion packages/npcap.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

VM-Uninstall-With-Uninstaller "Npcap*" "EXE" "/S"
VM-Uninstall-With-Uninstaller "Npcap*" "" "EXE" "/S"

2 changes: 1 addition & 1 deletion packages/vbdec.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $toolName = 'vbdec'
$category = 'Visual Basic'

# Silently uninstall
VM-Uninstall-With-Uninstaller $toolName "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
VM-Uninstall-With-Uninstaller $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"

# Remove directory, shortcut, shim
VM-Uninstall $toolName $category
Expand Down
2 changes: 1 addition & 1 deletion packages/vbdec.vm/vbdec.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>vbdec.vm</id>
<version>1.0.917.20240217</version>
<version>1.0.917.20240614</version>
<authors>vbGamer45, David Zimmer</authors>
<description>VBDec works as a VB6 disassembler, PCode debugger, structure viewer for all vb6 executables, and can generate IDA scripts to integrate structures and named function offsets.</description>
<dependencies>
Expand Down

0 comments on commit 1b8dcd8

Please sign in to comment.