Scrut1ny / Hypervisor-Phantom

A type 1 & 2 hypervisor setup guide for evading detection from Proctors and Anti-Cheats.
142 stars 24 forks source link

Error in building qemu environment #14

Open romanholidaypancakes opened 2 months ago

romanholidaypancakes commented 2 months ago

I followed the commands at each step according to QEMU + Virt-Manager Setup

/root/Downloads/qemu/hw/usb/canokey.c:39:    [STR_SERIALNUMBER]     = "0"
/root/Downloads/qemu/hw/usb/dev-storage.c:52:    [STR_SERIALNUMBER] = "1",
/root/Downloads/qemu/hw/usb/u2f.c:51:    [STR_SERIALNUMBER]     = "0",
/root/Downloads/qemu/hw/usb/dev-wacom.c:69:    [STR_SERIALNUMBER]     = "1",
grep: /root/Downloads/qemu/roms/edk2/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory
/root/Downloads/qemu/hw/ide/core.c:2633:                 "QM%05d", s->drive_serial);
grep: /root/Downloads/qemu/roms/edk2/EmulatorPkg/Unix/Host/X11IncludeHack: No such file or directory
root@admin-wx:~/Downloads/qemu# cd $HOME/Downloads
git clone --depth 1 --branch v8.2.6 https://gitlab.com/qemu-project/qemu.git
cd qemu/ && git apply v8.2.6.patch && cd .. mkdir qemu_build && cd qemu_build
../qemu/configure --target-list=x86_64-softmmu,x86_64-linux-user --prefix=/usr
make -j $(nproc)
sudo make install
sudo mv -f qemu-system-x86_64 /bin
fatal: destination path 'qemu' already exists and is not an empty directory.
error: can't open patch 'v8.2.6.patch': No such file or directory
Using './build' as the directory for build output
python determined to be '/usr/bin/python3'
python version: Python 3.10.12

*** Ouch! ***

Python's ensurepip module is not found.
It's normally part of the Python standard library, maybe your distribution packages it separately?
Either install ensurepip, or alleviate the need for it in the first place by installing pip and setuptools for '/usr/bin/python3'.
(Hint: Debian puts ensurepip in its python3-venv package.) 

ERROR: python venv creation failed

changing dir to build for make ""...
make[1]: Entering directory '/root/Downloads/qemu/build'
make[1]: Makefile: No such file or directory
make[1]: *** No rule to make target 'Makefile'.  Stop.
make[1]: Leaving directory '/root/Downloads/qemu/build'
make: *** [GNUmakefile:6: build] Error 2
changing dir to build for make "install"...
make[1]: Entering directory '/root/Downloads/qemu/build'
make[1]: Makefile: No such file or directory
make[1]: *** No rule to make target 'Makefile'.  Stop.
make[1]: Leaving directory '/root/Downloads/qemu/build'
make: *** [GNUmakefile:6: build] Error 2
mv: cannot stat 'qemu-system-x86_64': No such file or directory
Scrut1ny commented 2 months ago

You're missing Python's pip and venv modules first of all. Second of all why aren't you using the bash script I made for automating the installation? I also no longer really maintain this project, I'm working on another version that's much better. I won't be releasing it for a while though.

sudo apt -y install python3-venv python3-pip
romanholidaypancakes commented 2 months ago

New error

Installing /root/Downloads/qemu/pc-bios/petalogix-ml605.dtb to /usr/share/qemu
Installing /root/Downloads/qemu/build/pc-bios/descriptors/50-edk2-i386-secure.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/build/pc-bios/descriptors/50-edk2-x86_64-secure.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/build/pc-bios/descriptors/60-edk2-aarch64.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/build/pc-bios/descriptors/60-edk2-arm.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/build/pc-bios/descriptors/60-edk2-i386.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/build/pc-bios/descriptors/60-edk2-x86_64.json to /usr/share/qemu/firmware
Installing /root/Downloads/qemu/pc-bios/keymaps/sl to /usr/share/qemu/keymaps
Installing /root/Downloads/qemu/pc-bios/keymaps/sv to /usr/share/qemu/keymaps
make[1]: Leaving directory '/root/Downloads/qemu/build'
mv: cannot stat 'qemu-system-x86_64': No such file or directory

But the file seems to exist

image

Maybe I should execute Auto-Hypervisor.sh?

Scrut1ny commented 2 months ago

Yes, try using Auto-Hypervisor.sh I made it for automating the process of setting up a custom version of QEMU.

romanholidaypancakes commented 2 months ago

