From f920d4e7d0225e942d61f5d05b71850525603863 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Tue, 29 Oct 2024 15:39:41 +0100 Subject: [PATCH 1/2] VM-Pip-Install: extend to support list Extend the `VM-Pip-Install` function helper to support a list of Python libraries to install. Use the new feature to simplify the code in `internet_detector`. --- packages/common.vm/common.vm.nuspec | 2 +- packages/common.vm/tools/vm.common/vm.common.psm1 | 10 ++++++---- .../internet_detector.vm/internet_detector.vm.nuspec | 4 ++-- .../internet_detector.vm/tools/chocolateyinstall.ps1 | 6 ++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/common.vm/common.vm.nuspec b/packages/common.vm/common.vm.nuspec index 6a957f5a..8ce9e321 100755 --- a/packages/common.vm/common.vm.nuspec +++ b/packages/common.vm/common.vm.nuspec @@ -2,7 +2,7 @@ common.vm - 0.0.0.20241002 + 0.0.0.20241029 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 c6edc13d..f976e6e0 100755 --- a/packages/common.vm/tools/vm.common/vm.common.psm1 +++ b/packages/common.vm/tools/vm.common/vm.common.psm1 @@ -1737,16 +1737,18 @@ function VM-Get-MSIInstallerPathByProductName { } } -# Install Python library with Pip +# Install Python library/ies with Pip function VM-Pip-Install { param ( - [string]$package + [string]$libraries # Comma-separated list of libraries to install, example: "flare-capa", "flare-capa,tabulate" ) # Create output file to log python module installation details $outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR} - # Ignore warning with `-W ignore` to avoid warnings like deprecation to fail the installation - Invoke-Expression "py -3.10 -W ignore -m pip install $package --disable-pip-version-check 2>&1 >> $outputFile" + ForEach ($library in $libraries.Split(",")) { + # Ignore warning with `-W ignore` to avoid warnings like deprecation to fail the installation + Invoke-Expression "py -3.10 -W ignore -m pip install $library --disable-pip-version-check 2>&1 >> $outputFile" + } } # Install tool using Pip and create shortcut in the Tools directory diff --git a/packages/internet_detector.vm/internet_detector.vm.nuspec b/packages/internet_detector.vm/internet_detector.vm.nuspec index aa7c6ae7..f64f2696 100644 --- a/packages/internet_detector.vm/internet_detector.vm.nuspec +++ b/packages/internet_detector.vm/internet_detector.vm.nuspec @@ -2,11 +2,11 @@ internet_detector.vm - 1.0.0 + 1.0.0.20241029 Elliot Chernofsky and Ana Martinez Gomez Tool that changes the background and a taskbar icon if it detects internet connectivity - + diff --git a/packages/internet_detector.vm/tools/chocolateyinstall.ps1 b/packages/internet_detector.vm/tools/chocolateyinstall.ps1 index a6467801..a999eb58 100644 --- a/packages/internet_detector.vm/tools/chocolateyinstall.ps1 +++ b/packages/internet_detector.vm/tools/chocolateyinstall.ps1 @@ -11,10 +11,8 @@ New-Item -Path $toolDir -ItemType Directory -Force -ea 0 VM-Assert-Path $toolDir # Install pyinstaller (needed to build the Python executable) and tool dependencies ('pywin32') -$dependencies = @('pyinstaller', 'pywin32') -ForEach ($dependency in $dependencies) { - VM-Pip-Install $dependency -} +$dependencies = "pyinstaller,pywin32" +VM-Pip-Install $dependencies # This wrapper is needed because we can't run PyInstaller as admin, so this forces a usermode context. Start-Process -FilePath 'cmd.exe' -ArgumentList "/c pyinstaller --onefile -w --distpath $toolDir --workpath $packageToolDir --specpath $packageToolDir $packageToolDir\internet_detector.pyw" -Wait From 40b06a96aacbbf0d5ae745b025e7829203db4569 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Tue, 29 Oct 2024 15:40:59 +0100 Subject: [PATCH 2/2] Add libraries-extra.python3.vm The FLARE team is working in a new tool and needs the following libraries that are useful in general to develop reverse engineering related tools. --- .../libraries-extra.python3.vm.nuspec | 13 +++++++++++++ .../tools/chocolateyinstall.ps1 | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 packages/libraries-extra.python3.vm/libraries-extra.python3.vm.nuspec create mode 100644 packages/libraries-extra.python3.vm/tools/chocolateyinstall.ps1 diff --git a/packages/libraries-extra.python3.vm/libraries-extra.python3.vm.nuspec b/packages/libraries-extra.python3.vm/libraries-extra.python3.vm.nuspec new file mode 100644 index 00000000..34826c1a --- /dev/null +++ b/packages/libraries-extra.python3.vm/libraries-extra.python3.vm.nuspec @@ -0,0 +1,13 @@ + + + + libraries-extra.python3.vm + 0.0.0.20241029 + Install extra Python useful libraries + Several, check in pypi.org for every of the libraries + + + + + + diff --git a/packages/libraries-extra.python3.vm/tools/chocolateyinstall.ps1 b/packages/libraries-extra.python3.vm/tools/chocolateyinstall.ps1 new file mode 100644 index 00000000..21698fdb --- /dev/null +++ b/packages/libraries-extra.python3.vm/tools/chocolateyinstall.ps1 @@ -0,0 +1,9 @@ +$ErrorActionPreference = 'Stop' +Import-Module vm.common -Force -DisableNameChecking + +try { + $dependencies = "asciinet,bs4,flare_capa,langchain,langchain_google_genai,langchain_openai,networkx,python-statemachine,requests,tabulate,tenacity" + VM-Pip-Install $dependencies +} catch { + VM-Write-Log-Exception $_ +}