-
-
Save darkhypervisor/0ca11d02d91be64350fbc747afe153b5 to your computer and use it in GitHub Desktop.
Revisions
-
doomedraven revised this gist
Dec 16, 2018 . 1 changed file with 190 additions and 119 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,38 @@ #!/bin/bash # # For latest version please check https://github.com/doomedraven/Tools/blob/master/Virtualization/kvm-qemu.sh # # https://www.doomedraven.com/2016/05/kvm.html # Use Ubuntu 18.04 LTS # 14.12.2018 - QEMU 3.1, libvirt-2.10 # 10.11.2018 - Virt-manager 2, libivrt-4.9, fixes # 11.09.2018 - code improvement # 09.09.2018 - ACPI fixes - huge thanks to @2sec4u and @seifreed for your patience and your time/help :P # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # https://www.shellcheck.net/ # ACPI tables related # https://wiki.archlinux.org/index.php/DSDT # Dump on linux # acpidump > acpidump.out # Dump on Windows # https://acpica.org/downloads/binary-tools # acpixtract -a acpi/4/acpi.dump # acpixtract -a acpidump.out # iasl -d DSDT.dat # Decompile: iasl -d dsdt.dat # Recompile: iasl -tc dsdt.dsl # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ @@ -34,32 +42,33 @@ # strs[5] = "VBoxVBoxVBox"; /* VirtualBox */ #https://www.qemu.org/download/#source or https://download.qemu.org/ qemu_version=3.1.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.10.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version=2.0.0 # autofilled OS="" username="" function usage() { cat << EndOfHelp Usage: $0 <func_name> <args> Commands - are case insensitive: All - <username_optional> - Execs QEMU/SeaBios/KVM, username is optional QEMU - Install QEMU from source SeaBios - Install SeaBios and repalce QEMU bios file KVM - this will install intel-HAXM if you on Mac HAXM - Mac Hardware Accelerated Execution Manager Clone - <VM_NAME> <path_to_hdd> <start_from_number> <#vm_to_create> <path_where_to_store> <network_range_base> * Example Win7x64 /VMs/Win7x64.qcow2 0 5 /var/lib/libvirt/images/ 192.168.1 https://wiki.qemu.org/Documentation/CreateSnapshot Libvirt <username_optional> - install libvirt, username is optional Replace_qemu - only fix antivms in QEMU source Replace_seabios <path> - only fix antivms in SeaBios source Issues - will give you error - solution list noip - Install No-ip deamon and enable on boot EndOfHelp } @@ -75,7 +84,7 @@ function install_haxm_mac() { brew tap jeffreywildman/homebrew-virt-manager brew cask install xquartz brew install virt-manager virt-viewer if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" else @@ -84,29 +93,32 @@ function install_haxm_mac() { } function install_libvirt() { #dpkg —purge libivrt-4.7.0 # http://ask.xmodulo.com/compile-virt-manager-debian-ubuntu.html #rm -r /usr/local/lib/python2.7/dist-packages/libvirt* #apt-get install python-libvirt libgtk-3-dev libvirt-glib-1.0 gir1.2-gtk-vnc-2.0 libosinfo-1.0 python-ipaddr python-libxml2 python-requests qemu-kvm- qemu-system-common- qemu-system-x86- qemu-utils- seabios- ipxe-qemu- ipxe-qemu-256k-compat-efi-roms- cd /tmp || return if [ -f libvirt-$libvirt_version.tar.xz ]; then rm -r libvirt-$libvirt_version else wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz fi tar xf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version || return if [ "$OS" = "Linux" ]; then apt-get install unzip numad glib-2.0 libglib2.0-dev libsdl1.2-dev lvm2 python-pip python-libxml2 python3-libxml2 ebtables libosinfo-1.0-dev libnl-3-dev libnl-route-3-dev libyajl-dev xsltproc libapparmor-dev libdevmapper-dev libpciaccess-dev apparmor-utils -y 2>/dev/null pip install ipaddr # --prefix=/usr --localstatedir=/var --sysconfdir=/etc ./autogen.sh --system --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes --with-secdriver-apparmor=yes --with-apparmor-profiles --with-apparmor-profiles make -j"$(getconf _NPROCESSORS_ONLN)" checkinstall -D --pkgname=libvirt-$libvirt_version --default #make -j"$(getconf _NPROCESSORS_ONLN)" install elif [ "$OS" = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit if [ -f /etc/libvirt/libvirtd.conf ]; then path="/etc/libvirt/libvirtd.conf" elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then @@ -119,22 +131,19 @@ function install_libvirt() { sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' $path # https://gitlab.com/apparmor/apparmor/wikis/Libvirt echo "[+] Setting AppArmor for libvirt/kvm/qemu" sed -i 's/#security_driver = "selinux"/security_driver = "apparmor"/g' /etc/libvirt/qemu.conf aa-complain /usr/sbin/libvirtd cd /tmp || return if [ ! -f v$libvirt_version.zip ]; then wget https://github.com/libvirt/libvirt-python/archive/v$libvirt_version.zip fi unzip v$libvirt_version.zip cd libvirt-python* || return python3 setup.py build python3 setup.py install if [ "$OS" = "Linux" ]; then # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c @@ -144,25 +153,29 @@ function install_libvirt() { elif grep -q -E '^libvirt:' /etc/group; then groupname="libvirt" else # create group if missed groupname="libvirt" groupadd libvirt fi usermod -G $groupname -a "$(whoami)" if "$username"; then usermod -G $groupname -a "$username" fi echo "[+] You should logout and login " fi } function install_kvm_linux_apt() { #sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list apt-get update 2>/dev/null apt-get install build-essential python-pip python-pip3 gcc pkg-config cpu-checker intltool -y 2>/dev/null apt-get install gtk-update-icon-cache -y 2>/dev/null # WSL support apt-get install gcc make gnutls-bin -y # remove old apt-get purge libvirt0 libvirt-bin -y install_libvirt systemctl enable libvirtd.service @@ -171,12 +184,12 @@ function install_kvm_linux_apt() { systemctl restart virtlogd.socket # from build-dep apt install libgirepository1.0-dev gtk-doc-tools python-pip python3-pip gir1.2-govirt-1.0 libgovirt-dev \ libgovirt-common libgovirt2 gir1.2-rest-0.7 unzip intltool augeas-doc ifupdown wodim cdrkit-doc indicator-application \ augeas-tools radvd auditd systemtap nfs-common zfsutils pm-utils python-openssl-doc python-socks python-ntlm samba ovmf \ debootstrap sharutils-doc ssh-askpass gnome-keyring python-requests python-six python-urllib3 python2.7 python2.7-minimal \ sharutils spice-client-glib-usb-acl-helper ubuntu-mono x11-common python-cryptography python-dbus python-enum34 python-gi \ python-gi-cairo python-idna python-ipaddr python-ipaddress python-libxml2 python3-libxml2 python-minimal python-openssl python-pkg-resources \ libxml2-utils libxrandr2 libxrender1 libxshmfence1 libxtst6 libxv1 libyajl2 msr-tools osinfo-db python python-asn1crypto \ python-cairo python-certifi python-cffi-backend python-chardet libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 \ libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxen-4.9 libxenstore3.0 libxfixes3 libxft2 libxi6 libxinerama1 \ @@ -200,40 +213,46 @@ function install_kvm_linux_apt() { gir1.2-libosinfo-1.0 gir1.2-pango-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0 gir1.2-vte-2.91 glib-networking \ glib-networking-common glib-networking-services gsettings-desktop-schemas gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ gstreamer1.0-x adwaita-icon-theme at-spi2-core augeas-lenses bridge-utils cpu-checker dconf-gsettings-backend dconf-service \ fontconfig fontconfig-config fonts-dejavu-core genisoimage gir1.2-appindicator3-0.1 gir1.2-secret-1 -y 2>/dev/null # should be installed first pip install pycairo pip3 install pycairo pip3 install PyGObject -U pip install PyGObject -U cd /tmp || return if wget https://libvirt.org/sources/glib/libvirt-glib-1.0.0.tar.gz; then tar xf libvirt-glib-1.0.0.tar.gz cd libvirt-glib-1.0.0 aclocal && libtoolize --force automake --add-missing ./configure make -j"$(getconf _NPROCESSORS_ONLN)" checkinstall --pkgname=libvirt-glib-1.0-0 --default wget http://launchpadlibrarian.net/297448356/gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb dpkg -i gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb #apt-get install gir1.2-libvirt-glib-1.0 -y /sbin/ldconfig fi if [ ! -f "virt-manager" ]; then #git clone -b v1.5-maint https://github.com/virt-manager/virt-manager.git git clone https://github.com/virt-manager/virt-manager.git fi cd "virt-manager" || return apt-get install gobject-introspection intltool pkg-config python-lxml python3-libxml2 libxml2-dev libxslt-dev python-dev gir1.2-gtk-vnc-2.0 gir1.2-spiceclientgtk-3.0 libgtk-3-dev -y # py3 python3 setup.py build python3 setup.py install if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.bashrc" fi #reboot me here kvm-ok } @@ -267,9 +286,9 @@ function replace_qemu_clues_public() { echo 'KVMKVMKVM was not replaced in kvm.c'; fail=1 fi # by @http_error_418 #if sed -i 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c; then # echo 'Microsoft Hv was not replaced in target/i386/kvm.c'; fail=1 #fi if ! sed -i 's/"bochs"/"hawks"/g' qemu*/block/bochs.c; then echo 'BOCHS was not replaced in block/bochs.c'; fail=1 fi @@ -281,14 +300,14 @@ function replace_qemu_clues_public() { if ! sed -i 's/Bochs Pseudo/Intel RealTime/g' qemu*/roms/ipxe/src/drivers/net/pnic.c; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c'; fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) #if ! sed -i 's/Bochs\/Plex86/<WOOT>\/FIRM64/g' qemu*/roms/vgabios/vbe.c; then # echo 'BOCHS was not replaced in roms/vgabios/vbe.c'; fail=1 #fi } function replace_seabios_clues_public() { echo "[+] Generating SeaBios Kconfig" echo "[+] Fixing SeaBios antivms" if ! sed -i 's/Bochs/<WOOT>/g' src/config.h; then echo 'Bochs was not replaced in src/config.h'; fail=1 @@ -316,7 +335,7 @@ function replace_seabios_clues_public() { src/hw/blockcmd.c src/fw/paravirt.c ) for file in "${FILES[@]}"; do if ! sed -i 's/"QEMU/"<WOOT>/g' "$file"; then echo "QEMU was not replaced in $file"; fail=1 fi @@ -325,10 +344,10 @@ function replace_seabios_clues_public() { echo '"QEMU" was not replaced in src/hw/blockcmd.c'; fail=1 fi FILES=( "src/fw/acpi-dsdt.dsl" "src/fw/q35-acpi-dsdt.dsl" ) for file in "${FILES[@]}"; do if ! sed -i 's/"BXPC"/<WOOT>"/g' "$file"; then echo "BXPC was not replaced in $file"; fail=1 fi @@ -371,42 +390,51 @@ function replace_seabios_clues_public() { src/fw/ssdt-pcihp.dsl src/config.h ) for file in "${FILES[@]}"; do if ! sed -i 's/"BXPC"/"A M I"/g' "$file"; then echo "BXPC was not replaced in $file"; fail=1 fi done } function qemu_func() { cd /tmp || return echo '[+] Cleaning QEMU old install if exists' rm -r /usr/share/qemu >/dev/null 2>&1 dpkg -r ubuntu-vm-builder python-vm-builder >/dev/null 2>&1 dpkg -l |grep qemu |cut -d " " -f 3|xargs dpkg --purge --force-all >/dev/null 2>&1 echo '[+] Downloading QEMU source code' if [ ! -f qemu-$qemu_version.tar.xz ]; then wget "https://download.qemu.org/qemu-$qemu_version.tar.xz" fi if [ ! -f qemu-$qemu_version.tar.xz ]; then echo "[-] Download qemu-$qemu_version failed" exit fi if ! $(tar xf "qemu-$qemu_version.tar.xz") ; then echo "[-] Failed to extract, check if download was correct" exit 1 fi fail=0 if [ "$OS" = "Linux" ]; then add-apt-repository universe apt-get update apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev -y 2>/dev/null apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev \ libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev -y 2>/dev/null elif [ "$OS" = "Darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools glib -y fi # WOOT # some checks may be depricated, but keeping them for compatibility with old versions if [ $? -eq 0 ]; then if declare -f -F "replace_qemu_clues"; then replace_qemu_clues @@ -419,7 +447,7 @@ function qemu_func() { # add in future --enable-netmap https://sgros-students.blogspot.com/2016/05/installing-and-testing-netmap.html # remove --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user if you want all targets if [ "$OS" = "Linux" ]; then ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-gtk --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-kvm --enable-linux-aio --enable-cap-ng --enable-vhost-net --enable-vhost-crypto --enable-spice --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libssh2 --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone elif [ "$OS" = "Darwin" ]; then # --enable-vhost-net --enable-vhost-crypto ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-hax --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone @@ -437,22 +465,22 @@ function qemu_func() { make -j"$(getconf _NPROCESSORS_ONLN)" install fi # hack for libvirt/virt-manager if [ ! -f /usr/bin/qemu-system-x86_64-spice ]; then ln -s /usr/bin/qemu-system-x86_64 /usr/bin/qemu-system-x86_64-spice fi if [ ! -f /usr/bin/kvm-spice ]; then ln -s /usr/bin/qemu-system-x86_64 /usr/bin/kvm-spice fi if [ ! -f /usr/bin/kvm ]; then ln -s /usr/bin/qemu-system-x86_64 /usr/bin/kvm fi if [ $? -eq 0 ]; then echo '[+] Patched, compiled and installed' else echo '[-] Install failed' fi groupadd tss useradd -g tss tss else echo '[-] Compilling failed' fi @@ -464,15 +492,17 @@ function qemu_func() { else echo '[-] Download QEMU source was not possible' fi if [ "$OS" = "linux" ]; then dpkg --get-selections | grep "qemu" | xargs apt-mark hold dpkg --get-selections | grep "libvirt" | xargs apt-mark hold # apt-mark unhold qemu fi } function seabios_func() { cd /tmp || return fail=0 echo '[+] Installing SeaBios dependencies' apt-get install git iasl -y if [ -d seabios ]; then @@ -485,16 +515,20 @@ function seabios_func() { else replace_seabios_clues_public fi # make help # make menuconfig -> BIOS tables -> disable Include default ACPI DSDT # get rid of this hack make -j "$(getconf _NPROCESSORS_ONLN)" 2>/dev/null sed -i 's/CONFIG_ACPI_DSDT=y/CONFIG_ACPI_DSDT=n/g' .config sed -i 's/CONFIG_XEN=y/CONFIG_XEN=n/g' .config if make -j "$(getconf _NPROCESSORS_ONLN)"; then echo '[+] Replacing old bios.bin to new out/bios.bin' bios=0 FILES=( "/usr/share/qemu/bios.bin" "/usr/share/qemu/bios-256k.bin" ) for file in "${FILES[@]}"; do cp -vf out/bios.bin "$file" bios=1 done @@ -514,6 +548,9 @@ function seabios_func() { function issues(){ cat << EndOfHelp ### Links: * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-troubleshooting-common_libvirt_errors_and_troubleshooting ### Errors and Solutions * Error: required by /usr/lib/libvirt/storage-file/libvirt_storage_file_fs.so @@ -524,22 +561,22 @@ cat << EndOfHelp * Error: /libvirt.so.0: version LIBVIRT_PRIVATE_x.x.0' not found (required by /usr/sbin/libvirtd) * Solutions: 1. apt-get purge libvirt0 libvirt-bin 2. ldd /usr/sbin/libvirtd 3. ls -lah /usr/lib/libvirt* * Make sure what all symlinks pointing to last version * Error: libvirt: Polkit error : authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage' * Solutions: 1. sed -i 's/#unix_sock_group/unix_sock_group/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' /etc/libvirt/libvirtd.conf 2. Add ssh key to $HOME/.ssh/authorized_keys virt-manager -c "qemu+ssh://user@host/system?socket=/var/run/libvirt/libvirt-sock" * Slow HDD/Snapshot taking performance? Modify <driver name='qemu' type='qcow2'/> @@ -549,38 +586,43 @@ cat << EndOfHelp error : virPidFileAcquirePath:422 : Failed to acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable * Solution ps aux | grep libvirtd * Error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Permission denied * Solution: * usermod -G libvirt -a username * log out and log in # Fixes from http://ask.xmodulo.com/compile-virt-manager-debian-ubuntu.html 1. ImportError: No module named libvirt $ apt-get install python-libvirt 2. ImportError: No module named libxml2 $ apt-get install python-libxml2 python3-libxml2 3. ImportError: No module named requests $ apt-get install python-requests 4. Error launching details: Namespace GtkVnc not available $ apt-get install gir1.2-gtk-vnc-2.0 5. Error launching details: Namespace SpiceClientGtk not available $ apt-get install gir1.2-spice-client-gtk-3.0 6. ValueError: Namespace LibvirtGLib not available $ apt-get install libvirt-glib-1.0 7. ValueError: Namespace Libosinfo not available $ apt-get install libosinfo-1.0 8. ImportError: No module named ipaddr $ apt-get install python-ipaddr 9. Namespace Gtk not available: Could not open display: localhost:10.0 $ apt-get install libgtk-3-dev 10. ImportError: cannot import name Vte $ apt-get install gir1.2-vte-2.90 EndOfHelp } @@ -594,11 +636,12 @@ function cloning() { # bad macaddress can be generated while [ $worked -eq 1 ]; do macaddr=$(hexdump -n 6 -ve '1/1 "%.2x "' /dev/random | awk -v a="2,6,a,e" -v r="$RANDOM" 'BEGIN{srand(r);}NR==1{split(a,b,",");r=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s\n",substr($1,0,1),b[r],$2,$3,$4,$5,$6}') 2>/dev/null #virt-clone --print-xml -n $1_$i -o $1 -m "$macaddr" if [ ! -f "${5}/${1}_${i}.qcow2" ]; then qemu-img create -f qcow2 -b "$2" "$5/$1_$i.qcow2" fi if virt-clone --print-xml -n "$1_$i" -o "$1" -m "$macaddr" 2>/dev/null|sed "s|<driver name=\"qemu\" type=\"qcow2\"/>|<driver name=\"qemu\" type=\"qcow2\" cache=\"none\" io=\"native\"/>\\n <source file=\"${5}/${1}_${i}.qcow2\"/>|" > "$5/$1_$i.xml"; then sed -i "s|<domain type='kvm'>|<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>" "$5/$1_$i.xml" virsh define "$5/$1_$i.xml" worked=0 fi @@ -622,21 +665,35 @@ case $COMMAND in exit 0;; esac #if ([ "$COMMAND" = "all" ] || [ "$COMMAND" = "libvirt" ]) && [ $# -eq 2 ]; then # if [ id -u "$2" ]; then # username="$2" # else # echo "[-] username $2 doesn't exist" # exit 1 # fi #fi #check if start with root if [ "$EUID" -ne 0 ]; then echo 'This script must be run as root' exit 1 fi OS="$(uname -s)" #add-apt-repository universe #apt-get update && apt-get upgrade #make case "$COMMAND" in 'all') apt-get install language-pack-UTF-8 qemu_func seabios_func if [ "$OS" = "Linux" ]; then install_kvm_linux_apt # check if all features enabled virt-host-validate systemctl daemon-reload systemctl restart libvirtd libvirt-guests.service elif [ "$OS" = "Darwin" ]; then @@ -662,6 +719,20 @@ case $COMMAND in install_libvirt;; 'clone') cloning "$2" "$3" "$4" "$5" "$6" "$7";; 'noip') if [ "$OS" = "Linux" ]; then cd /tmp wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz tar xf noip-duc-linux.tar.gz rm noip-duc-linux.tar.gz cd "noip-*" make install crontab -l | { cat; echo "@reboot sleep 10 && /usr/local/bin/noip2 -c /usr/local/etc/no-ip2.conf"; } | crontab - elif [ "$OS" = "Darwin" ]; then _check_brew brew cask install no-ip-duc fi ;; 'replace_seabios') if [ ! -d "$2" ]; then echo "[-] Pass the path to SeaBios folder" @@ -677,4 +748,4 @@ case $COMMAND in ;; *) usage;; esac -
doomedraven revised this gist
Sep 20, 2018 . 1 changed file with 109 additions and 45 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 11.09.2018 - code improvement # 09.09.2018 - ACPI fixes - huge thanks to @2sec4u for your patience and your time/help :P # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes @@ -11,20 +11,20 @@ # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # https://www.shellcheck.net/ # ACPI tables related # https://wiki.archlinux.org/index.php/DSDT # Dump on linux # sudo acpidump > acpidump.out # Dump on Windows # https://acpica.org/downloads/binary-tools # acpixtract -a acpi/4/acpi.dump # sudo acpixtract -a acpidump.out # sudo iasl -d DSDT.dat # Decompile: iasl -d dsdt.dat # Recompile: iasl -tc dsdt.dsl # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ @@ -37,8 +37,9 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://virt-manager.org/download/sources/virt-manager/ # https://github.com/virt-manager/virt-manager/releases on oficial web is 1.5.1 but it breaks deps virt_manager_version=1.5.0 # autofilled OS="" @@ -94,7 +95,7 @@ function install_libvirt() { if [ "$OS" = "Linux" ]; then apt-get install python-libxml2 ebtables libosinfo-1.0-dev libnl-3-dev libnl-route-3-dev libyajl-dev xsltproc libapparmor-dev libdevmapper-dev libpciaccess-dev apparmor-utils -y pip install ipaddr # --prefix=/usr --localstatedir=/var --sysconfdir=/etc if ! ./autogen.sh --system --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes --with-secdriver-apparmor=yes --with-apparmor-profiles --with-apparmor-profiles; then echo "[-] Compilation failed, check previous output" exit 1 @@ -105,7 +106,7 @@ function install_libvirt() { elif [ "$OS" = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit if [ -f /etc/libvirt/libvirtd.conf ]; then path="/etc/libvirt/libvirtd.conf" elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then @@ -118,25 +119,44 @@ function install_libvirt() { sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' $path # https://gitlab.com/apparmor/apparmor/wikis/Libvirt echo "[+] Setting AppArmor for libvirt/kvm/qemu" sed -i 's/#security_driver = "selinux"/security_driver = "apparmor"/g' /etc/libvirt/qemu.conf aa-complain /usr/sbin/libvirtd #pip install libvirt-python #pip3 install libvirt-python cd /tmp || return if [ ! -f v$libvirt_version.zip ]; then wget https://github.com/libvirt/libvirt-python/archive/v$libvirt_version.zip fi unzip v$libvirt_version.zip cd libvirt-python* || return python setup.py build # libvirt.git checkout, by setting PKG_CONFIG_PATH and LD_LIBRARY_PATH sudo python setup.py install if [ "$OS" = "Linux" ]; then # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c groupname="" if grep -q -E '^libvirtd:' /etc/group; then groupname="libvirtd" elif grep -q -E '^libvirt:' /etc/group; then groupname="libvirt" else # create group if missed groupname="libvirt" sudo groupadd libvirt fi usermod -G $groupname -a "$(whoami)" echo "[+] You should logout and login " fi } function install_kvm_linux_apt() { #sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential python-pip gcc pkg-config cpu-checker intltool -y sudo apt-get install gtk-update-icon-cache -y # WSL support @@ -145,30 +165,67 @@ function install_kvm_linux_apt() { sudo apt-get purge libvirt0 libvirt-bin -y install_libvirt systemctl enable libvirtd.service systemctl restart libvirtd.service systemctl enable virtlogd.socket systemctl restart virtlogd.socket # from build-dep sudo apt install libgirepository1.0-dev gtk-doc-tools python-pip python3-pip gir1.2-govirt-1.0 libgovirt-dev \ libgovirt-common libgovirt2 gir1.2-rest-0.7 unzip intltool augeas-doc ifupdown wodim cdrkit-doc indicator-application \ augeas-tools radvd auditd systemtap nfs-common zfsutils pm-utils python-openssl-doc python-socks python-ntlm samba ovmf \ debootstrap sharutils-doc ssh-askpass gnome-keyring python-requests python-six python-urllib3 python2.7 python2.7-minimal \ sharutils spice-client-glib-usb-acl-helper ubuntu-mono x11-common python-cryptography python-dbus python-enum34 python-gi \ python-gi-cairo python-idna python-ipaddr python-ipaddress python-libxml2 python-minimal python-openssl python-pkg-resources \ libxml2-utils libxrandr2 libxrender1 libxshmfence1 libxtst6 libxv1 libyajl2 msr-tools osinfo-db python python-asn1crypto \ python-cairo python-certifi python-cffi-backend python-chardet libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 \ libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxen-4.9 libxenstore3.0 libxfixes3 libxft2 libxi6 libxinerama1 \ libxkbcommon0 libusbredirhost1 libusbredirparser1 libv4l-0 libv4lconvert0 libvisual-0.4-0 libvorbis0a libvorbisenc2 libvpx5 \ libvte-2.91-0 libvte-2.91-common libwavpack1 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa libwayland-server0 \ libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libsoup-gnome2.4-1 libsoup2.4-1 libspeex1 libspice-client-glib-2.0-8 \ libspice-client-gtk-3.0-5 libspice-server1 libtag1v5 libtag1v5-vanilla libthai-data libthai0 libtheora0 libtiff5 \ libtwolame0 libpython2.7 libpython2.7-minimal libpython2.7-stdlib librados2 libraw1394-11 librbd1 librdmacm1 librest-0.7-0 \ librsvg2-2 librsvg2-common libsamplerate0 libsdl1.2debian libshout3 libsndfile1 libpango-1.0-0 libpangocairo-1.0-0 \ libpangoft2-1.0-0 libpangoxft-1.0-0 libpciaccess0 libphodav-2.0-0 libphodav-2.0-common libpixman-1-0 libproxy1v5 \ libpulse-mainloop-glib0 libpulse0 libpython-stdlib libgstreamer1.0-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk-vnc-2.0-0 \ libgudev-1.0-0 libgvnc-1.0-0 libharfbuzz0b libibverbs1 libiec61883-0 libindicator3-7 libiscsi7 libjack-jackd2-0 libjbig0 \ libjpeg-turbo8 libjpeg8 libjson-glib-1.0-0 libjson-glib-1.0-common liblcms2-2 libmp3lame0 libmpg123-0 libnetcf1 libnl-route-3-200 \ libnspr4 libnss3 libogg0 libopus0 liborc-0.4-0 libosinfo-1.0-0 libcairo-gobject2 libcairo2 libcdparanoia0 libcolord2 libcroco3 \ libcups2 libdatrie1 libdbusmenu-glib4 libdbusmenu-gtk3-4 libdconf1 libdv4 libegl-mesa0 libegl1 libepoxy0 libfdt1 libflac8 \ libfontconfig1 libgbm1 libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libglapi-mesa libglvnd0 libgraphite2-3 \ libgstreamer-plugins-base1.0-0 libgstreamer-plugins-good1.0-0 gtk-update-icon-cache hicolor-icon-theme humanity-icon-theme \ ibverbs-providers libaa1 libaio1 libappindicator3-1 libasound2 libasound2-data libasyncns0 libatk-bridge2.0-0 libatk1.0-0 \ libatk1.0-data libatspi2.0-0 libaugeas0 libavahi-client3 libavahi-common-data libavahi-common3 libavc1394-0 libbluetooth3 \ libbrlapi0.6 libcaca0 libcacard0 gir1.2-atk-1.0 gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-gtk-3.0 gir1.2-gtk-vnc-2.0 \ gir1.2-libosinfo-1.0 gir1.2-pango-1.0 gir1.2-spiceclientglib-2.0 gir1.2-spiceclientgtk-3.0 gir1.2-vte-2.91 glib-networking \ glib-networking-common glib-networking-services gsettings-desktop-schemas gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ gstreamer1.0-x adwaita-icon-theme at-spi2-core augeas-lenses bridge-utils cpu-checker dconf-gsettings-backend dconf-service \ fontconfig fontconfig-config fonts-dejavu-core genisoimage gir1.2-appindicator3-0.1 gir1.2-secret-1 -y pip3 install pycairo PyGObject -U pip install pycairo PyGObject -U cd /tmp || return if wget https://libvirt.org/sources/glib/libvirt-glib-1.0.0.tar.gz; then tar xf libvirt-glib-1.0.0.tar.gz cd libvirt-glib-1.0.0 aclocal && libtoolize --force automake --add-missing ./configure make -j"$(getconf _NPROCESSORS_ONLN)" sudo checkinstall --pkgname=libvirt-glib-1.0-0 --default #wget http://launchpadlibrarian.net/297448356/gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb #dpkg -i gir1.2-libvirt-glib-1.0_1.0.0-1_amd64.deb sudo apt-get install gir1.2-libvirt-glib-1.0 -y sudo /sbin/ldconfig fi if [ ! -f "virt-manager" ]; then git clone -b v1.5-maint https://github.com/virt-manager/virt-manager.git fi cd "virt-manager" || return sudo apt-get install gobject-introspection intltool pkg-config python-lxml libxml2-dev libxslt-dev python-dev gir1.2-gtk-vnc-2.0 gir1.2-spiceclientgtk-3.0 libgtk-3-dev -y #pip install libxml2 python setup.py build python setup.py install if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" @@ -333,7 +390,10 @@ function qemu_func() { if [ ! -f qemu-$qemu_version.tar.xz ]; then wget https://download.qemu.org/qemu-$qemu_version.tar.xz fi if [ $(tar xf qemu-$qemu_version.tar.xz) ]; then echo "[-] Failed to extract, check if download was correct" exit 1 fi fail=0 if [ "$OS" = "Linux" ]; then @@ -391,6 +451,8 @@ function qemu_func() { else echo '[-] Install failed' fi sudo groupadd tss sudo useradd -g tss tss else echo '[-] Compilling failed' fi @@ -402,14 +464,15 @@ function qemu_func() { else echo '[-] Download QEMU source was not possible' fi #if [ "$OS" = "linux" ]; then # dpkg --get-selections | grep "qemu" | xargs sudo apt-mark hold # #sudo apt-mark unhold qemu #fi } function seabios_func() { fail=0 cd /tmp || return echo '[+] Installing SeaBios dependencies' apt-get install git iasl -y if [ -d seabios ]; then @@ -422,8 +485,8 @@ function seabios_func() { else replace_seabios_clues_public fi # sudo make help # sudo make menuconfig -> BIOS tables -> disable Include default ACPI DSDT if make -j "$(getconf _NPROCESSORS_ONLN)"; then echo '[+] Replacing old bios.bin to new out/bios.bin' bios=0 @@ -569,6 +632,7 @@ OS="$(uname -s)" case $COMMAND in 'all') sudo apt-get install unzip qemu_func seabios_func if [ "$OS" = "Linux" ]; then @@ -613,4 +677,4 @@ case $COMMAND in ;; *) usage;; esac -
doomedraven revised this gist
Sep 18, 2018 . 1 changed file with 18 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # https://www.doomedraven.com/2016/05/kvm.html # 11.09.2018 - code improvement # 09.09.2018 - ACPI fixes - huge thanks to @2sec4u for your patience and your time/help :P # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes @@ -11,20 +11,20 @@ # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # https://www.shellcheck.net/ # ACPI tables related # https://wiki.archlinux.org/index.php/DSDT # Dump on linux # sudo acpidump > acpidump.out # Dump on Windows # https://acpica.org/downloads/binary-tools # acpixtract -a acpi/4/acpi.dump # sudo acpixtract -a acpidump.out # sudo iasl -d DSDT.dat # Decompile: iasl -d dsdt.dat # Recompile: iasl -tc dsdt.dsl # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ @@ -37,7 +37,7 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://virt-manager.org/download/sources/virt-manager/ virt_manager_version=1.5.1 # autofilled @@ -94,7 +94,7 @@ function install_libvirt() { if [ "$OS" = "Linux" ]; then apt-get install python-libxml2 ebtables libosinfo-1.0-dev libnl-3-dev libnl-route-3-dev libyajl-dev xsltproc libapparmor-dev libdevmapper-dev libpciaccess-dev apparmor-utils -y pip install ipaddr # --prefix=/usr --localstatedir=/var --sysconfdir=/etc if ! ./autogen.sh --system --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes --with-secdriver-apparmor=yes --with-apparmor-profiles --with-apparmor-profiles; then echo "[-] Compilation failed, check previous output" exit 1 @@ -105,7 +105,7 @@ function install_libvirt() { elif [ "$OS" = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit if [ -f /etc/libvirt/libvirtd.conf ]; then path="/etc/libvirt/libvirtd.conf" elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then @@ -118,7 +118,7 @@ function install_libvirt() { sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' $path # https://gitlab.com/apparmor/apparmor/wikis/Libvirt echo "[+] Setting AppArmor for libvirt/kvm/qemu" sed -i 's/#security_driver = "selinux"/security_driver = "apparmor"/g' /etc/libvirt/qemu.conf aa-complain /usr/sbin/libvirtd @@ -152,7 +152,7 @@ function install_kvm_linux_apt() { elif grep -q -E '^libvirt:' /etc/group; then groupname="libvirt" else # create group if missed groupname="libvirt" sudo groupadd libvirt fi @@ -224,10 +224,6 @@ function replace_qemu_clues_public() { if ! sed -i 's/Bochs Pseudo/Intel RealTime/g' qemu*/roms/ipxe/src/drivers/net/pnic.c; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c'; fail=1 fi } function replace_seabios_clues_public() { @@ -426,8 +422,8 @@ function seabios_func() { else replace_seabios_clues_public fi # sudo make help # sudo make menuconfig -> BIOS tables -> disable Include default ACPI DSDT if make -j "$(getconf _NPROCESSORS_ONLN)"; then echo '[+] Replacing old bios.bin to new out/bios.bin' bios=0 -
doomedraven revised this gist
Sep 15, 2018 . 1 changed file with 187 additions and 113 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,27 +37,29 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://virt-manager.org/download/sources/virt-manager/ virt_manager_version=1.5.1 # autofilled OS="" function usage() { cat << EndOfHelp Usage: $0 <func_name> <args> Commands - are case insensitive: All - Execs QEMU/SeaBios/KVM QEMU - Install QEMU from source SeaBios - Install SeaBios and repalce QEMU bios file KVM - this will install intel-HAXM if you on Mac HAXM - Mac Hardware Accelerated Execution Manager Clone - <VM_NAME> <path_to_hdd> <start_from_number> <#vm_to_create> <path_where_to_store> <network_range_base> * Example Win7x64 /VMs/Win7x64.qcow2 0 5 /var/lib/libvirt/images/ 192.168.1 https://wiki.qemu.org/Documentation/CreateSnapshot Libvirt - install libvirt Replace_qemu - only fix antivms in QEMU source Replace_seabios <path> - only fix antivms in SeaBios source Issues - will give you error - solution list EndOfHelp } function _check_brew() { @@ -90,10 +92,16 @@ function install_libvirt() { tar xf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version || return if [ "$OS" = "Linux" ]; then apt-get install python-libxml2 ebtables libosinfo-1.0-dev libnl-3-dev libnl-route-3-dev libyajl-dev xsltproc libapparmor-dev libdevmapper-dev libpciaccess-dev apparmor-utils -y pip install ipaddr # --prefix=/usr --localstatedir=/var --sysconfdir=/etc if ! ./autogen.sh --system --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes --with-secdriver-apparmor=yes --with-apparmor-profiles --with-apparmor-profiles; then echo "[-] Compilation failed, check previous output" exit 1 fi make -j"$(getconf _NPROCESSORS_ONLN)" checkinstall -D --pkgname=libvirt-$libvirt_version --default #make -j"$(getconf _NPROCESSORS_ONLN)" install elif [ "$OS" = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi @@ -123,21 +131,18 @@ function install_libvirt() { cd libvirt-python* || return python setup.py build sudo python setup.py install } function install_kvm_linux_apt() { #sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev lvm2 intltool -y sudo apt-get install gtk-update-icon-cache -y # WSL support sudo apt-get install gcc make gnutls-bin -y # remove old sudo apt-get purge libvirt0 libvirt-bin -y install_libvirt # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c @@ -158,12 +163,12 @@ function install_kvm_linux_apt() { systemctl enable virtlogd.socket systemctl restart virtlogd.socket if [ ! -f "virt-manager-$virt_manager_version.tar.gz" ]; then wget https://virt-manager.org/download/sources/virt-manager/virt-manager-$virt_manager_version.tar.gz fi tar xf "virt-manager-$virt_manager_version.tar.gz" cd "virt-manager-$virt_manager_version" || return sudo apt-get install intltool -y python setup.py install if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" @@ -175,7 +180,7 @@ function install_kvm_linux_apt() { } function replace_qemu_clues_public() { echo '[+] Patching QEMU clues' if ! sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c; then echo 'QEMU HARDDISK was not replaced in core.c'; fail=1 @@ -225,14 +230,12 @@ function replace_qemu_clues() { fi } function replace_seabios_clues_public() { echo "[+] deleting BOCHS APCI tables" echo "[+] Generating SeaBios Kconfig" #./scripts/kconfig/merge_config.sh -o . >/dev/null 2>&1 #sed -i 's/CONFIG_ACPI_DSDT=y/CONFIG_ACPI_DSDT=n/g' .config #sed -i 's/CONFIG_XEN=y/CONFIG_XEN=n/g' .config echo "[+] Fixing SeaBios antivms" if ! sed -i 's/Bochs/<WOOT>/g' src/config.h; then echo 'Bochs was not replaced in src/config.h'; fail=1 @@ -255,6 +258,7 @@ function replace_seabios_clues() { if ! sed -i 's/qemu /<WOOT> /g' vgasrc/Kconfig; then echo 'qemu was not replaced in vgasrc/Kconfig'; fail=1 fi FILES=( src/hw/blockcmd.c src/fw/paravirt.c @@ -326,7 +330,8 @@ function qemu_func() { echo '[+] Cleaning QEMU old install if exists' rm -r /usr/share/qemu >/dev/null 2>&1 sudo dpkg -r ubuntu-vm-builder python-vm-builder >/dev/null 2>&1 sudo dpkg -l |grep qemu |cut -d " " -f 3|xargs sudo dpkg --purge --force-all >/dev/null 2>&1 echo '[+] Downloading QEMU source code' if [ ! -f qemu-$qemu_version.tar.xz ]; then @@ -337,14 +342,21 @@ function qemu_func() { if [ "$OS" = "Linux" ]; then sudo apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev -y sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev \ libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev -y elif [ "$OS" = "Darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools glib -y fi # WOOT # some checks may be depricated, but keeping them for compatibility with old versions if [ $? -eq 0 ]; then if declare -f -F "replace_qemu_clues"; then replace_qemu_clues else replace_qemu_clues_public fi if [ $fail -eq 0 ]; then echo '[+] Starting compile it' cd qemu-$qemu_version || return @@ -364,7 +376,7 @@ function qemu_func() { fi make -j"$(getconf _NPROCESSORS_ONLN)" if [ "$OS" = "Linux" ]; then checkinstall -D --pkgname=qemu-$qemu_version --nodoc --showinstall=no --default elif [ "$OS" = "Darwin" ]; then make -j"$(getconf _NPROCESSORS_ONLN)" install fi @@ -400,7 +412,6 @@ function qemu_func() { fi } function seabios_func() { fail=0 echo '[+] Installing SeaBios dependencies' @@ -410,32 +421,33 @@ function seabios_func() { fi if git clone https://github.com/coreboot/seabios.git; then cd seabios || return if declare -f -F "replace_seabios_clues"; then replace_seabios_clues else replace_seabios_clues_public fi # sudo make help # sudo make menuconfig -> BIOS tables -> disable Include default ACPI DSDT if make -j "$(getconf _NPROCESSORS_ONLN)"; then echo '[+] Replacing old bios.bin to new out/bios.bin' bios=0 FILES=( "/usr/share/qemu/bios.bin" "/usr/share/qemu/bios-256k.bin" ) for file in "${FILES[@]}"; do cp -vf out/bios.bin "$file" bios=1 done if [ $bios -eq 1 ]; then echo '[+] Patched bios.bin placed correctly' else echo '[-] Bios patching failed' fi else echo '[-] Bios compilation failed' fi cd - || return else echo '[-] Check if git installed or network connection is OK' fi @@ -454,51 +466,102 @@ cat << EndOfHelp /libvirt.so.0: version LIBVIRT_PRIVATE_x.x.0' not found (required by /usr/sbin/libvirtd) * Solutions: 1. sudo apt-get purge libvirt0 libvirt-bin 2. ldd /usr/sbin/libvirtd 3. ls -lah /usr/lib/libvirt* * Make sure what all symlinks pointing to last version * Error: libvirt: Polkit error : authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage' * Solutions: 1. sed -i 's/#unix_sock_group/unix_sock_group/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' /etc/libvirt/libvirtd.conf 2. Add ssh key to $HOME/.ssh/authorized_keys virt-manager -c "qemu+ssh://user@host/system?socket=/var/run/libvirt/libvirt-sock" * Slow HDD/Snapshot taking performance? Modify <driver name='qemu' type='qcow2'/> To <driver name='qemu' type='qcow2' cache='none' io='native'/> * Error: error : virPidFileAcquirePath:422 : Failed to acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable * Solution ps aux | grep libvirtd # Fixes from http://ask.xmodulo.com/compile-virt-manager-debian-ubuntu.html 1. ImportError: No module named libvirt $ sudo apt-get install python-libvirt 2. ImportError: No module named libxml2 $ sudo apt-get install python-libxml2 3. ImportError: No module named requests $ sudo apt-get install python-requests 4. Error launching details: Namespace GtkVnc not available $ sudo apt-get install gir1.2-gtk-vnc-2.0 5. Error launching details: Namespace SpiceClientGtk not available $ sudo apt-get install gir1.2-spice-client-gtk-3.0 6. ValueError: Namespace LibvirtGLib not available $ sudo apt-get install libvirt-glib-1.0 7. ValueError: Namespace Libosinfo not available $ sudo apt-get install libosinfo-1.0 8. ImportError: No module named ipaddr $ sudo apt-get install python-ipaddr 9. Namespace Gtk not available: Could not open display: localhost:10.0 $ sudo apt-get install libgtk-3-dev 10. ImportError: cannot import name Vte $ sudo apt-get install gir1.2-vte-2.90 EndOfHelp } function cloning() { if [ $# -lt 5 ]; then echo '[-] You must provide <VM_NAME> <path_to_hdd> <start_from_number> <#vm_to_create> <path_where_to_store> <network_base>' exit 1 fi for i in $(seq "$3" "$4"); do worked=1 # bad macaddress can be generated while [ $worked -eq 1 ]; do macaddr=$(hexdump -n 6 -ve '1/1 "%.2x "' /dev/random | awk -v a="2,6,a,e" -v r="$RANDOM" 'BEGIN{srand(r);}NR==1{split(a,b,",");r=int(rand()*4+1);printf "%s%s:%s:%s:%s:%s:%s\n",substr($1,0,1),b[r],$2,$3,$4,$5,$6}') 2>/dev/null #virt-clone --print-xml -n $1_$i -o $1 -m "$macaddr" if [ ! -f "${5}/${1}_${i}.qcow2" ]; then qemu-img create -f qcow2 -b "$2" "$5/$1_$i.qcow2" fi if virt-clone --print-xml -n "$1_$i" -o "$1" -m "$macaddr" 2>/dev/null|sed "s|<driver name=\"qemu\" type=\"qcow2\"/>|<driver name=\"qemu\" type=\"qcow2\" cache=\"none\" io=\"native\"/>\\n <source file=\"${5}/${1}_${i}.qcow2\"/>|" > "$5/$1_$i.xml"; then virsh define "$5/$1_$i.xml" worked=0 fi done echo "<host mac='$macaddr' name='$1_$i' ip='$6.$(($i+1))'/>" done echo "[+] Enjoy" } # Doesn't work ${$1,,} COMMAND=$(echo "$1"|tr "[A-Z]" "[a-z]") case $COMMAND in '-h') usage exit 0;; 'issues') issues exit 0;; esac #check if start with root if [ $EUID -ne 0 ]; then @@ -508,7 +571,8 @@ fi OS="$(uname -s)" case $COMMAND in 'all') qemu_func seabios_func if [ "$OS" = "Linux" ]; then @@ -518,29 +582,39 @@ if [ "$1" = 'All' ]; then elif [ "$OS" = "Darwin" ]; then install_haxm_mac fi ;; 'qemu') qemu_func;; 'seabios') seabios_func;; 'kvm') install_kvm_linux_apt;; 'haxm') install_haxm_mac;; 'replace_qemu') if declare -f -F "replace_qemu_clues"; then replace_qemu_clues else replace_qemu_clues_public fi ;; 'libvirt') install_libvirt;; 'clone') cloning "$2" "$3" "$4" "$5" "$6" "$7";; 'replace_seabios') if [ ! -d "$2" ]; then echo "[-] Pass the path to SeaBios folder" exit 1 fi cd "$2" || exit 1 if declare -f -F "replace_seabios_clues"; then replace_seabios_clues else replace_seabios_clues_public fi cd - || exit 0 ;; *) usage;; esac -
doomedraven revised this gist
Sep 12, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -73,7 +73,7 @@ function install_haxm_mac() { brew cask install xquartz brew install virt-manager virt-viewer if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.bashrc" @@ -165,10 +165,10 @@ function install_kvm_linux_apt() { cd "virt-manager-$virt_manager_version" || return python setup.py build python setup.py install if [ "$SHELL" = "/bin/zsh" ] || [ "$SHELL" = "/usr/bin/zsh" ] ; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.bashrc" fi #reboot me here sudo kvm-ok -
doomedraven revised this gist
Sep 11, 2018 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -364,8 +364,7 @@ function qemu_func() { fi make -j"$(getconf _NPROCESSORS_ONLN)" if [ "$OS" = "Linux" ]; then checkinstall -D --pkgname=qemu-$qemu_version elif [ "$OS" = "Darwin" ]; then make -j"$(getconf _NPROCESSORS_ONLN)" install fi -
doomedraven revised this gist
Sep 11, 2018 . 1 changed file with 310 additions and 357 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ # https://www.doomedraven.com/2016/05/kvm.html # 11.09.2018 - code improvement # 09.09.2018 - ACPI fixes - huge thanks to @2sec4u for your patience and your time/help :P # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes @@ -10,14 +11,18 @@ # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # https://www.shellcheck.net/ # ACPI tables related # https://wiki.archlinux.org/index.php/DSDT # Dump on linux # sudo acpidump > acpidump.out # Dump on Windows # https://acpica.org/downloads/binary-tools # acpixtract -a acpi/4/acpi.dump # sudo acpixtract -a acpidump.out # sudo iasl -d DSDT.dat # Decompile: iasl -d dsdt.dat # Recompile: iasl -tc dsdt.dsl @@ -39,17 +44,19 @@ virt_manager_version=1.5.0 OS="" function usage() { echo "Usage: $0 <func_name>" echo "" echo "Commands:" echo " All" echo " QEMU" echo " SeaBios" echo " KVM - this will install intel-HAXM if you on Mac" echo " HAXM - Mac Hardware Accelerated Execution Manager" echo " libvirt - install libvirt" echo " replace_qemu - only fix antivms in QEMU source" echo " replace_seabios <path> - only fix antivms in SeaBios source" echo " issues - will give you error - solution list" echo " cuckoo - add cuckoo user to libvirt(d) group" exit } @@ -66,68 +73,66 @@ function install_haxm_mac() { brew cask install xquartz brew install virt-manager virt-viewer if echo "$SHELL" = "/bin/zsh" || echo "$SHELL" = "/usr/bin/zsh"; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.zsh" else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> "$HOME/.bashrc" fi } function install_libvirt() { cd /tmp || return if [ -f libvirt-$libvirt_version.tar.xz ]; then rm -r libvirt-$libvirt_version else wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz fi tar xf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version || return if [ "$OS" = "Linux" ]; then #sudo apt-get build-dep libvirt ./autogen.sh --system --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes --with-secdriver-apparmor=yes --with-apparmor-profiles --with-apparmor-profiles make -j"$(getconf _NPROCESSORS_ONLN)" make -j"$(getconf _NPROCESSORS_ONLN)" install elif [ "$OS" = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit if [ -f /etc/libvirt/libvirtd.conf ]; then path="/etc/libvirt/libvirtd.conf" elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then path="/usr/local/etc/libvirt/libvirtd.conf" fi sed -i 's/#unix_sock_group/unix_sock_group/g' $path sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' $path sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' $path sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' $path # https://gitlab.com/apparmor/apparmor/wikis/Libvirt echo "[+] Setting AppArmor for libvirt/kvm/qemu" sed -i 's/#security_driver = "selinux"/security_driver = "apparmor"/g' /etc/libvirt/qemu.conf aa-complain /usr/sbin/libvirtd cd /tmp || return if [ ! -f v$libvirt_version.zip ]; then wget https://github.com/libvirt/libvirt-python/archive/v$libvirt_version.zip fi unzip v$libvirt_version.zip cd libvirt-python* || return python setup.py build sudo python setup.py install } function install_kvm_linux_apt() { sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev -y sudo apt-get install gtk-update-icon-cache -y sudo apt-get install lvm2 -y sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev -y # WSL support sudo apt-get install gcc make gnutls-bin @@ -137,302 +142,217 @@ function install_kvm_linux_apt() { # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c groupname="" if grep -q -E '^libvirtd:' /etc/group; then groupname="libvirtd" elif grep -q -E '^libvirt:' /etc/group; then groupname="libvirt" else # create group if missed groupname="libvirt" sudo groupadd libvirt fi usermod -G $groupname -a "$(whoami)" systemctl enable libvirtd.service systemctl restart libvirtd.service systemctl enable virtlogd.socket systemctl restart virtlogd.socket if [ ! -f "v$virt_manager_version.zip" ]; then wget https://github.com/virt-manager/virt-manager/archive/v$virt_manager_version.zip fi unzip "v$virt_manager_version" cd "virt-manager-$virt_manager_version" || return python setup.py build python setup.py install if echo "$SHELL" = "/bin/zsh" || echo "$SHELL" = "/usr/bin/zsh"; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > "$HOME/.zsh" else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > "$HOME/.bashrc" fi #reboot me here sudo kvm-ok } function replace_qemu_clues() { echo '[+] Patching QEMU clues' if ! sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c; then echo 'QEMU HARDDISK was not replaced in core.c'; fail=1 fi if ! sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/scsi/scsi-disk.c; then echo 'QEMU HARDDISK was not replaced in scsi-disk.c'; fail=1 fi if ! sed -i 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/core.c; then echo 'QEMU DVD-ROM was not replaced in core.c'; fail=1 fi if ! sed -i 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/atapi.c; then echo 'QEMU DVD-ROM was not replaced in atapi.c'; fail=1 fi if ! sed -i 's/s->vendor = g_strdup("QEMU");/s->vendor = g_strdup("<WOOT>");/g' qemu*/hw/scsi/scsi-disk.c; then echo 'Vendor string was not replaced in scsi-disk.c'; fail=1 fi if ! sed -i 's/QEMU CD-ROM/<WOOT> CD-ROM/g' qemu*/hw/scsi/scsi-disk.c; then echo 'QEMU CD-ROM was not patched in scsi-disk.c'; fail=1 fi if ! sed -i 's/padstr8(buf + 8, 8, "QEMU");/padstr8(buf + 8, 8, "<WOOT>");/g' qemu*/hw/ide/atapi.c; then echo 'padstr was not replaced in atapi.c'; fail=1 fi if ! sed -i 's/QEMU MICRODRIVE/<WOOT> MICRODRIVE/g' qemu*/hw/ide/core.c; then echo 'QEMU MICRODRIVE was not replaced in core.c'; fail=1 fi if ! sed -i 's/KVMKVMKVM\\0\\0\\0/GenuineIntel/g' qemu*/target/i386/kvm.c; then echo 'KVMKVMKVM was not replaced in kvm.c'; fail=1 fi # by @http_error_418 if sed -i 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c; then echo 'Microsoft Hv was not replaced in target/i386/kvm.c'; fail=1 fi if ! sed -i 's/"bochs"/"hawks"/g' qemu*/block/bochs.c; then echo 'BOCHS was not replaced in block/bochs.c'; fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) if ! sed -i 's/"BOCHS "/"ALASKA"/g' qemu*/include/hw/acpi/aml-build.h; then echo 'bochs was not replaced in include/hw/acpi/aml-build.h'; fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) if ! sed -i 's/Bochs Pseudo/Intel RealTime/g' qemu*/roms/ipxe/src/drivers/net/pnic.c; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c'; fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) if ! sed -i 's/Bochs\/Plex86/<WOOT>\/FIRM64/g' qemu*/roms/vgabios/vbe.c; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c'; fail=1 fi } function replace_seabios_clues() { echo "[+] deleting BOCHS APCI tables" #rm src/fw/*.hex >/dev/null 2>&1 echo "[+] Generating SeaBios Kconfig" ./scripts/kconfig/merge_config.sh -o . >/dev/null 2>&1 sed -i 's/CONFIG_ACPI_DSDT=y/CONFIG_ACPI_DSDT=n/g' .config sed -i 's/CONFIG_XEN=y/CONFIG_XEN=n/g' .config echo "[+] Fixing SeaBios antivms" if ! sed -i 's/Bochs/<WOOT>/g' src/config.h; then echo 'Bochs was not replaced in src/config.h'; fail=1 fi if ! sed -i 's/BOCHSCPU/<WOOT>/g' src/config.h; then echo 'BOCHSCPU was not replaced in src/config.h'; fail=1 fi if ! sed -i 's/"BOCHS "/"<WOOT>"/g' src/config.h; then echo 'BOCHS was not replaced in src/config.h'; fail=1 fi if ! sed -i 's/BXPC/<WOOT>/g' src/config.h; then echo 'BXPC was not replaced in src/config.h'; fail=1 fi if ! sed -i 's/QEMU0001/<WOOT>/g' src/fw/ssdt-misc.dsl; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl'; fail=1 fi if ! sed -i 's/QEMU\/Bochs/<WOOT>\/<WOOT>/g' vgasrc/Kconfig; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig'; fail=1 fi if ! sed -i 's/qemu /<WOOT> /g' vgasrc/Kconfig; then echo 'qemu was not replaced in vgasrc/Kconfig'; fail=1 fi FILES=( src/hw/blockcmd.c src/fw/paravirt.c ) for file in "${FILES[@]}"; do if ! sed -i 's/"QEMU/"<WOOT>/g' "$file"; then echo "QEMU was not replaced in $file"; fail=1 fi done if ! sed -i 's/"QEMU"/"<WOOT>"/g' src/hw/blockcmd.c; then echo '"QEMU" was not replaced in src/hw/blockcmd.c'; fail=1 fi FILES=( "src/fw/acpi-dsdt.dsl" "src/fw/q35-acpi-dsdt.dsl" ) for file in "${FILES[@]}"; do if ! sed -i 's/"BXPC"/<WOOT>"/g' "$file"; then echo "BXPC was not replaced in $file"; fail=1 fi if ! sed -i 's/"BXDSDT"/"<WOOT>"/g' "$file"; then echo "BXDSDT was not replaced in $file"; fail=1 fi done if ! sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-pcihp.dsl"; then echo 'BXPC was not replaced in src/fw/ssdt-pcihp.dsl'; fail=1 fi if ! sed -i 's/"BXDSDT"/"<WOOT>"/g' "src/fw/ssdt-pcihp.dsl"; then echo 'BXDSDT was not replaced in src/fw/ssdt-pcihp.dsl'; fail=1 fi if ! sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-proc.dsl"; then echo 'BXPC was not replaced in "src/fw/ssdt-proc.dsl"'; fail=1 fi if ! sed -i 's/"BXSSDT"/"<WOOT>"/g' "src/fw/ssdt-proc.dsl"; then echo 'BXSSDT was not replaced in src/fw/ssdt-proc.dsl'; fail=1 fi if ! sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-misc.dsl"; then echo 'BXPC was not replaced in src/fw/ssdt-misc.dsl'; fail=1 fi if ! sed -i 's/"BXSSDTSU"/"<WOOT>"/g' "src/fw/ssdt-misc.dsl"; then echo 'BXDSDT was not replaced in src/fw/ssdt-misc.dsl'; fail=1 fi if ! sed -i 's/"BXSSDTSUSP"/"<WOOT>"/g' src/fw/ssdt-misc.dsl; then echo 'BXSSDTSUSP was not replaced in src/fw/ssdt-misc.dsl'; fail=1 fi if ! sed -i 's/"BXSSDT"/"<WOOT>"/g' src/fw/ssdt-proc.dsl; then echo 'BXSSDT was not replaced in src/fw/ssdt-proc.dsl'; fail=1 fi if ! sed -i 's/"BXSSDTPCIHP"/"<WOOT>"/g' src/fw/ssdt-pcihp.dsl; then echo 'BXPC was not replaced in src/fw/ssdt-pcihp.dsl'; fail=1 fi FILES=( src/fw/q35-acpi-dsdt.dsl src/fw/acpi-dsdt.dsl src/fw/ssdt-misc.dsl src/fw/ssdt-proc.dsl src/fw/ssdt-pcihp.dsl src/config.h ) for file in "${FILES[@]}"; do if ! sed -i 's/"BXPC"/"A M I"/g' "$file"; then echo "BXPC was not replaced in $file"; fail=1 fi done } function qemu_func() { cd /tmp || return echo '[+] Cleaning QEMU old install if exists' rm -r /usr/share/qemu >/dev/null 2>&1 sudo dpkg -l |grep qemu |cut -d " " -f 3|xargs dpkg -r >/dev/null 2>&1 echo '[+] Downloading QEMU source code' if [ ! -f qemu-$qemu_version.tar.xz ]; then wget https://download.qemu.org/qemu-$qemu_version.tar.xz fi tar xJf qemu-$qemu_version.tar.xz fail=0 if [ "$OS" = "Linux" ]; then sudo apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev -y elif [ "$OS" = "Darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools glib fi # WOOT # some checks may be depricated, but keeping them for compatibility with old versions if [ $? -eq 0 ]; then replace_qemu_clues if [ $fail -eq 0 ]; then echo '[+] Starting compile it' cd qemu-$qemu_version || return # add in future --enable-netmap https://sgros-students.blogspot.com/2016/05/installing-and-testing-netmap.html # remove --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user if you want all targets if [ "$OS" = "Linux" ]; then ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user --enable-gnutls --enable-docs --enable-gtk --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-kvm --enable-linux-aio --enable-cap-ng --enable-vhost-net --enable-vhost-crypto --enable-spice --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libssh2 --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone elif [ "$OS" = "Darwin" ]; then # --enable-vhost-net --enable-vhost-crypto ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-hax --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone fi @@ -442,11 +362,12 @@ function qemu_func() { if [ -f /usr/share/qemu/qemu_logo_no_text.svg ]; then rm /usr/share/qemu/qemu_logo_no_text.svg fi make -j"$(getconf _NPROCESSORS_ONLN)" if [ "$OS" = "Linux" ]; then #checkinstall -D --pkgname=qemu-$qemu_version echo "aja" elif [ "$OS" = "Darwin" ]; then make -j"$(getconf _NPROCESSORS_ONLN)" install fi # hack for libvirt/virt-manager if [ ! -f /usr/bin/qemu-system-x86_64-spice ]; then @@ -461,9 +382,8 @@ function qemu_func() { if [ $? -eq 0 ]; then echo '[+] Patched, compiled and installed' else echo '[-] Install failed' fi else echo '[-] Compilling failed' fi @@ -475,7 +395,7 @@ function qemu_func() { else echo '[-] Download QEMU source was not possible' fi if [ "$OS" = "linux" ]; then dpkg --get-selections | grep "qemu" | xargs sudo apt-mark hold #sudo apt-mark unhold qemu fi @@ -485,42 +405,35 @@ function qemu_func() { function seabios_func() { fail=0 echo '[+] Installing SeaBios dependencies' apt-get install git iasl -y if [ -d seabios ]; then rm -r seabios fi if git clone https://github.com/coreboot/seabios.git; then cd seabios || return if replace_seabios_clues; then # sudo make help # sudo make menuconfig -> BIOS tables -> disable Include default ACPI DSDT if make -j "$(getconf _NPROCESSORS_ONLN)"; then echo '[+] Replacing old bios.bin to new out/bios.bin' bios=0 FILES=( "/usr/share/qemu/bios.bin" "/usr/share/qemu/bios-256k.bin" ) for file in "${FILES[@]}"; do cp -vf out/bios.bin "$file" bios=1 done if [ $bios -eq 1 ]; then echo '[+] Patched bios.bin placed correctly' else echo '[-] Bios patching failed' fi else echo '[-] Bios compilation failed' fi cd - || return else echo '[-] check previous errors' fi @@ -529,15 +442,62 @@ function seabios_func() { fi } function issues(){ cat << EndOfHelp ### Errors and Solutions * Error: required by /usr/lib/libvirt/storage-file/libvirt_storage_file_fs.so * Solution: systemctl daemon-reload systemctl restart libvirtd libvirt-guests.service * Error: /libvirt.so.0: version LIBVIRT_PRIVATE_x.x.0' not found (required by /usr/sbin/libvirtd) * Solutions: 1. sudo apt-get purge libvirt0 libvirt-bin 2. ls -lah /usr/lib/libvirt* * Make sure what all symlinks pointing to last version * Error: libvirt: Polkit error : authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage' * Solution: sed -i 's/#unix_sock_group/unix_sock_group/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' /etc/libvirt/libvirtd.conf * Slow HDD/Snapshot taking performance? Modify <driver name='qemu' type='qcow2'/> To <driver name='qemu' type='qcow2' cache='none' io='native'/> EndOfHelp } function cuckoo_user() { groupname="" if grep -q -E '^libvirtd:' /etc/group; then groupname="libvirtd" elif grep -q -E '^libvirt:' /etc/group; then groupname="libvirt" else # create group if missed groupname="libvirt" sudo groupadd libvirt fi usermod -G $groupname -a cuckoo } COMMAND=$1 if [ $# -eq 0 ] || [ "$COMMAND" = '-h' ]; then usage exit 0 fi if [ "$COMMAND" = "issues" ]; then issues exit 0 fi @@ -552,43 +512,36 @@ OS="$(uname -s)" if [ "$1" = 'All' ]; then qemu_func seabios_func if [ "$OS" = "Linux" ]; then install_kvm_linux_apt systemctl daemon-reload systemctl restart libvirtd libvirt-guests.service elif [ "$OS" = "Darwin" ]; then install_haxm_mac fi cuckoo_user fi if [ "$COMMAND" = 'QEMU' ]; then qemu_func elif [ "$COMMAND" = 'SeaBios' ]; then seabios_func elif [ "$COMMAND" = 'KVM' ]; then install_kvm_linux_apt elif [ "$COMMAND" = 'HAXM' ]; then install_haxm_mac elif [ "$COMMAND" = "replace_qemu" ]; then replace_qemu_clues elif [ "$COMMAND" = "libvirt" ]; then install_libvirt elif [ "$COMMAND" = "cuckoo" ]; then cuckoo_user elif [ "$COMMAND" = "replace_seabios" ]; then if [ ! -d "$2" ]; then echo "[-] Pass the path to SeaBios folder" exit 1 fi cd "$2" || exit 1 replace_seabios_clues cd - || exit 0 fi -
doomedraven revised this gist
Sep 11, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -75,7 +75,7 @@ function install_haxm_mac() { function install_libvirt() { cd /tmp if [ -f libvirt-$libvirt_version.tar.xz ]; then rm -r libvirt-$libvirt_version else wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz @@ -484,7 +484,7 @@ function qemu_func() { function seabios_func() { fail=0 echo '[+] Installing SeaBios dependencies' apt-get install git iasl if [ -d seabios ]; then rm -r seabios -
doomedraven revised this gist
Sep 10, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -162,9 +162,9 @@ function install_kvm_linux_apt() { python setup.py build python setup.py install if [ `echo $SHELL` = "/bin/zsh" ]; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> $HOME/.zsh else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" >> $HOME/.bashrc fi #reboot me here sudo kvm-ok -
doomedraven revised this gist
Sep 10, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -509,7 +509,7 @@ function seabios_func() { ) for file in ${FILES[@]}; do if [ -f $file ]; then # cp $file $file_back cp out/bios.bin $file bios=1 fi -
doomedraven revised this gist
Sep 10, 2018 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -106,7 +106,7 @@ function install_libvirt() { sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' $path sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' $path sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_rw = "none"/auth_unix_rw = "none"/g' $path cd /tmp wget https://github.com/libvirt/libvirt-python/archive/v$libvirt_version.zip @@ -137,9 +137,9 @@ function install_kvm_linux_apt() { # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c groupname="" if [ `grep -q -E "^libvirtd:" /etc/group` ]; then groupname="libvirtd" elif [ `grep -q -E "^libvirt:" /etc/group` ]; then groupname="libvirt" else # create group if missed @@ -270,7 +270,7 @@ function replace_seabios_clues() { fail=1 fi sed -i 's/"BOCHS "<WOOT>"/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 @@ -296,7 +296,7 @@ function replace_seabios_clues() { fail=1 fi FILES= src/hw/blockcmd.c src/fw/paravirt.c ) @@ -423,7 +423,6 @@ function qemu_func() { if [ $? -eq 0 ]; then cd qemu*/roms/seabios replace_seabios_clues replace_qemu_clues if [ $fail -eq 0 ]; then echo '[+] Starting compile it' @@ -464,6 +463,7 @@ function qemu_func() { else echo '[-] Install failed' fi cd - else echo '[-] Compilling failed' fi -
doomedraven revised this gist
Sep 9, 2018 . 1 changed file with 263 additions and 117 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,25 @@ # https://www.doomedraven.com/2016/05/kvm.html # 09.09.2018 - ACPI fixes - huge thanks to @2sec4u for your patience and your time/help :P # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # ACPI tables related # https://wiki.archlinux.org/index.php/DSDT # Dump on linux # cat /sys/firmware/acpi/tables/DSDT > dsdt.dat # Dump on Windows # https://acpica.org/downloads/binary-tools # acpixtract -a acpi/4/acpi.dump # Decompile: iasl -d dsdt.dat # Recompile: iasl -tc dsdt.dsl # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ # strs[2] = "VMwareVMware"; /* VMware */ @@ -20,7 +33,7 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version=1.5.0 # autofilled OS="" @@ -34,7 +47,9 @@ function usage() { echo ' SeaBios' echo ' KVM - this will install intel-HAXM if you on Mac' echo ' HAXM - Mac Hardware Accelerated Execution Manager' echo ' libvirt - install libvirt' echo ' replace_qemu - only fix antivms in QEMU source' echo ' replace_seabios <path> - only fix antivms in SeaBios source' exit } @@ -50,17 +65,25 @@ function install_haxm_mac() { brew tap jeffreywildman/homebrew-virt-manager brew cask install xquartz brew install virt-manager virt-viewer if [ `echo $SHELL` = "/bin/zsh" ]; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.zsh else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc fi } function install_libvirt() { cd /tmp if [ -f ibvirt-$libvirt_version.tar.xz ]; then rm -r libvirt-$libvirt_version else wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz fi tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version if [ $OS = "Linux" ]; then #sudo apt-get build-dep libvirt ./autogen.sh --system --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes make -j4 make install @@ -80,16 +103,18 @@ function install_libvirt() { path="/usr/local/etc/libvirt/libvirtd.conf" fi #sed -i 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' $path sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' $path sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' $path sed -i 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' $path cd /tmp wget https://github.com/libvirt/libvirt-python/archive/v$libvirt_version.zip unzip v$libvirt_version.zip cd libvirt-python* python setup.py build sudo python setup.py install } @@ -98,8 +123,9 @@ function install_kvm_linux_apt() { sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev# latest for ubuntu 16 sudo apt-get install gtk-update-icon-cache # sudo apt-get build-dep qemu binfmt-support # #qemu-kvm qemu-system libvirt-bin ubuntu-virt-server python-vm-builder ubuntu-vm-builder bridge-utils sudo apt-get install lvm2 #DEPRICATED sudo apt-get install virt-viewer virt-manager virtinst # Virtual Machine Manager sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev @@ -109,43 +135,37 @@ function install_kvm_linux_apt() { sudo apt-get purge libvirt0 libvirt-bin install_libvirt # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c groupname="" if [ grep -q -E "^libvirtd:" /etc/group ]; then groupname="libvirtd" elif [ grep -q -E "^libvirt:" /etc/group ]; then groupname="libvirt" else # create group if missed groupname="libvirt" sudo groupadd libvirt fi usermod -G $groupname -a cuckoo usermod -G $groupname -a `whoami` systemctl enable libvirtd.service systemctl restart libvirtd.service systemctl enable virtlogd.socket systemctl restart virtlogd.socket wget https://github.com/virt-manager/virt-manager/archive/v$virt_manager_version.zip unzip v$virt_manager_version cd virt-manager-$virt_manager_version python setup.py build python setup.py install if [ `echo $SHELL` = "/bin/zsh" ]; then echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.zsh else echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc fi #reboot me here sudo kvm-ok } @@ -204,20 +224,20 @@ function replace_qemu_clues() { echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed -i 's/"bochs"/"hawks"/g' qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/"BOCHS "/"ALASKA"/g' qemu*/include/hw/acpi/aml-build.h if [ $? -ne 0 ]; then echo 'bochs was not replaced in include/hw/acpi/aml-build.h' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/Bochs Pseudo/Intel RealTime/g' qemu*/roms/ipxe/src/drivers/net/pnic.c if [ $? -ne 0 ]; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c' fail=1 @@ -230,6 +250,158 @@ function replace_qemu_clues() { fi } function replace_seabios_clues() { echo "[+] deleting BOCHS APCI tables" #rm src/fw/*.hex >/dev/null 2>&1 echo "[+] Generating SeaBios Kconfig" ./scripts/kconfig/merge_config.sh -o . >/dev/null 2>&1 sed -i 's/CONFIG_ACPI_DSDT=y/CONFIG_ACPI_DSDT=n/g' .config sed -i 's/CONFIG_XEN=y/CONFIG_XEN=n/g' .config echo "[+] Fixing SeaBios antivms" sed -i 's/Bochs/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'Bochs was not replaced in src/config.h' fail=1 fi sed -i 's/BOCHSCPU/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHSCPU was not replaced in src/config.h' fail=1 fi sed -i 's/"BOCHS "/"<WOOT>"/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 fi sed -i 's/BXPC/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/config.h' fail=1 fi sed -i 's/QEMU0001/<WOOT>/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed -i 's/QEMU\/Bochs/<WOOT>\/<WOOT>/g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig' fail=1 fi sed -i 's/qemu /<WOOT> /g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'qemu was not replaced in vgasrc/Kconfig' fail=1 fi FILES=( src/hw/blockcmd.c src/fw/paravirt.c ) for file in ${FILES[@]}; do sed -i 's/"QEMU/"<WOOT>/g' $file; if [ $? -ne 0 ]; then echo 'QEMU was not replaced in' $file fail=1 fi done sed -i 's/"QEMU"/"<WOOT>"/g' src/hw/blockcmd.c if [ $? -ne 0 ]; then echo '"QEMU" was not replaced in src/hw/blockcmd.c' fail=1 fi FILES=( "src/fw/acpi-dsdt.dsl" "src/fw/q35-acpi-dsdt.dsl" ) for file in ${FILES[@]}; do sed -i 's/"BXPC"/<WOOT>"/g' $file; if [ $? -ne 0 ]; then echo 'BXPC was not replaced in' $file fail=1 fi sed -i 's/"BXDSDT"/"<WOOT>"/g' $file; if [ $? -ne 0 ]; then echo 'BXDSDT was not replaced in' $file fail=1 fi done sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-pcihp.dsl"; if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/fw/ssdt-pcihp.dsl' fail=1 fi sed -i 's/"BXDSDT"/"<WOOT>"/g' "src/fw/ssdt-pcihp.dsl"; if [ $? -ne 0 ]; then echo 'BXDSDT was not replaced in src/fw/ssdt-pcihp.dsl' fail=1 fi sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-proc.dsl"; if [ $? -ne 0 ]; then echo 'BXPC was not replaced in "src/fw/ssdt-proc.dsl"' fail=1 fi sed -i 's/"BXSSDT"/"<WOOT>"/g' "src/fw/ssdt-proc.dsl"; if [ $? -ne 0 ]; then echo 'BXSSDT was not replaced in "src/fw/ssdt-proc.dsl" ' fail=1 fi sed -i 's/"BXPC"/"<WOOT>"/g' "src/fw/ssdt-misc.dsl" ; if [ $? -ne 0 ]; then echo 'BXPC was not replaced in "src/fw/ssdt-misc.dsl"' fail=1 fi sed -i 's/"BXSSDTSU"/"<WOOT>"/g' "src/fw/ssdt-misc.dsl" ; if [ $? -ne 0 ]; then echo 'BXDSDT was not replaced in "src/fw/ssdt-misc.dsl"' fail=1 fi sed -i 's/"BXSSDTSUSP"/"<WOOT>"/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'BXSSDTSUSP was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed -i 's/"BXSSDT"/"<WOOT>"/g' src/fw/ssdt-proc.dsl if [ $? -ne 0 ]; then echo 'BXSSDT was not replaced in src/fw/ssdt-proc.dsl' fail=1 fi sed -i 's/"BXSSDTPCIHP"/"<WOOT>"/g' src/fw/ssdt-pcihp.dsl if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/fw/ssdt-pcihp.dsl' fail=1 fi FILES=( src/fw/q35-acpi-dsdt.dsl src/fw/acpi-dsdt.dsl src/fw/ssdt-misc.dsl src/fw/ssdt-proc.dsl src/fw/ssdt-pcihp.dsl src/config.h ) for file in ${FILES[@]}; do sed -i 's/"BXPC"/"<WOOT>"/g' $file; if [ $? -ne 0 ]; then echo 'BXPC was not replaced in' $file fail=1 fi done } function qemu_func() { echo '[+] Downloading QEMU source code' if [ ! -f qemu-$qemu_version.tar.xz ]; then @@ -249,6 +421,9 @@ function qemu_func() { # WOOT # some checks may be depricated, but keeping them for compatibility with old versions if [ $? -eq 0 ]; then cd qemu*/roms/seabios replace_seabios_clues cd - replace_qemu_clues if [ $fail -eq 0 ]; then echo '[+] Starting compile it' @@ -265,7 +440,7 @@ function qemu_func() { if [ $? -eq 0 ]; then echo '[+] Starting Install it' #dpkg -i qemu*.deb if [ -f /usr/share/qemu/qemu_logo_no_text.svg ]; then rm /usr/share/qemu/qemu_logo_no_text.svg fi make -j4 @@ -281,6 +456,9 @@ function qemu_func() { if [ ! -f /usr/bin/kvm-spice ]; then ln -s /usr/bin/qemu-system-x86_64 /usr/bin/kvm-spice fi if [ ! -f /usr/bin/kvm ]; then ln -s /usr/bin/qemu-system-x86_64 /usr/bin/kvm fi if [ $? -eq 0 ]; then echo '[+] Patched, compiled and installed' else @@ -303,86 +481,38 @@ function qemu_func() { fi } function seabios_func() { fail=0 echo '[+] Installign SeaBios dependencies' apt-get install git iasl if [ -d seabios ]; then rm -r seabios fi git clone https://github.com/coreboot/seabios.git if [ $? -eq 0 ]; then cd seabios replace_seabios_clues cd - if [ $fail -eq 0 ]; then # sudo make help # sudo make menuconfig -> BIOS tables -> disable Include default ACPI DSDT make -j4 if [ $? -eq 0 ]; then echo '[+] Compiled SeaBios, bios file located in -> out/bios.bin' echo '[+] Replacing old bios.bin to new one, with backup' bios=0 FILES=( /usr/share/qemu/bios.bin /usr/share/qemu/bios-256k.bin ) for file in ${FILES[@]}; do if [ -f $file ]; then cp $file $file_back cp out/bios.bin $file bios=1 fi if [ $bios -eq 1 ]; then echo '[+] Patched bios.bin placed correctly' else @@ -403,10 +533,12 @@ function seabios_func { COMMAND=$1 if [ $# -eq 0 ]; then usage exit 0 fi if [ $COMMAND = '-h' ]; then usage exit 0 fi #check if start with root @@ -443,6 +575,20 @@ if [ $COMMAND = 'HAXM' ]; then install_haxm_mac fi if [ $COMMAND = "replace_qemu" ]; then replace_qemu_clues fi if [ $COMMAND = "libvirt" ]; then install_libvirt fi if [ $COMMAND = "replace_seabios" ]; then if [ ! -d $2 ]; then echo "[-] Pass the path to SeaBios folder" exit 1 fi cd $2 replace_seabios_clues cd - fi -
doomedraven revised this gist
Sep 6, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,7 +217,7 @@ function replace_qemu_clues() { fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/Bochs Pseudo/Intel RealTime/g 'qemu*/roms/ipxe/src/drivers/net/pnic.c if [ $? -ne 0 ]; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c' fail=1 -
doomedraven revised this gist
Sep 5, 2018 . 1 changed file with 42 additions and 45 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,13 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 05.09.2018 - libivrt 4.7 and virtlogd # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ # strs[2] = "VMwareVMware"; /* VMware */ @@ -82,11 +79,11 @@ function install_libvirt() { elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then path="/usr/local/etc/libvirt/libvirtd.conf" fi #sed -i 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c usermod -G libvirtd -a "cuckoo" @@ -97,7 +94,7 @@ function install_libvirt() { function install_kvm_linux_apt() { sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev# latest for ubuntu 16 sudo apt-get install gtk-update-icon-cache @@ -120,11 +117,11 @@ function install_kvm_linux_apt() { #auth_unix_ro = "none" #auth_unix_rw = "none" #sed -i 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c usermod -G libvirtd -a cuckoo @@ -135,7 +132,7 @@ function install_kvm_linux_apt() { systemctl start libvirtd.service systemctl enable virtlogd.socket systemctl start virtlogd.socket cd /tmp git clone https://github.com/libvirt/libvirt-python.git cd libvirt-python @@ -156,77 +153,77 @@ function install_kvm_linux_apt() { function replace_qemu_clues() { echo '[+] Patching QEMU clues' sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in core.c' fail=1 fi sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in scsi-disk.c' fail=1 fi sed -i 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in core.c' fail=1 fi sed -i 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in atapi.c' fail=1 fi sed -i 's/s->vendor = g_strdup("QEMU");/s->vendor = g_strdup("<WOOT>");/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'Vendor string was not replaced in scsi-disk.c' fail=1 fi sed -i 's/QEMU CD-ROM/<WOOT> CD-ROM/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU CD-ROM was not patched in scsi-disk.c' fail=1 fi sed -i 's/padstr8(buf + 8, 8, "QEMU");/padstr8(buf + 8, 8, "<WOOT>");/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'padstr was not replaced in atapi.c' fail=1 fi sed -i 's/QEMU MICRODRIVE/<WOOT> MICRODRIVE/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU MICRODRIVE was not replaced in core.c' fail=1 fi sed -i 's/KVMKVMKVM\\0\\0\\0/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'KVMKVMKVM was not replaced in kvm.c' fail=1 fi # by @http_error_418 sed -i 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed -i 's/"bochs"/"hawks"/g'qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/"BOCHS "/"<WOOT> "/g' qemu*/include/hw/acpi/aml-build.h if [ $? -ne 0 ]; then echo 'bochs was not replaced in include/hw/acpi/aml-build.h' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/Bochs Pseudo/Intel RealTime/g'qemu*/roms/ipxe/src/drivers/net/pnic.c if [ $? -ne 0 ]; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/Bochs\/Plex86/<WOOT>\/FIRM64/g' qemu*/roms/vgabios/vbe.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c' fail=1 @@ -272,7 +269,7 @@ function qemu_func() { rm /usr/share/qemu/qemu_logo_no_text.svg fi make -j4 if [ $OS = "Linux" ]; then checkinstall -D --pkgname=$qemu_version elif [ $OS = "Darwin" ]; then make install @@ -314,38 +311,38 @@ function seabios_func { if [ $? -eq 0 ]; then cd seabios sed -i 's/Bochs/Dells/g' src/config.h if [ $? -ne 0 ]; then echo 'Bochs was not replaced in src/config.h' fail=1 fi sed -i 's/BOCHSCPU/DELLCPU/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHSCPU was not replaced in src/config.h' fail=1 fi sed -i 's/BOCHS/DELLS/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 fi sed -i 's/BXPC/DELL/g' src/config.h if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/config.h' fail=1 fi sed -i 's/QEMU0001/DELL0001/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed -i 's/QEMU\/Bochs/DELL\/Dells/g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig' fail=1 fi sed -i 's/qemu /dell /g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'qemu was not replaced in vgasrc/Kconfig' fail=1 @@ -356,14 +353,14 @@ function seabios_func { "src/fw/paravirt.c" ) for file in ${FILES[@]}; do sed -i 's/"QEMU/"DELL/g' $file; if [ $? -ne 0 ]; then echo 'QEMU was not replaced in $file' fail=1 fi done sed -i 's/"QEMU"/"DELL"/g' src/hw/blockcmd.c if [ $? -ne 0 ]; then echo '"QEMU" was not replaced in src/hw/blockcmd.c' fail=1 @@ -425,24 +422,24 @@ if [ "$1" = 'All' ]; then seabios_func if [ $OS = "Linux" ]; then install_kvm_linux_apt elif [ $OS = "Darwin" ]; then install_haxm_mac fi fi if [ $COMMAND = 'QEMU' ]; then qemu_func fi if [ $COMMAND = 'SeaBios' ]; then seabios_func fi if [ $COMMAND = 'KVM' ]; then install_kvm_linux_apt fi if [ $COMMAND = 'HAXM' ]; then install_haxm_mac fi -
doomedraven revised this gist
Sep 5, 2018 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ # mac - should be sed -i "" # https://www.doomedraven.com/2016/05/kvm.html # 05.09.2018 - libvirt 4.7 + virtlogd # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 @@ -132,6 +133,9 @@ function install_kvm_linux_apt() { systemctl stop libvirtd.service systemctl enable libvirtd.service systemctl start libvirtd.service systemctl enable virtlogd.socket systemctl start virtlogd.socket cd /tmp git clone https://github.com/libvirt/libvirt-python.git cd libvirt-python -
doomedraven revised this gist
Sep 5, 2018 . 1 changed file with 0 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,29 +10,6 @@ # https://github.com/dylanaraps/pure-bash-bible # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ # strs[2] = "VMwareVMware"; /* VMware */ -
doomedraven revised this gist
Sep 5, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,7 +85,6 @@ function install_libvirt() { tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version if [ $OS = "Linux" ]; then sudo apt-get build-dep libvirt ./autogen.sh --system --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes make -j4 -
doomedraven revised this gist
Sep 5, 2018 . 1 changed file with 97 additions and 30 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,38 @@ #!/bin/bash # mac - should be sed -i "" # https://www.doomedraven.com/2016/05/kvm.html # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible ### search for 51454d55 or 554D4551, '"QEMU', "'QEMU", "'KVM", '"KVM"', /QEMU, 0x46f4 # 0x46f4, /* CRC16() of "QEMU" */ # 0x1030, /* CRC16() of "DELL" */ # "'KVM", '"KVM"', /QEMU # "KVM/Linux # -qemu" # 0x53504D554D4551LL; /* "QEMUMPTx" */ # 0x51454d5520434647ULL /* "QEMU CFG" */ #"Qemu # "BOCHS # QEMU/Bochs # depends on QEMU # _HID # "Bochs" # "BOCHSCPU" # "BOCHS " # "BXPC" # qemu0 # 51454d55 or 554D4551 # LLED = 0x4C4C4544 # DELL # WDC WD20EARS # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ # strs[2] = "VMwareVMware"; /* VMware */ @@ -19,7 +44,7 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version="1.5.0" # autofilled @@ -50,29 +75,67 @@ function install_haxm_mac() { brew tap jeffreywildman/homebrew-virt-manager brew cask install xquartz brew install virt-manager virt-viewer echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.zsh } function install_libvirt() { cd /tmp wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version if [ $OS = "Linux" ]; then cd libvirt sudo apt-get build-dep libvirt ./autogen.sh --system --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-yajl=yes make -j4 make install elif [ $OS = "Darwin" ]; then ./autogen.sh --system --prefix=/usr/local/ --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no --with-wireshark-dissector=no --with-yajl=yes fi # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit #/etc/libvirt/libvirtd.conf #unix_sock_group = "libvirt" #unix_sock_ro_perms = "0777" # set to 0770 to deny non-group libvirt users #unix_sock_rw_perms = "0770" #auth_unix_ro = "none" #auth_unix_rw = "none" if [ -f /etc/libvirt/libvirtd.conf ]; then path="/etc/libvirt/libvirtd.conf" elif [ -f /usr/local/etc/libvirt/libvirtd.conf ]; then path="/usr/local/etc/libvirt/libvirtd.conf" fi #sed 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c usermod -G libvirtd -a "cuckoo" usermod -G libvirtd -a `whoami` pip install libvirt-python } function install_kvm_linux_apt() { sed 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev libgtk2.0-bin libxml2-utils systemtap-sdt-dev# latest for ubuntu 16 sudo apt-get install gtk-update-icon-cache sudo apt-get build-dep qemu binfmt-support sudo apt-get install lvm2 python-vm-builder ubuntu-vm-builder bridge-utils #qemu-kvm qemu-system libvirt-bin ubuntu-virt-server #DEPRICATED sudo apt-get install virt-viewer virt-manager virtinst # Virtual Machine Manager sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev # WSL support sudo apt-get install gcc make gnutls-bin # remove old sudo apt-get purge libvirt0 libvirt-bin install_libvirt # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit #/etc/libvirt/libvirtd.conf #unix_sock_group = "libvirt" #unix_sock_ro_perms = "0777" # set to 0770 to deny non-group libvirt users @@ -93,10 +156,13 @@ function install_kvm_linux_apt() { systemctl stop libvirtd.service systemctl enable libvirtd.service systemctl start libvirtd.service cd /tmp git clone https://github.com/libvirt/libvirt-python.git cd libvirt-python python setup.py build sudo python setup.py install wget https://github.com/virt-manager/virt-manager/archive/v$virt_manager_version.zip unzip v$virt_manager_version cd virt-manager-$virt_manager_version sudo apt-get build-dep virt-manager @@ -107,6 +173,7 @@ function install_kvm_linux_apt() { sudo kvm-ok } function replace_qemu_clues() { echo '[+] Patching QEMU clues' sed 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c @@ -160,7 +227,7 @@ function replace_qemu_clues() { echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed 's/"bochs"/"hawks"/g'qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 @@ -179,7 +246,7 @@ function replace_qemu_clues() { fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed 's/Bochs\/Plex86/<WOOT>\/FIRM64/g' qemu*/roms/vgabios/vbe.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c' fail=1 @@ -200,7 +267,7 @@ function qemu_func() { sudo apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev elif [ $OS = "Darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools glib fi # WOOT # some checks may be depricated, but keeping them for compatibility with old versions @@ -267,38 +334,38 @@ function seabios_func { if [ $? -eq 0 ]; then cd seabios sed 's/Bochs/Dells/g' src/config.h if [ $? -ne 0 ]; then echo 'Bochs was not replaced in src/config.h' fail=1 fi sed 's/BOCHSCPU/DELLCPU/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHSCPU was not replaced in src/config.h' fail=1 fi sed 's/BOCHS/DELLS/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 fi sed 's/BXPC/DELL/g' src/config.h if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/config.h' fail=1 fi sed 's/QEMU0001/DELL0001/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed 's/QEMU\/Bochs/DELL\/Dells/g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig' fail=1 fi sed 's/qemu /dell /g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'qemu was not replaced in vgasrc/Kconfig' fail=1 @@ -309,14 +376,14 @@ function seabios_func { "src/fw/paravirt.c" ) for file in ${FILES[@]}; do sed 's/"QEMU/"DELL/g' $file; if [ $? -ne 0 ]; then echo 'QEMU was not replaced in $file' fail=1 fi done sed 's/"QEMU"/"DELL"/g' src/hw/blockcmd.c if [ $? -ne 0 ]; then echo '"QEMU" was not replaced in src/hw/blockcmd.c' fail=1 -
doomedraven revised this gist
Sep 2, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ #https://www.qemu.org/download/#source or https://download.qemu.org/ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version="1.5.0" @@ -65,7 +65,7 @@ function install_kvm_linux_apt() { sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version-rc2 sudo apt-get build-dep libvirt ./autogen.sh --system ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no -
doomedraven revised this gist
Sep 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,7 +65,7 @@ function install_kvm_linux_apt() { sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-* sudo apt-get build-dep libvirt ./autogen.sh --system ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no -
doomedraven revised this gist
Sep 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ #https://www.qemu.org/download/#source or https://download.qemu.org/ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.7.0-rc2 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version="1.5.0" -
doomedraven revised this gist
Aug 26, 2018 . 1 changed file with 33 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 19.08.2018 - Intel HAXM support + MacOSX support not finished # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 @@ -19,7 +19,7 @@ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.6.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version="1.5.0" # autofilled @@ -57,7 +57,7 @@ function install_haxm_mac() { function install_kvm_linux_apt() { sed 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev gtk-update-icon-cache libgtk2.0-bin # latest for ubuntu 16 sudo apt-get build-dep qemu binfmt-support @@ -72,19 +72,19 @@ function install_kvm_linux_apt() { make -j4 make install # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit #/etc/libvirt/libvirtd.conf #unix_sock_group = "libvirt" #unix_sock_ro_perms = "0777" # set to 0770 to deny non-group libvirt users #unix_sock_rw_perms = "0770" #auth_unix_ro = "none" #auth_unix_rw = "none" #sed 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c usermod -G libvirtd -a cuckoo @@ -96,7 +96,7 @@ function install_kvm_linux_apt() { pip install libvirt-python wget https://github.com/virt-manager/virt-manager/archive/v$virt_manager_version.zip unzip v$virt_manager_version cd virt-manager-$virt_manager_version sudo apt-get build-dep virt-manager @@ -109,77 +109,77 @@ function install_kvm_linux_apt() { function replace_qemu_clues() { echo '[+] Patching QEMU clues' sed 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in core.c' fail=1 fi sed 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in scsi-disk.c' fail=1 fi sed 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in core.c' fail=1 fi sed 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in atapi.c' fail=1 fi sed 's/s->vendor = g_strdup("QEMU");/s->vendor = g_strdup("<WOOT>");/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'Vendor string was not replaced in scsi-disk.c' fail=1 fi sed 's/QEMU CD-ROM/<WOOT> CD-ROM/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU CD-ROM was not patched in scsi-disk.c' fail=1 fi sed 's/padstr8(buf + 8, 8, "QEMU");/padstr8(buf + 8, 8, "<WOOT>");/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'padstr was not replaced in atapi.c' fail=1 fi sed 's/QEMU MICRODRIVE/<WOOT> MICRODRIVE/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU MICRODRIVE was not replaced in core.c' fail=1 fi sed 's/KVMKVMKVM\\0\\0\\0/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'KVMKVMKVM was not replaced in kvm.c' fail=1 fi # by @http_error_418 sed 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed 's/"bochs"/"<WOOT>"/g'qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed 's/"BOCHS "/"<WOOT> "/g' qemu*/include/hw/acpi/aml-build.h if [ $? -ne 0 ]; then echo 'bochs was not replaced in include/hw/acpi/aml-build.h' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed 's/Bochs Pseudo/Intel RealTime/g'qemu*/roms/ipxe/src/drivers/net/pnic.c if [ $? -ne 0 ]; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed 's/Bochs\/Plex86/<WOOT>\/<WOOT>/g' qemu*/roms/vgabios/vbe.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c' fail=1 @@ -267,38 +267,38 @@ function seabios_func { if [ $? -eq 0 ]; then cd seabios sed 's/Bochs/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'Bochs was not replaced in src/config.h' fail=1 fi sed 's/BOCHSCPU/<WOOT>CPU/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHSCPU was not replaced in src/config.h' fail=1 fi sed 's/BOCHS/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 fi sed 's/BXPC/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/config.h' fail=1 fi sed 's/QEMU0001/<WOOT>0001/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed 's/QEMU\/Bochs/<WOOT>\/<WOOT>s/g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig' fail=1 fi sed 's/qemu /<WOOT> /g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'qemu was not replaced in vgasrc/Kconfig' fail=1 @@ -309,14 +309,14 @@ function seabios_func { "src/fw/paravirt.c" ) for file in ${FILES[@]}; do sed 's/"QEMU/"<WOOT>/g' $file; if [ $? -ne 0 ]; then echo 'QEMU was not replaced in $file' fail=1 fi done sed 's/"QEMU"/"<WOOT>"/g' src/hw/blockcmd.c if [ $? -ne 0 ]; then echo '"QEMU" was not replaced in src/hw/blockcmd.c' fail=1 -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,6 +51,8 @@ function install_haxm_mac() { brew cask install xquartz brew install virt-manager virt-viewer pip install libvirt-python echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.zsh } @@ -100,6 +102,7 @@ function install_kvm_linux_apt() { sudo apt-get build-dep virt-manager ./setup.py install echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.zsh #reboot me here sudo kvm-ok } -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 14 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -106,77 +106,77 @@ function install_kvm_linux_apt() { function replace_qemu_clues() { echo '[+] Patching QEMU clues' sed -i "" 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in core.c' fail=1 fi sed -i "" 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in scsi-disk.c' fail=1 fi sed -i "" 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in core.c' fail=1 fi sed -i "" 's/QEMU DVD-ROM/<WOOT> DVD-ROM/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'QEMU DVD-ROM was not replaced in atapi.c' fail=1 fi sed -i "" 's/s->vendor = g_strdup("QEMU");/s->vendor = g_strdup("<WOOT>");/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'Vendor string was not replaced in scsi-disk.c' fail=1 fi sed -i "" 's/QEMU CD-ROM/<WOOT> CD-ROM/g' qemu*/hw/scsi/scsi-disk.c if [ $? -ne 0 ]; then echo 'QEMU CD-ROM was not patched in scsi-disk.c' fail=1 fi sed -i "" 's/padstr8(buf + 8, 8, "QEMU");/padstr8(buf + 8, 8, "<WOOT>");/g' qemu*/hw/ide/atapi.c if [ $? -ne 0 ]; then echo 'padstr was not replaced in atapi.c' fail=1 fi sed -i "" 's/QEMU MICRODRIVE/<WOOT> MICRODRIVE/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU MICRODRIVE was not replaced in core.c' fail=1 fi sed -i "" 's/KVMKVMKVM\\0\\0\\0/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'KVMKVMKVM was not replaced in kvm.c' fail=1 fi # by @http_error_418 sed -i "" 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed -i "" 's/"bochs"/"<WOOT>"/g'qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i "" 's/"BOCHS "/"<WOOT> "/g' qemu*/include/hw/acpi/aml-build.h if [ $? -ne 0 ]; then echo 'bochs was not replaced in include/hw/acpi/aml-build.h' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i "" 's/Bochs Pseudo/Intel RealTime/g'qemu*/roms/ipxe/src/drivers/net/pnic.c if [ $? -ne 0 ]; then echo 'Bochs Pseudo was not replaced in roms/ipxe/src/drivers/net/pnic.c' fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i "" 's/Bochs\/Plex86/<WOOT>\/<WOOT>/g' qemu*/roms/vgabios/vbe.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c' fail=1 -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 9 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -193,9 +193,9 @@ function qemu_func() { # qemu deps # Adding user libvirt-qemu to group libvirt-qemu if [ $OS = "Linux" ]; then sudo apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev elif [ $OS = "Darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools fi @@ -209,9 +209,9 @@ function qemu_func() { # --enable-malloc-trim since we use tcmalloc # add in future --enable-netmap https://sgros-students.blogspot.com/2016/05/installing-and-testing-netmap.html # --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user if [ $OS = "Linux" ]; then ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-gtk --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-kvm --enable-linux-aio --enable-cap-ng --enable-vhost-net --enable-vhost-crypto --enable-spice --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libssh2 --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone elif [ $OS = "Darwin" ]; then # --enable-vhost-net --enable-vhost-crypto ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-hax --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone fi @@ -222,9 +222,9 @@ function qemu_func() { rm /usr/share/qemu/qemu_logo_no_text.svg fi make -j4 if [ $OS = "Linux"]; then checkinstall -D --pkgname=$qemu_version elif [ $OS = "Darwin" ]; then make install fi # hack for libvirt/virt-manager @@ -368,28 +368,14 @@ if [ $EUID -ne 0 ]; then exit 1 fi OS="$(uname -s)" if [ "$1" = 'All' ]; then qemu_func seabios_func if [ $OS = "Linux" ]; then install_kvm_linux_apt elif [ $OS = "Darwin"]; then install_haxm_mac fi fi -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 236 additions and 93 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 19.08.2018 - Intel HAXM support + MacOSX support # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # https://github.com/dylanaraps/pure-bash-bible # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ @@ -14,78 +15,97 @@ # strs[4] = "prl hyperv "; /* Parallels */ # strs[5] = "VBoxVBoxVBox"; /* VirtualBox */ #https://www.qemu.org/download/#source or https://download.qemu.org/ qemu_version=3.0.0 # libvirt - https://libvirt.org/sources/ libvirt_version=4.6.0 # virt-manager - https://github.com/virt-manager/virt-manager/releases virt_manager_version="1.5.0" # autofilled OS="" function usage() { echo 'Usage: $0 <func_name>' echo echo 'Commands:' echo ' All' echo ' QEMU' echo ' SeaBios' echo ' KVM - this will install intel-HAXM if you on Mac' echo ' HAXM - Mac Hardware Accelerated Execution Manager' echo ' replace - only fix antivms in qemu source' exit } function _check_brew() { if [ ! -f /usr/local/bin/brew ]; then /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fi } function install_haxm_mac() { _check_brew brew cask install intel-haxm brew tap jeffreywildman/homebrew-virt-manager brew cask install xquartz brew install virt-manager virt-viewer pip install libvirt-python } function install_kvm_linux_apt() { sed -i "" 's/# deb-src/deb-src/g' /etc/apt/sources.list sudo apt-get update sudo apt-get install build-essential numad python-pip gcc pkg-config cpu-checker glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev gtk-update-icon-cache libgtk2.0-bin # latest for ubuntu 16 sudo apt-get build-dep qemu binfmt-support sudo apt-get install lvm2 python-vm-builder ubuntu-vm-builder bridge-utils sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev wget https://libvirt.org/sources/libvirt-$libvirt_version.tar.xz tar xvf libvirt-$libvirt_version.tar.xz cd libvirt-$libvirt_version sudo apt-get build-dep libvirt ./autogen.sh --system ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-qemu=yes --with-dtrace --with-numad --with-storage-rbd --disable-nls --with-openvz=no --with-vmware=no --with-phyp=no --with-xenapi=no --with-libxl=no --with-vbox=no --with-lxc=no --with-vz=no --with-esx=no --with-hyperv=no make -j4 make install # https://wiki.archlinux.org/index.php/Libvirt#Using_polkit #/etc/libvirt/libvirtd.conf #unix_sock_group = "libvirt" #unix_sock_ro_perms = "0777" # set to 0770 to deny non-group libvirt users #unix_sock_rw_perms = "0770" #auth_unix_ro = "none" #auth_unix_rw = "none" #sed -i "" 's/#unix_sock_group = "libvirt"/unix_sock_group = "libvirtd"/g' /etc/libvirt/libvirtd.conf sed -i "" 's/#unix_sock_ro_perms = "0777"/unix_sock_ro_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i "" 's/#unix_sock_rw_perms = "0770"/unix_sock_rw_perms = "0770"/g' /etc/libvirt/libvirtd.conf sed -i "" 's/#auth_unix_ro = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf sed -i "" 's/#auth_unix_r2 = "none"/auth_unix_ro = "none"/g' /etc/libvirt/libvirtd.conf # https://github.com/libvirt/libvirt/commit/e94979e901517af9fdde358d7b7c92cc055dd50c usermod -G libvirtd -a cuckoo usermod -G libvirtd -a `whoami` systemctl stop libvirtd.service systemctl enable libvirtd.service systemctl start libvirtd.service pip install libvirt-python wget https://github.com/virt-manager/virt-manager/archive/v$virt_manager_version.zip unzip v$virt_manager_version cd virt-manager-$virt_manager_version sudo apt-get build-dep virt-manager ./setup.py install echo "export LIBVIRT_DEFAULT_URI=qemu:///system" > $HOME/.bashrc #reboot me here sudo kvm-ok } function replace_qemu_clues() { echo '[+] Patching QEMU clues' sed -i 's/QEMU HARDDISK/<WOOT> HARDDISK/g' qemu*/hw/ide/core.c if [ $? -ne 0 ]; then echo 'QEMU HARDDISK was not replaced in core.c' @@ -131,13 +151,13 @@ function qemu_func() { echo 'KVMKVMKVM was not replaced in kvm.c' fail=1 fi # by @http_error_418 sed -i 's/Microsoft Hv/GenuineIntel/g' qemu*/target/i386/kvm.c if [ $? -ne 0 ]; then echo 'Microsoft Hv was not replaced in target/i386/kvm.c' fail=1 fi sed -i 's/"bochs"/"<WOOT>"/g'qemu*/block/bochs.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in block/bochs.c' fail=1 @@ -156,29 +176,56 @@ function qemu_func() { fail=1 fi # by Tim Shelton (redsand) @ HAWK (hawk.io) sed -i 's/Bochs\/Plex86/<WOOT>\/<WOOT>/g' qemu*/roms/vgabios/vbe.c if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in roms/vgabios/vbe.c' fail=1 fi } function qemu_func() { echo '[+] Downloading QEMU source code' if [ ! -f qemu-$qemu_version.tar.xz ]; then wget https://download.qemu.org/qemu-$qemu_version.tar.xz fi tar xvJf qemu-$qemu_version.tar.xz fail=0 # qemu deps # Adding user libvirt-qemu to group libvirt-qemu if [ $OS = "linux" ]; then sudo apt-get install checkinstall openbios-* libssh2-1-dev vde2 liblzo2-dev libghc-gtk3-dev libsnappy-dev libbz2-dev libxml2-dev google-perftools libgoogle-perftools-dev libvde-dev elif [ $OS = "darwin" ]; then _check_brew brew install pkg-config libtool jpeg gnutls glib ncurses pixman libpng vde gtk+3 libssh2 libssh2 libvirt snappy libcapn gperftools fi # WOOT # some checks may be depricated, but keeping them for compatibility with old versions if [ $? -eq 0 ]; then replace_qemu_clues if [ $fail -eq 0 ]; then echo '[+] Starting compile it' cd qemu-$qemu_version # --enable-malloc-trim since we use tcmalloc # add in future --enable-netmap https://sgros-students.blogspot.com/2016/05/installing-and-testing-netmap.html # --target-list=i386-softmmu,x86_64-softmmu,i386-linux-user,x86_64-linux-user if [ $OS = "linux" ]; then ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-gtk --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-kvm --enable-linux-aio --enable-cap-ng --enable-vhost-net --enable-vhost-crypto --enable-spice --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libssh2 --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone elif [ $OS = "darwin" ]; then # --enable-vhost-net --enable-vhost-crypto ./configure --prefix=/usr --libexecdir=/usr/lib/qemu --localstatedir=/var --bindir=/usr/bin/ --enable-gnutls --enable-docs --enable-vnc --enable-vnc-sasl --enable-vnc-png --enable-vnc-jpeg --enable-curl --enable-hax --enable-usb-redir --enable-lzo --enable-snappy --enable-bzip2 --enable-coroutine-pool --enable-libxml2 --enable-tcmalloc --enable-replication --enable-tools --enable-capstone fi if [ $? -eq 0 ]; then echo '[+] Starting Install it' #dpkg -i qemu*.deb if [ -f /usr/share/qemu/qemu_logo_no_text.svg]; then rm /usr/share/qemu/qemu_logo_no_text.svg fi make -j4 if [ $OS = "linux"]; then checkinstall -D --pkgname=$qemu_version elif [ $OS = "darwin" ]; then make install fi # hack for libvirt/virt-manager if [ ! -f /usr/bin/qemu-system-x86_64-spice ]; then @@ -203,70 +250,166 @@ function qemu_func() { else echo '[-] Download QEMU source was not possible' fi if [ $OS = "linux" ]; then dpkg --get-selections | grep "qemu" | xargs sudo apt-mark hold #sudo apt-mark unhold qemu fi } function seabios_func { fail=0 echo '[+] Installign SeaBios dependencies' apt-get install git iasl git clone https://github.com/coreboot/seabios.git if [ $? -eq 0 ]; then cd seabios sed -i "" 's/Bochs/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'Bochs was not replaced in src/config.h' fail=1 fi sed -i "" 's/BOCHSCPU/<WOOT>CPU/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHSCPU was not replaced in src/config.h' fail=1 fi sed -i "" 's/BOCHS/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BOCHS was not replaced in src/config.h' fail=1 fi sed -i "" 's/BXPC/<WOOT>/g' src/config.h if [ $? -ne 0 ]; then echo 'BXPC was not replaced in src/config.h' fail=1 fi sed -i "" 's/QEMU0001/<WOOT>0001/g' src/fw/ssdt-misc.dsl if [ $? -ne 0 ]; then echo 'QEMU0001 was not replaced in src/fw/ssdt-misc.dsl' fail=1 fi sed -i "" 's/QEMU\/Bochs/<WOOT>\/<WOOT>s/g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'QEMU\/Bochs was not replaced in vgasrc/Kconfig' fail=1 fi sed -i "" 's/qemu /<WOOT> /g' vgasrc/Kconfig if [ $? -ne 0 ]; then echo 'qemu was not replaced in vgasrc/Kconfig' fail=1 fi FILES=( "src/hw/blockcmd.c" "src/fw/paravirt.c" ) for file in ${FILES[@]}; do sed -i "" 's/"QEMU/"<WOOT>/g' $file; if [ $? -ne 0 ]; then echo 'QEMU was not replaced in $file' fail=1 fi done sed -i "" 's/"QEMU"/"<WOOT>"/g' src/hw/blockcmd.c if [ $? -ne 0 ]; then echo '"QEMU" was not replaced in src/hw/blockcmd.c' fail=1 fi if [ $fail -eq 0 ]; then make -j4 if [ $? -eq 0 ]; then echo '[+] Compiled SeaBios, bios file located in -> out/bios.bin' echo '[+] Replacing old bios.bin to new one, with backup' bios=0 echo '[+] Original bios.bin file backuped and replaced' if [ -f /usr/share/seabios/bios.bin ]; then cp /usr/share/seabios/bios.bin /usr/share/seabios/bios.bin_back cp out/bios.bin /usr/share/seabios/bios.bin bios=1 fi if [ -f /usr/share/qemu/bios.bin ]; then cp /usr/share/qemu/bios.bin /usr/share/qemu/bios.bin_back cp out/bios.bin /usr/share/qemu/bios.bin bios=1 fi if [ $bios -eq 1 ]; then echo '[+] Patched bios.bin placed correctly' else echo '[-] Bios patching failed' fi else echo '[-] Bios compilation failed' fi else echo '[-] check previous errors' fi else echo '[-] Check if git installed or network connection is OK' fi } COMMAND=$1 if [ $# -eq 0 ]; then usage fi if [ COMMAND = '-h' ]; then usage fi #check if start with root if [ $EUID -ne 0 ]; then echo 'This script must be run as root' exit 1 fi case "$(uname -s)" in Darwin) OS='darwin' ;; Linux) # ToDo yum support? OS='linux' ;; CYGWIN*|MINGW32*|MSYS*) OS='windows' ;; *) OS='unkwnown' ;; esac if [ "$1" = 'All' ]; then qemu_func seabios_func if [ $OS = "linux" ]; then install_kvm_linux_apt elif [ $OS = "darwin"]; then install_haxm_mac fi fi if [ COMMAND = 'QEMU' ]; then qemu_func fi if [ COMMAND = 'SeaBios' ]; then seabios_func fi if [ COMMAND = 'KVM' ]; then install_kvm_linux_apt fi if [ COMMAND = 'HAXM' ]; then install_haxm_mac fi if [ COMMAND = "replace" ]; then replace_qemu_clues fi -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,7 @@ # KVM should be installed last # For all QEMU lovers, on Windows/Mac use - https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm # Download HAXM from https://github.com/intel/haxm/releases/ # Instead of `-accel kvm or -enable-kvm` use `-accel hax (or -enable-hax)` function usage() { echo 'Usage: $0 <func_name>' -
doomedraven revised this gist
Aug 19, 2018 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,11 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 19.08.2018 - Intel HAXM notes # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 28.02.2018 - Support for qemu 2.12 # strs[0] = "KVMKVMKVM\0\0\0"; /* KVM */ # strs[1] = "Microsoft Hv"; /* Microsoft Hyper-V or Windows Virtual PC */ @@ -13,6 +16,8 @@ # KVM should be installed last # For all QEMU lovers, on Windows/Mac use - https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm # Download HAXM from https://github.com/intel/haxm/releases/ function usage() { echo 'Usage: $0 <func_name>' -
doomedraven revised this gist
Aug 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/bin/bash # https://www.doomedraven.com/2016/05/kvm.html # 28.02.2018 - Support for qemu 2.12 # 03.08.2018 - More anti-anti by Tim Shelton (redsand) @ HAWK (hawk.io) and @http_error_418 # 14.08.2018 - QEMU 3 support tested on ubuntu 18.04 -
doomedraven revised this gist
Aug 15, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ function install_kvm() { #DEPRICATED sudo apt-get install virt-viewer virt-manager virtinst # Virtual Machine Manager sudo apt-get install debhelper ibusb-1.0-0-dev libxen-dev uuid-dev xfslibs-dev libjpeg-dev libusbredirparser-dev device-tree-compiler texinfo libbluetooth-dev libbrlapi-dev libcap-ng-dev libcurl4-gnutls-dev libfdt-dev gnutls-dev libiscsi-dev libncurses5-dev libnuma-dev libcacard-dev librados-dev librbd-dev libsasl2-dev libseccomp-dev libspice-server-dev # libvirt - https://libvirt.org/sources/ version="4.6.0" wget https://libvirt.org/sources/libvirt-$version.tar.xz tar xvf libvirt-$version.tar.xz cd libvirt-$version @@ -70,7 +70,7 @@ function qemu_func() { #Download code echo '[+] Downloading QEMU source code' # new version can be found here https://www.qemu.org/download/#source or https://download.qemu.org/ version=3.0.0 wget https://download.qemu.org/qemu-$version.tar.xz tar xvJf qemu-$version.tar.xz fail=0
NewerOlder