image I'm using Ubuntu and it detects it as Debian, should I choose option 2? I selected 2 and kept selecting yes but it didn't seem to do anything

Scrut1ny commented 2 months ago

Ubuntu is based on Debian bruh, and yes select option 2. If it doesn't do anything it actually is, you need wait. It has to install and setup a lot.

romanholidaypancakes commented 2 months ago

How can I be sure it is done and can be used? https://streamable.com/yjjx7v

Scrut1ny commented 2 months ago

Yeah that didn't look right at all, It'll take a lot longer than that. You're going to have to troubleshoot the issues and fix them. I no longer maintain the script, and I'm working on a different better version. What I recommend doing is running everything manually, one by one and figure out where shit breaks. It'll be easy to identify the issue from there and fix it.

Scrut1ny commented 2 months ago

@romanholidaypancakes Alright, I just took the time and fixed up the manual guide a lot on the readme. Go take a look and follow the new updated instructions. There should be no reason why anything messes up honestly.

romanholidaypancakes commented 2 months ago

@romanholidaypancakes Alright, I just took the time and fixed up the manual guide a lot on the readme. Go take a look and follow the new updated instructions. There should be no reason why anything messes up honestly.

Maybe you shouldn't assume that the user's computer has curl

user-admin@admin-wx:~$ cd $HOME/Downloads
curl -sSO "https://download.qemu.org/qemu-8.2.6.tar.xz"
tar xJf "qemu-8.2.6.tar.xz" && cd "qemu-8.2.6"
Command 'curl' not found, but can be installed with:
sudo snap install curl  # version 8.1.2, or
sudo apt  install curl  # version 7.81.0-1ubuntu1.17
See 'snap info curl' for additional versions.
tar (child): qemu-8.2.6.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
romanholidaypancakes commented 2 months ago

I've now come to this step: https://github.com/Scrut1ny/Hypervisor-Phantom#modify-grubcfg, maybe this can be automated via commands as well?

I'll leave it like this for now. I don't know if it will have any effect.

image

romanholidaypancakes commented 2 months ago

