kafl.targets icon indicating copy to clipboard operation
kafl.targets copied to clipboard

Running the example windows_x64_x86 example error

Open 0xDivyanshu-new opened this issue 1 year ago • 2 comments

Hi team,

I am currently trying to get the snapshot by importing the vm into libvrt as defined in the docs mentioned here.

vagrant up --no-provision
Bringing machine 'vagrant-kafl-windows' up with 'libvirt' provider...
==> vagrant-kafl-windows: No version detected for kafl_windows, using timestamp to watch for modifications. Consider
==> vagrant-kafl-windows: generating a local metadata for the box with a version to allow better handling.
==> vagrant-kafl-windows: See https://www.vagrantup.com/docs/boxes/format#box-metadata for further details.
==> vagrant-kafl-windows: Creating image (snapshot of base box volume).
==> vagrant-kafl-windows: Creating domain with the following settings...
==> vagrant-kafl-windows:  -- Name:              windows_x86_64_vagrant-kafl-windows
==> vagrant-kafl-windows:  -- Description:       Source: /home/XXX/Research/Windows/Fuzzing/kafl.targets/windows_x86_64/Vagrantfile
==> vagrant-kafl-windows:  -- Domain type:       kvm
==> vagrant-kafl-windows:  -- Cpus:              4
==> vagrant-kafl-windows:  -- CPU topology:      sockets=1, cores=4, threads=1
==> vagrant-kafl-windows:  -- Feature:           acpi
==> vagrant-kafl-windows:  -- Feature:           apic
==> vagrant-kafl-windows:  -- Feature:           pae
==> vagrant-kafl-windows:  -- Clock offset:      utc
==> vagrant-kafl-windows:  -- Memory:            4096M
==> vagrant-kafl-windows:  -- Base box:          kafl_windows
==> vagrant-kafl-windows:  -- Storage pool:      default
==> vagrant-kafl-windows:  -- Image(vda):        /home/XXX/.local/share/libvirt/images/windows_x86_64_vagrant-kafl-windows.img, ide, 64G
==> vagrant-kafl-windows:  -- Disk driver opts:  cache='default'
==> vagrant-kafl-windows:  -- Graphics Type:     spice
==> vagrant-kafl-windows:  -- Graphics Websocket: 
==> vagrant-kafl-windows:  -- Graphics Port:     
==> vagrant-kafl-windows:  -- Graphics IP:       
==> vagrant-kafl-windows:  -- Graphics Password: Not defined
==> vagrant-kafl-windows:  -- Video Type:        cirrus
==> vagrant-kafl-windows:  -- Video VRAM:        16384
==> vagrant-kafl-windows:  -- Video 3D accel:    false
==> vagrant-kafl-windows:  -- Keymap:            en-us
==> vagrant-kafl-windows:  -- TPM Backend:       passthrough
==> vagrant-kafl-windows:  -- INPUT:             type=mouse, bus=ps2
==> vagrant-kafl-windows:  -- CHANNEL:             type=spicevmc, mode=
==> vagrant-kafl-windows:  -- CHANNEL:             target_type=virtio, target_name=com.redhat.spice.0
Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: internal error: Failed to start QEMU binary /usr/local/bin/qemu-system-x86_64 for probing: 
make: *** [Makefile:13: init] Error 1
❯ vim Vagrantfile

I am not really quite sure on what is the exact issue here. Before that i was getting permission denied issues but those got fixed by fixing the apparmor.

I was able to create the box and it was added to vagrant

❯ vagrant box list
kafl_windows (libvirt, 0)

I also ran the vagrant up command with debug flag but there is literally no message that says what exactly went wrong that failed virDomainDefineXML. This is the error snippet when running with debug flag

ERROR warden: Error occurred: Error while creating domain: Error saving the server: Call to virDomainDefineXML failed: internal error: Failed to start QEMU binary /usr/local/bin/qemu-system-x86_64 for probing: 
 INFO warden: Beginning recovery process...
 INFO warden: Calling recover: #<VagrantPlugins::ProviderLibvirt::Action::CleanupOnFailure:0x00007f390df7a510>

0xDivyanshu-new avatar Aug 27 '24 08:08 0xDivyanshu-new

Hi !

I've never seen this error before. Also you altready toggled the debug output (which is great), but doesn't give us much information. "Failed to start QEMU binary /usr/local/bin/qemu-system-x86_64 for probing"

Can you try posting it on the https://github.com/vagrant-libvirt/vagrant-libvirt project ?

Side note: what was the last time you successfuly built the Windows template ? I tried it on Monday, and it breaks when reaching the VSIX extension setup.

I didn't manage to fix it yet, so I can't test vagrant provisioning again for the moment.

Wenzel avatar Aug 29 '24 13:08 Wenzel

Hi @Wenzel ,

Thanks for the response. So i tried 2 things basically.

  • First, i used the hashicorp qemu that was specified as dependency as part of kafl windows template. I was also facing issues with VSIX setup but i removed that line from the playbook since I was not interested in fuzzing the vulnerable driver. I just wanted to get the setup working so that i can move it to my target. Apart from the VSIX issue, I also had to add path field for the lastest windows WSDK and SDK for the auto install to happen. Not sure if its part of new versions. Something like this :-
sdk_setup.exe /q /installpath "C:\\Program Files\\Windows Kits\\10" /norestart /log po.txt

After removing the VSIX extension line, i was facing the main error that i just shared here in the issue.

  • Secondly, i saw that by default it is using the hashicorp qemu in windows.pkr.hcl rather than the one that i built by make deploy with kafl support. So i removed the hashicorp dependency and installed the qemu with kafl support system wide by make install from x86_64-softmmu directory.

After doing that, I started facing issues with the OS installation part itself which is way before the execution of playbook commands inside VM.

I think the 2nd approach is the right once since we are supposed to use the qemu that was build with kafl support rather than using the hashicorp's default qemu plugin.

Would love to know your inputs on this!

Thanks

0xDivyanshu-new avatar Aug 30 '24 05:08 0xDivyanshu-new

Hi, sorry I lost track of this issue.

After doing that, I started facing issues with the OS installation part itself

What kind of Windows installation issues did you face ? BSOD ?

Wenzel avatar Jan 30 '25 13:01 Wenzel

@Wenzel I am having the same issue right now. Did you solve it?

jakydibe avatar Feb 26 '25 20:02 jakydibe

Hi, sorry I lost track of this issue.

After doing that, I started facing issues with the OS installation part itself

What kind of Windows installation issues did you face ? BSOD ?

Nevermind. I solved it just doing fresh install. By the way lik 9 times out of 10 make build failes wqhile installing windowsSDK qemu.windows: TASK [Install Windows11SDK 10.0.22621.0] *************************************** qemu.windows: fatal: [default]: FAILED! => changed=true

jakydibe avatar Feb 27 '25 00:02 jakydibe

Hi @jakydibe

Indeed, this new playbook task is rather unstable. I also had to launch the build multiple times until it worked out. Providing an image on Vagrant Cloud would be more practical, i'll see how if i can arrange that.

thanks for your input !

Wenzel avatar Feb 27 '25 04:02 Wenzel