diff --git a/packages/common.vm/common.vm.nuspec b/packages/common.vm/common.vm.nuspec index 234e5f9c4..02e7c5da5 100755 --- a/packages/common.vm/common.vm.nuspec +++ b/packages/common.vm/common.vm.nuspec @@ -2,7 +2,7 @@ common.vm - 0.0.0.20240425 + 0.0.0.20240429 Common libraries for VM-packages Mandiant diff --git a/packages/common.vm/tools/vm.common/vm.common.psm1 b/packages/common.vm/tools/vm.common/vm.common.psm1 index 146ae123e..2f13aa18f 100755 --- a/packages/common.vm/tools/vm.common/vm.common.psm1 +++ b/packages/common.vm/tools/vm.common/vm.common.psm1 @@ -288,7 +288,10 @@ function VM-Get-IDA-Plugins-Dir { return New-Item "$Env:APPDATA\Hex-Rays\IDA Pro\plugins" -ItemType "directory" -Force } -# Downloads an IDA plugin file to the plugins directory +# Downloads an IDA plugin file or ZIP containing a plugin (and supporting files/directories) to the plugins directory. +# For ZIPs, we check if there is an inner folder (this is the case for GH ZIPs) and if there is a directory called 'plugins'. +# We copy all files in this directory with the exception of the README and the LICENSE file (often present in GH repos). +# The copied files must include $pluginName. function VM-Install-IDA-Plugin { [CmdletBinding()] [OutputType([System.Object[]])] @@ -302,17 +305,52 @@ function VM-Install-IDA-Plugin { [string] $pluginSha256 ) try { + $pluginExtension = [System.IO.Path]::GetExtension($pluginUrl) $pluginsDir = VM-Get-IDA-Plugins-Dir $pluginPath = Join-Path $pluginsDir $pluginName - $packageArgs = @{ - packageName = ${Env:ChocolateyPackageName} - url = $pluginUrl - checksum = $pluginSha256 - checksumType = "sha256" - fileFullPath = $pluginPath - forceDownload = $true + + if ($pluginExtension -eq ".zip") { + $tempDownloadDir = Join-Path ${Env:chocolateyPackageFolder} "temp_$([guid]::NewGuid())" + # Download and unzip + $packageArgs = @{ + packageName = ${Env:ChocolateyPackageName} + unzipLocation = $tempDownloadDir + url = $pluginUrl + checksum = $pluginSha256 + checksumType = 'sha256' + } + Install-ChocolateyZipPackage @packageArgs | Out-Null + VM-Assert-Path $tempDownloadDir + + # Check if there is inner folder (for example for ZIPs downloaded from GH) + $childItems = Get-ChildItem $tempDownloadDir -ea 0 + if (($childItems).Count -eq 1) { + $subDir = Join-Path $tempDownloadDir $childItems + if (Test-Path $subDir -PathType Container) { + $tempDownloadDir = $subDir + } + } + # Look for the plugins directory + $pluginDir = Get-Item "$tempDownloadDir\plugins" -ea 0 + if (!$pluginDir) { $pluginDir = $tempDownloadDir } + + # Delete files we don't want to copy + Remove-Item "$pluginDir\README*" -Force -ea 0 + Remove-Item "$pluginDir\LICENSE*" -Force -ea 0 + + Copy-Item "$pluginDir\*" $pluginsDir -Recurse + } + else { + $packageArgs = @{ + packageName = ${Env:ChocolateyPackageName} + url = $pluginUrl + checksum = $pluginSha256 + checksumType = "sha256" + fileFullPath = $pluginPath + forceDownload = $true + } + Get-ChocolateyWebFile @packageArgs } - Get-ChocolateyWebFile @packageArgs VM-Assert-Path $pluginPath } catch { VM-Write-Log-Exception $_ diff --git a/packages/ida.plugin.dereferencing.vm/ida.plugin.dereferencing.vm.nuspec b/packages/ida.plugin.dereferencing.vm/ida.plugin.dereferencing.vm.nuspec new file mode 100644 index 000000000..a9523c9e7 --- /dev/null +++ b/packages/ida.plugin.dereferencing.vm/ida.plugin.dereferencing.vm.nuspec @@ -0,0 +1,12 @@ + + + + ida.plugin.dereferencing.vm + 0.0.0.20240430 + danigargu + IDA Pro plugin that implements new registers and stack views. + + + + + diff --git a/packages/ida.plugin.dereferencing.vm/tools/chocolateyinstall.ps1 b/packages/ida.plugin.dereferencing.vm/tools/chocolateyinstall.ps1 new file mode 100644 index 000000000..3c99b5991 --- /dev/null +++ b/packages/ida.plugin.dereferencing.vm/tools/chocolateyinstall.ps1 @@ -0,0 +1,8 @@ +$ErrorActionPreference = 'Stop' +Import-Module vm.common -Force -DisableNameChecking + +$pluginName = 'dereferencing.py' +$pluginUrl = 'https://github.com/danigargu/deREferencing/archive/c5c606a9e70bff48214ce5286a37b15752fd8d1b.zip' +$pluginSha256 = '3ddec5c7569bc53883c5feaeb36d1145e2dde1c67491d14929af05938870dc1e' + +VM-Install-IDA-Plugin -pluginName $pluginName -pluginUrl $pluginUrl -pluginSha256 $pluginSha256 diff --git a/packages/ida.plugin.dereferencing.vm/tools/chocolateyuninstall.ps1 b/packages/ida.plugin.dereferencing.vm/tools/chocolateyuninstall.ps1 new file mode 100644 index 000000000..82ca4cab2 --- /dev/null +++ b/packages/ida.plugin.dereferencing.vm/tools/chocolateyuninstall.ps1 @@ -0,0 +1,6 @@ +$ErrorActionPreference = 'Continue' +Import-Module vm.common -Force -DisableNameChecking + +$pluginName = 'dereferencing.py' +VM-Uninstall-IDA-Plugin -pluginName $pluginName + diff --git a/scripts/utils/create_package_template.py b/scripts/utils/create_package_template.py index 8d6b3f85f..a6f897491 100755 --- a/scripts/utils/create_package_template.py +++ b/scripts/utils/create_package_template.py @@ -44,7 +44,7 @@ def package_version(dependency_version): {authors} {description} - +