Can I modify /etc/modprobe.d/vfio.conf and /etc/default/grub at the same time and then restart? This can save one restart (I'm trying this now


The output of executing the following command after restarting (was the gpu passthrough set up successfully?

image

romanholidaypancakes commented 2 months ago

In this step: https://github.com/Scrut1ny/Hypervisor-Phantom#virtual-machine-manager-guide , can I start using an existing virtual machine file(qcow2) so that I can reuse it instead of having to re-start it every time? Install

romanholidaypancakes commented 2 months ago

I don't have /usr/share/OVMF/OVMF_CODE_4M.ms.fd here (It's strange that my system is 64-bit but recognized as i686

image

romanholidaypancakes commented 2 months ago

Now I'm stuck here maybe it's something other than my firmware issue?

image

Scrut1ny commented 2 months ago

@romanholidaypancakes Alright, I just took the time and fixed up the manual guide a lot on the readme. Go take a look and follow the new updated instructions. There should be no reason why anything messes up honestly.

Maybe you shouldn't assume that the user's computer has curl

user-admin@admin-wx:~$ cd $HOME/Downloads
curl -sSO "https://download.qemu.org/qemu-8.2.6.tar.xz"
tar xJf "qemu-8.2.6.tar.xz" && cd "qemu-8.2.6"
Command 'curl' not found, but can be installed with:
sudo snap install curl  # version 8.1.2, or
sudo apt  install curl  # version 7.81.0-1ubuntu1.17
See 'snap info curl' for additional versions.
tar (child): qemu-8.2.6.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Well curl is a very common tool thats used a lot, I'll add it to the required packages lol.

I've now come to this step: https://github.com/Scrut1ny/Hypervisor-Phantom#modify-grubcfg, maybe this can be automated via commands as well?

I'll leave it like this for now. I don't know if it will have any effect.

image

Yes, that can certainly be automated. I've already developed it, it just wasn't working perfectly right in this public version of the script. In my private version though it's perfect and works great. Also your PCI IDs are wrong, Idk if you looked at the tutorials or not but when did it ever say to put the same ID 4 times in a row? Each ID is supposed to be unique. Depending on what PCI device you pick you need to collect ALL PCI IDs from the same device. You can grep for the device you're looking for by just looking for the first part of the ID, everything behind the colon.

Can I modify /etc/modprobe.d/vfio.conf and /etc/default/grub at the same time and then restart? This can save one restart (I'm trying this now

The output of executing the following command after restarting (was the gpu passthrough set up successfully?

image

Yes, you can modify both first then restart. Just make sure to rebuild the bootloader and initramfs for the GPU to actually get isolated!

And no it wasn't successful, if you read the guide it literally says:

image

In this step: https://github.com/Scrut1ny/Hypervisor-Phantom#virtual-machine-manager-guide , can I start using an existing virtual machine file(qcow2) so that I can reuse it instead of having to re-start it every time? Install

Yes, you can reuse it.

I don't have /usr/share/OVMF/OVMF_CODE_4M.ms.fd here (It's strange that my system is 64-bit but recognized as i686

image

Yes, that is incorrect. You need to point to use the CORRECT one in the XML in the VMM (Virtual Machine Manager). The arch we use is obviously x86 and not i686.

Now I'm stuck here maybe it's something other than my firmware issue?

image

yes.

romanholidaypancakes commented 2 months ago

The four identical IDs are just because I don't know where to get the correct one, I thought I could just use a random one.

romanholidaypancakes commented 2 months ago

I think there is something wrong with Virtual Machine Manager recognizing iso/qcow2, it mistakenly recognizes x86_64 as i686, how can I launch it from the command line

Scrut1ny commented 2 months ago

The four identical IDs are just because I don't know where to get the correct one, I thought I could just use a random one.

No, you cant just use a random one xD. It's easy getting the correct ones. I'll show you the easiest way.

List only GPUs/iGPUs

lspci | grep -i vga | sort

Example Output:

00:02.0 VGA compatible controller: Intel Corporation Device 3e92 (rev 02)
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1eb8 (rev a1)

Extract the bus number from the PCI device of your choice.

00:02.0 means:

So our Bus number would be 00.

So in the terminal now run this:

bus_number=00

Now we Find the matching devices and extract HWIDs automatically

HWID="$(lspci -nn | grep -E "^${bus_number}:[0-9a-f]{2}.[0-9a-f]" | sed -n 's/.*\[\([0-9a-f:]*\)\].*/\1/p' | paste -sd, -)"

Now we can echo out the vfio-pci.ids variable we just set and you can see the string you'll be copying and pasting into grub.cfg and the vfio.conf. We can automate this process by running these convenient commands I made though.

Create or overwrite vfio.conf with the necessary options

VFIO_CONF_PATH='/etc/modprobe.d/vfio.conf'
echo -e "options vfio-pci ids=${HWID}\nsoftdep nvidia pre: vfio-pci" | sudo tee "$VFIO_CONF_PATH"

Now we'll also modify the grub configuration & update your system.

IOMMU_SETTING="intel_iommu=on"

sudo sed -i '/etc/default/grub' -f - <<EOF
s#^\(GRUB_CMDLINE_LINUX_DEFAULT=".*\)"\$\
#\1 ${IOMMU_SETTING} iommu=pt vfio-pci.ids=${HWID} "#
EOF

sudo update-grub && sudo update-initramfs

After this, just reboot and now you're GPU of choice will be being used with vfio kernel drivers.

To check just run this command and you'll see the GPU you chose now is under vfio-pci kernel driver control.

lspci -k | grep -E "vfio-pci"
Scrut1ny commented 2 months ago

I think there is something wrong with Virtual Machine Manager recognizing iso/qcow2, it mistakenly recognizes x86_64 as i686, how can I launch it from the command line

There isn't, it's your fault. You need to go to the VMM XML config and manually FIX the specified path of the emulator its using and the edk2 / ovmf (firmware / UEFI) file also.

WARNING: OURS WON'T BE THE SAME. You need to learn how everything works and NOT just blindly copy and paste shit. This is an example of how it SHOULD look though. Also since you're on Intel you need to make sure certain stuff is set to Intel.

image image
romanholidaypancakes commented 2 months ago

I re-executed the command according to https://github.com/Scrut1ny/Hypervisor-Phantom/issues/14#issuecomment-2341562537

image

Doesn't seem to be set up correctly

Scrut1ny commented 2 months ago

Then fix it, it's not that hard. There's plenty of examples and tutorials online, you need to try harder. It isn't that complicated.

romanholidaypancakes commented 2 months ago

I am basically using Windows and don't know much about some Linux commands. I will try

Scrut1ny commented 2 months ago

Yikes, well this is a horrible idea. Suddenly trying to switch to linux and do vfio stuff is fucking wild xD. You need to understand linux first and tons of stuff about. Also I recommend Arch Linux, don't use Ubuntu. That shit is bloated and just shit.