mandiant / flare-vm

A collection of software installations scripts for Windows systems that allows you to easily setup and maintain a reverse engineering environment on a VM.
Apache License 2.0
6.35k stars 896 forks source link

flare-vm & boxstarter 3.0.0 doesn't support Chocolatey 2 (use of deprecated cinst) #456

Closed DanAsBjorn closed 1 year ago

DanAsBjorn commented 1 year ago

Installing fails after clicking ok on the GUI part of install with the output

common.vm v0.0.0.20230526 (forced)
common.vm package files install completed. Performing other installation steps.
[+] VM_COMMON_DIR set to: C:\ProgramData\_VM
[+] PSModulePath set to: C:\ProgramData\_VM;C:\ProgramData\Boxstarter;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
[+] TOOL_LIST_DIR set to: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Tools
[+] TOOL_LIST_SHORTCUT set to: C:\Users\Dan\Desktop\Tools.lnk
[+] RAW_TOOLS_DIR set to: C:\Tools
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The install of common.vm was successful.
  Software install location not explicitly set, it could be in package or
  default install location of installer.

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Refreshing environment variables from the registry for powershell.exe. Please wait...
Finished
chocolatey : The term 'chocolatey' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\ProgramData\_VM\vm.common\vm.common.psm1:843 char:18
+     $chocoInfo = chocolatey --version
+                  ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (chocolatey:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException

Looking at line 843-846 of C:\ProgramData_VM\vm.common\vm.common.psm1 it looks like it is using the command chocolatey rather than choco

 $chocoInfo = chocolatey --version
    $installedPackages = chocolatey list -l -r -all
    $boxstarerInfo = $installedPackages | Select-String -Pattern "Boxstarter" | Out-String
    $installedPackages = $installedPackages | Out-String

Example:

PS C:\Windows\system32> chocolatey --version
chocolatey : The term 'chocolatey' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ chocolatey --version
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (chocolatey:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32> choco --version
2.0.0
PS C:\Windows\system32>

looks like 843 and 844 need changing to choco.

DanAsBjorn commented 1 year ago

I am running chocolatey version 2.0

DanAsBjorn commented 1 year ago

https://github.com/mandiant/VM-Packages/issues/409

Looks like the issue

moatazabdullah commented 1 year ago

I have the same issue, you can run this command "Set-Alias -Name chocolatey -Value choco". It worked for me!

DanAsBjorn commented 1 year ago

cool, pretty simple! I just ended up deleting chocolatey and running $env:chocolateyVersion = '1.4.0' before the install script

basegdp commented 1 year ago

Setting the Alias fixed the issue for me however is now resulting in a call depth overflow. See error below.

"Invoke-ChocolateyBoxstarter : The script failed due to call depth overflow. At line:1 char:151

Any idea how to resolve?

moatazabdullah commented 1 year ago

Reinstalling chocolatey with version 1.4.0 should fix the issue.

$env:chocolateyVersion = '1.4.0'

Run this in powershell and run the install.ps1 script it should work

Ana06 commented 1 year ago

This is caused by Boxstarter not being compatible with Chocolatey 2 (released few days ago) as it uses the deprecated (now removed) cinst. As @moatazabdullah mentions, you can run $env:chocolateyVersion = '1.4.0' before installing flare-vm till https://github.com/chocolatey/boxstarter/pull/533 fix is merged and released.

Ana06 commented 1 year ago

We should update the boxstarter version check after https://github.com/chocolatey/boxstarter/pull/533 is released (it is already merged)