Skip to content

Commit

Permalink
Add psnotify.vm package
Browse files Browse the repository at this point in the history
  • Loading branch information
vm-packages authored and emtuls committed Oct 20, 2023
1 parent 297f991 commit c710a30
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/psnotify.vm/psnotify.vm.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>psnotify.vm</id>
<version>0.2.4</version>
<authors>alphillips-lab</authors>
<description>A POC tool to fight .NET anti-dumping tricks.</description>
<dependencies>
<dependency id="common.vm" />
</dependencies>
</metadata>
</package>
67 changes: 67 additions & 0 deletions packages/psnotify.vm/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

try {
$toolName = 'psnotify'
$category = 'dotNet'

$zipUrl = 'https://github.com/WithSecureLabs/GarbageMan/releases/download/v0.2.4/psnotify.zip'
$zipSha256 = '255633da6e61bf30a67bce995ef72b7f9d8c85c75c8c5ee0aedb48709f7e6454'

<<<<<<< HEAD
$unzipLocation = 'C:\' # psnotify has a requirement of being located in 'C:\psnotify'
$toolDir = Join-Path $unzipLocation $toolName

try {
$toolDir = Join-Path $unzipLocation $toolName
$shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category

# Remove files from previous zips for upgrade
VM-Remove-PreviousZipPackage ${Env:chocolateyPackageFolder}

# Snapshot all folders in $toolDir
$oldDirList = @()
if (Test-Path $toolDir) {
$oldDirList = @(Get-ChildItem $toolDir | Where-Object {$_.PSIsContainer})
}

# Download and unzip
$packageArgs = @{
packageName = ${Env:ChocolateyPackageName}
unzipLocation = $unzipLocation
url = $zipUrl
checksum = $zipSha256
checksumType = 'sha256'
url64bit = $zipUrl_64
checksum64 = $zipSha256_64
}
Install-ChocolateyZipPackage @packageArgs
VM-Assert-Path $toolDir

# Diff and find new folders in $toolDir
$newDirList = @(Get-ChildItem $toolDir | Where-Object {$_.PSIsContainer})
$diffDirs = Compare-Object -ReferenceObject $oldDirList -DifferenceObject $newDirList -PassThru

$executablePath = Join-Path $toolDir "$toolName.exe" -Resolve
$shortcut = Join-Path $shortcutDir "$toolName.lnk"

$executableDir = $toolDir
Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $executablePath -WorkingDirectory $executableDir

VM-Assert-Path $shortcut

Install-BinFile -Name $toolName -Path $executablePath
return $executablePath
} catch {
VM-Write-Log-Exception $_
}
VM-Assert-Path $toolDir
=======
$executablePath = (VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -innerFolder $true)
$innerPath = Join-Path $executablePath[0] "psnotify" -Resolve
Move-Item -Path $innerPath -Destination "C:\" -Force -ea 0
Remove-Item $executablePath -Force -ea 0
>>>>>>> 70efef8 (Add psnotify.vm package)
} catch {
VM-Write-Log-Exception $_
}
15 changes: 15 additions & 0 deletions packages/psnotify.vm/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = 'psnotify'
$category = 'dotNet'
$toolDir = 'C:\psnotify'

# Remove tool files
Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null

# Remove tool shortcut
VM-Remove-Tool-Shortcut $toolName $category

# Uninstall binary
Uninstall-BinFile -Name $toolName

0 comments on commit c710a30

Please sign in to comment.