Creating Base Images for Sandbox
Windows Packer Template
This is a basic Windows 10 and 7 Packer template for building VM images.
Requirements
- Packer
- QEMU & KVM
- MAKE
- Windows ISOs
- VMware Workstation Pro
- Rufus
Packer Installation
Install Packer from the official documentation
Getting packages
make download-packages # Or manually download all the packages in packages.txt into the folder 'Packages', mostly for Windows 7
Downloading ISOs
Installation of Windows 10 and 11
- Enable Check for Updates in Rufus
- Restart Rufus
- Wait for Select Button to have drop down
- Select Download
- Choose Windows Version
- Languge English (United States) -- > For Autounattend file. Wrong Language will cause it to not install.
- Choose Architecture (Windows 11 does not have x86)
Installation of Windows 7
Download the x86 and x64 ISO here
Loading the ISO file
Update the directory and hashes accordingly in variables.pkr.hcl
See build.*.pkr.hcl for the file names and hashes.
Building images on QEMU
# Both Windows 10 images:
packer build -on-error=ask -only 10.qemu.* .
# Only Windows 7 64-bit images:
packer build -on-error=ask -only 7.qemu.x64 .
# Only Windows 10 32-bit images:
packer build -on-error=ask -only 10.qemu.x86 .
Estimated build time on an NVMe SSD, i7-8700K:
- Windows 10 / 11: 2 hours
- Windows 7: 24 hours
- Due to slow Windows updates
Building images on VMware
# Only when getting errors
packer build -on-error=ask -only 10.vmware-iso.x86 .
packer build -on-error=ask -only 10.vmware-iso.x64 .
packer build -on-error=ask -only 11.vmware-iso.x64 .
Estimated build time on an NVMe SSD, i7-8700K:
- Windows 10 / 11: 2 hours
- Windows 7: 4 hours
- Due to slow Windows updates
VMWare Workstation Pro network mapping Error
If you encounter this problem with VMWare
7.vmware-iso.x64: Could not determine network mappings from files in path: C:/Program Files (x86)/VMware/VMware Workstation
7.vmware-iso.x64: Step "stepCreateVMX" failed
- Go to VMWare > Edit > Virtual Network Editor
- Requires Admin priviledges: Change Settings
- Click Ok and Exit
This will create the Network Mapping that is missing in VMware Workstation. For more info, please visit here
VM check list
- Sysmon installed
- Certificate Removed if added
- UAC Removed (Run cmd and u should be admin)
- Check if
Agent.pyis running <IP:8000> - Remove Windows Store and Mail on the Task Bar
- Windows Defender removed or Windows Security Center turned off
- [Noise Reduced] (#Things to note for Noise Reduction before snapshotting in KVM / QEMU)
Removing Windows Defender
Youtube link to remove Windows Defender
Boot into safe mode to remove privileges
- Open
msconfig.exe - Boot Tab --> Boot options --> Safe boot --> Minimal
- Restart
C:\ProgramData\Microsoft- Windows Defender Properties
- Security Change Owner from SYSTEM --> Administrators
- Tick all child object permission entries
- Remove all user permissions
- Disable Safeboot in
msconfig.exe
Disabling Windows 7 Security Center
- Services
- Disable Security Center (The WSCSV)
Things to note for Noise Reduction before snapshotting in KVM / QEMU
-
Chrome and Edge
- Rename Chrome and Edge updater file
Program Files\Google\Update\GoogleUpdate.exeProgram Files\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe
-
Disable Windows Update Service
- Windows Services
- Disable Windows Update
-
Set Static IP address for the Vm
- IP for the VM
- Gateway and DNS to be the same
-
Ensure that all the Driver has been installed properly
- PCI Driver
- Ethernet Controller
- Display Drivers
-
Restart Computer after changes had been made
Converting VMX to qcow2
Command to convert VMDK to Qcow2
qemu-img convert -f vmdk -O qcow2 disk.vmdk win<ver>-<arch>bit-base.qcow2
Current Base Machine Versioning
Windows 11x64v3
- Removed Windows Defender
- Removed Windows Store in Environment Variable
- Java Installed
- Security Updates Removed
Windows 10x64v3
- Removed Windows Defender
- Removed Windows Store in Environment Variable
- Java Installed
- Security Updates Removed
Windows 10x86v3
- Removed Windows Defender
- Removed Windows Store in Environment Variable
- Java Installed
- Security Updates Removed
Windows 7x64v3
- Windows Security Center turned off
- Java Installed
- Security Updates Removed
Windows 7x86v3
- Windows Security Center turned off
- Java Installed
- Security Updates Removed
If you have a Certificate Authority, copy the CA .cer file into optional/root.cer