Skip to content

Instantly share code, notes, and snippets.

@ioncodes
Last active March 19, 2022 20:44
Show Gist options
  • Save ioncodes/2383d35fe7ddf8d52333f7cb0b1e6a85 to your computer and use it in GitHub Desktop.
Save ioncodes/2383d35fe7ddf8d52333f7cb0b1e6a85 to your computer and use it in GitHub Desktop.
Spinning up Vagrant boxes for driver
WinDbgX -k net:port=53390,key=1.1.1.1
vagrant halt -f
bcdedit /debug on
bcdedit /dbgsettings net hostip:192.168.229.1 port:53390 key:1.1.1.1
copy C:\vagrant\guest\onboot.bat C:\onboot.bat
schtasks /create /sc onstart /tr "C:\onboot.bat" /tn vagrantonboot /ru SYSTEM /f
shutdown /r /t 0
sc stop layle
sc delete layle
sc create layle binPath= "C:\Windows\System32\drivers\layle.sys" type= kernel
copy C:\vagrant\layle.sys C:\Windows\System32\drivers
sc start layle
vagrant up --provider vmware_workstation
set /p DUMMY=Hit ENTER to continue...
vagrant powershell --command "schtasks /run /tn vagrantonboot"

Based off of this article

  1. Install the VMWare Vagrant Utility. Reboot your machine afterwards.
  2. Set up a Windows 10 VM as you normally would. Keep the hardware requirements (CPU and RAM) to a minimum.
  3. In the VM:
    1. Install the VMWare guest tools
    2. Disable Shutdown Tracker
    3. Disable complex passwords
    4. Set network adapter to "Private"
    5. Enable RDP
    6. Disable Driver Signature Enforcement and enable Test Sign mode
    7. Completely disable UAC: In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System set EnabledLUA to 0
    8. Install all pending updates (optional)
    9. To redirect debug messages to WinDbg (optional): In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager create the key Debug Print Filter. Add a DWORD entry called DEFAULT with value 0xFFFFFFFF
  4. Shutdown VM
  5. Open the "Virtual Network Editor" and hit "Change Settings". Select NAT in the list and then NAT Settings. Set UDP timeout to 32767 or WinDbg may get disconnected
  6. Go to the folder containing the vmx file
  7. Execute tar cvzf Win10ProBase.box ./*. This is the equivalent of running vagrant package for VBox.
  8. If step 7 fails create a file called metadata.json in that directory with the following content:
    {
     "provider": "vmware_desktop"
    }
  9. Execute vagrant box add layle/win10pro .\Win10ProBase.box
  10. You are all set now. Use the attached files to spin up your boxes

Make sure to update the host IP in the batch files to your own host IP!

Vagrant.configure("2") do |config|
config.vm.guest = :windows # tell Vagrant this is a Windows-based guest
config.vm.communicator = "winrm" # use winrm for management instead of ssh
config.vm.provider 'vmware_workstation' do |p|
p.linked_clone = false
end
config.vm.provider :vmware_desktop do |p|
p.vmx["ethernet0.pcislotnumber"] = "160"
end
config.winrm.password = "vagrant" # the credentials specified during OS install
config.winrm.username = "vagrant"
config.vm.define "win10" do |win10|
win10.vm.box = "layle/win10pro" # edit this to be the name of the box you created
win10.vm.provision "shell", path: "guest/kdbg.bat" # this batch file will be run inside the VM
win10.vm.network :forwarded_port, guest: 49152, host: 53390 # expose kernel debugging port to host
win10.vm.network :forwarded_port, guest: 3389, host: 53389 # expose RDP port to host
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment