mandiant / commando-vm

Complete Mandiant Offensive VM (Commando VM), a fully customizable Windows-based pentesting virtual machine distribution. commandovm@mandiant.com
https://www.mandiant.com/resources/blog/commando-vm-windows-offensive-distribution
Apache License 2.0
6.88k stars 1.28k forks source link

Create Packer and/or Vagrant scripts for install #136

Closed day1player closed 1 year ago

day1player commented 4 years ago

As discussed in #59

day1player commented 4 years ago

Due to Windows Tamper Protection I am not sure this will be a viable option for install.

elreydetoda commented 4 years ago

I haven't looked at the code for this yet, but it looks promising: https://github.com/clong/DetectionLab/pull/307

from, this issues comments: https://github.com/clong/DetectionLab/issues/306

day1player commented 4 years ago

Awesome, thanks again for the help ;-)

elreydetoda commented 4 years ago

no problem :grin: glad to help where I can. thanks @clong for amazing dev work in DetectionLab.

DrJZoidberg commented 4 years ago

@day1player there are a few different ways we can take the packer scripts.

  1. take the template from iso to full machine w/o waiting for snapshots in between. i.e. A-> Z

This would result in 1 VM with 1 final state.

  1. have incremental templates which would do something like so: a. iso -> "clean-ish" machine, which has some required changes to run the commando install script but not much more (disabling tamper protection for instance) A->M b. "clean-ish" -> final produced build. M->Z

This would result in 1 VM with 2 final states (snapshots), or 2 VMs with 1 state each (the b. step above would start by making a clone of the existing "clean-ish" VM to use).

Which do you think you would prefer?

Additionally, which builder targets do you need? right now I'm planning to use virtualbox, vmware-workstation, and hyper-v.

NebulousAnchor commented 4 years ago

@DrJZoidberg I was about to start building packer/vagrant versions tomorrow for a project I am working on to make a quick deployment kit using RHEL Satellite server and Ansible/Vagrant. I anticipate the tamper protection being an issue for a single command packer build. However, I will pass along any lessons learned and the files here if I manage to find a way to do it.

As far as builder targets, I personally will be aiming for libvirt since my host OS for the deploy-able devices will be RHEL.

NebulousAnchor commented 4 years ago

So I found a way to help automate all of the install BUT the final step where I have to type 'ENTER'

In the packer .json file I have a setup.ps1 file, the commando install.ps1 file, the AutoHotKey.exe portable exe, and the attached file (rename from .txt to .ahk) forked onto the box using the file provisioner.

The setup.ps1:

AutoHotKey.exe disable_defender.ahk Set-ExecutionPolicy Unrestricted Unblock-File .\install.ps1 .\install.ps1 -nochecks 1 -password ''

disable_defender.txt

day1player commented 4 years ago

An interesting article here: https://www.bleepingcomputer.com/news/microsoft/malware-can-no-longer-disable-microsoft-defender-via-the-registry/

NebulousAnchor commented 4 years ago

I'm about 95% of the way to a fully automated packer build, right now the sticking point is that Packer thinks the intermediate reboots exit codes mean the end of the provisioning and therefore it fails. The current workaround is to let windows build completely without a shutdown command in Packer. Once the Windows install is done, then run the 'install.ps1' and Packer will ignore the reboots. Once complete run a shutdown and Packer will run any post needed (box file creation).

DrJZoidberg commented 4 years ago

I've been taking a different approach @NebulousAnchor, I'll post up some gists tomorrow, but I'm trying to accomplish everything related to disabling Tamper Protection and Defender in the autounattend.xml file so that it is accomplished during the initial Windows setup.

DrJZoidberg commented 4 years ago

@NebulousAnchor https://gist.github.com/DrJZoidberg/0f749591b9f6a2668d6e5eaa62372b29

You should be able to see that. Now i'm not taking care of tamper protection, but it seems that we are both probably at the same state in terms of disabling Defender. I'll see if there is anyway to disable Tamper Pro some today

NebulousAnchor commented 4 years ago

@DrJZoidberg I need to redo my packer tomorrow. I'll try your files.

day1player commented 3 years ago

https://twitter.com/jonasLyk/status/1293815234805760000

skollr34p3r commented 1 year ago

Create a new issue here if you are still looking to see this happen in CommandoVM: https://github.com/mandiant/VM-Packages/issues/new/choose