Skip to content

Create Binary Ninja package #1229

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

Merged
merged 5 commits into from
May 13, 2025
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
15 changes: 15 additions & 0 deletions packages/binaryninja.vm/binaryninja.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>binaryninja.vm</id>
<version>4.2.6455.20250417</version>
<authors>Vector 35, Inc.</authors>
<description>Binary Ninja is an interactive decompiler, disassembler, debugger, and binary analysis platform built by reverse engineers, for reverse engineers.</description>
<dependencies>
<dependency id="common.vm" version="0.0.0.20250509" />
<!-- vcbuildtools.vm installs signtool.exe needed by VM-Assert-Signature -->
<dependency id="vcbuildtools.vm" />
</dependencies>
<tags>Disassemblers</tags>
</metadata>
</package>
22 changes: 22 additions & 0 deletions packages/binaryninja.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

$toolName = "binaryninja"
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)

try {
$url = "https://cdn.binary.ninja/installers/$($toolName)_free_win64.exe"
$executablePath = Join-Path ${Env:ProgramFiles} "Vector35\$toolName\$toolName.exe"

VM-Install-With-Installer -toolName $toolName `
-category $category `
-fileType 'EXE' `
-silentArgs '/S /ALLUSERS=1' `
-executablePath $executablePath `
-url $url `
-consoleApp $false `
-verifySignature

} catch {
VM-Write-Log-Exception $_
}
10 changes: 10 additions & 0 deletions packages/binaryninja.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = "binaryninja"
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)

VM-Uninstall-With-Uninstaller -toolName $toolName `
-category $category `
-fileType "EXE" `
-silentArgs "/S /ALLUSERS=1"
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.20250425</version>
<version>0.0.0.20250509</version>
<description>Common libraries for VM-packages</description>
<authors>Mandiant</authors>
</metadata>
Expand Down
43 changes: 37 additions & 6 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,18 @@ function VM-Install-From-Zip {
if ($verifySignature) {
# Check signature of all executable files individually
Get-ChildItem -Path "$toolDir\*.exe" | ForEach-Object {
$file = $_
try {
# Check signature for each file
VM-Assert-Signature $_.FullName
VM-Assert-Signature $file.FullName
} catch {
# Remove the file with invalid signature
Write-Warning "Removing file '$($_.FullName)' due to invalid signature"
Remove-Item $_.FullName -Force -ea 0 | Out-Null
VM-Write-Log-Exception $_
if ($_.Exception.Message -like "INVALID SIGNATURE*")
{
# Remove the file with invalid signature
VM-Write-Log "ERROR" "Removing file '$($file.FullName)' due to invalid signature"
Remove-Item $file.FullName -Force -ea 0 | Out-Null
}
}
}
}
Expand Down Expand Up @@ -738,6 +742,8 @@ function VM-Install-With-Installer {
[Parameter(Mandatory=$false)]
[bool] $consoleApp=$false,
[Parameter(Mandatory=$false)]
[switch] $verifySignature,
[Parameter(Mandatory=$false)]
[string] $arguments = "",
[Parameter(Mandatory=$false)]
[string] $iconLocation
Expand All @@ -753,9 +759,15 @@ function VM-Install-With-Installer {
$packageArgs = @{
packageName = ${Env:ChocolateyPackageName}
url = $url
checksum = $sha256
checksumType = "sha256"
}

# Add checksum details only if signature verification is not requested
if (-not $verifySignature)
{
$packageArgs.checksum = $sha256
$packageArgs.checksumType = 'sha256'
}

if ($ext -in @("zip", "7z")) {
VM-Remove-PreviousZipPackage ${Env:chocolateyPackageFolder}
$unzippedDir= Join-Path $toolDir "$($toolName)_installer"
Expand All @@ -781,6 +793,25 @@ function VM-Install-With-Installer {
VM-Assert-Path $installerPath
}

if ($verifySignature) {
# Check signature of all executable files individually
Get-ChildItem -path $toolDir -include *.msi, *.exe -recurse -File -ea 0 | ForEach-Object {
$file = $_
try {
# Check signature for each file
VM-Assert-Signature $file.FullName
} catch {
VM-Write-Log-Exception $_
if ($_.Exception.Message -like "INVALID SIGNATURE*")
{
# Remove the file with invalid signature
VM-Write-Log "ERROR" "Removing file '$($file.FullName)' due to invalid signature"
Remove-Item $file.FullName -Force -ea 0 | Out-Null
}
}
}
}

# Install tool via native installer
$packageArgs = @{
packageName = ${Env:ChocolateyPackageName}
Expand Down
Loading