惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
量子位
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
IT之家
IT之家
F
Fortinet All Blogs
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Register - Security
The Register - Security
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
A
Arctic Wolf
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
P
Palo Alto Networks Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AWS News Blog
AWS News Blog
有赞技术团队
有赞技术团队
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
aimingoo的专栏
aimingoo的专栏
Know Your Adversary
Know Your Adversary
Cyberwarzone
Cyberwarzone
Martin Fowler
Martin Fowler
The Hacker News
The Hacker News
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
博客园 - 聂微东
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
S
Securelist
T
The Exploit Database - CXSecurity.com
T
Threatpost
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
F
Full Disclosure

Black Hills Information Security, Inc.

Bad Habits: An ANTISOC Operation Same Problem, Different Angles: When Red Team and Blue Team Actually Talk to Each Other How to Identify and Exploit New Vulnerabilities Swapper – A Pure Regex Match/Replace Burp Extension A Practical Guide to BloodHound Data Collection Network Engineering Basics Signed, Trusted, and Abused: Proxy Execution via WebView2 Getting Started In Pentesting – Advice From The BHIS Pentest Lead Cloud Security: Tips and Resources for Securing the Cloud Lessons From A Chatbot Incident How to Lead Effective Tabletops Understanding GRC: How to Navigate Risks and Compliance Standards The “P” in PAM is for Persistence: Linux Persistence Technique Malware Analysis: How to Analyze and Understand Malware OSINT: How to Find, Use, and Control Open-Source Intelligence What to Do with Your First Home Lab When the SOC Goes to Deadwood: A Night to Remember Social Engineering and Microsoft SSPR: The Road to Pwnage is Paved with Good Intentions Common Cyber Threats Finding the Right Penetration Testing Company Deceptive-Auditing: An Active Directory Honeypots Tool The Curious Case of the Comburglar How to Set Smart Goals (That Actually Work For You) Inside the BHIS SOC: A Conversation with Hayden Covington Abusing Delegation with Impacket (Part 3): Resource-Based Constrained Delegation Why You Got Hacked – 2025 Super Edition Abusing Delegation with Impacket (Part 2): Constrained Delegation Abusing Delegation with Impacket (Part 1): Unconstrained Delegation GoSpoof – Turning Attacks into Intel Model Context Protocol (MCP) Bypassing WAFs Using Oversized Requests Getting Started with AI Hacking Part 2: Prompt Injection Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 2) DomCat: A Domain Categorization Tool Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 1) Microsoft Store and WinGet: Security Risks for Corporate Environments Default Web Content MailFail Commonly Abused Administrative Utilities: A Hidden Risk to Enterprise Security Stop Spoofing Yourself! Disabling M365 Direct Send Bypassing CSP with JSONP: Introducing JSONPeek and CSP B Gone Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource DNS Triage Cheatsheet GraphRunner Cheatsheet Burp Suite Cheatsheet Impacket Cheatsheet Wireshark Cheatsheet Hashcat Cheatsheet EyeWitness Cheatsheet Nmap Cheatsheet Netcat (nc) Cheatsheet Hunt for Weak Spots in Your Wireless Network with Airodump-ng from the Aircrack-ng Suite Detecting ADCS Privilege Escalation Vulnerability Scanning with Nmap Getting Started with NetExec: Streamlining Network Discovery and Access How to Use Dirsearch Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 3: Arcanum Cyber Security Bot How to Design and Execute Effective Social Engineering Attacks by Phone Abusing S4U2Self for Active Directory Pivoting Why Use a Macro Pad? Espanso: Text Replacement, the Easy Way Caging Copilot: Lessons Learned in LLM Security Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 2: Copilot Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 1: Burpference Intercepting Traffic for Mobile Applications that Bypass the System Proxy How to Root Android Phones Communicating Security to the C-Suite: A Strategic Approach Offline Memory Forensics With Volatility Getting Started with AI Hacking: Part 1 Go-Spoof: A Tool for Cyber Deception How to Test Adversary-in-the-Middle Without Hacking Tools Canary in the Code: Alert()-ing on XSS Exploits How to Hack Wi-Fi with No Wi-Fi Why Your Org Needs a Penetration Test Program Burp Suite Extension: Copy For Light at the End of the Dark Web Wi-Fi Forge: Practice Wi-Fi Security Without Hardware Avoiding Dirty RAGs: Retrieval-Augmented Generation with Ollama and LangChain Gone Phishing: Installing GoPhish and Creating a Campaign 5 Things We Are Going to Continue to Ignore in 2025 John Strand’s 5 Phase Plan For Starting in Computer Security Questions From a Beginner Threat Hunter GRC for Security Managers: From Checklists to Influence AI Large Language Models and Supervised Fine Tuning Attack Tactics 9: Shadow Creds for PrivEsc w/ Kent & Jordan One Active Directory Account Can Be Your Best Early Warning Introduction to Zeek Log Analysis Indecent Exposure: Your Secrets are Showing Creating Burp Extensions: A Beginner’s Guide Pitting AI Against AI: Using PyRIT to Assess Large Language Models (LLMs) The Top Ten List of Why You Got Hacked This Year (2023/2024) ICS Hard Knocks: Mitigations to Scenarios Found in ICS/OT Backdoors & Breaches Intro to Data Analytics Using SQL Finding Access Control Vulnerabilities with Autorize The Detection Engineering Process Cyber Risk Lessons We Can Learn From Hurricane Preparedness Intro to Desktop Application Testing Methodology What Is Penetration Testing? Adversary in the Middle (AitM): Post-Exploitation Pentesting, Threat Hunting, and SOC: An Overview
QEMU, MSYS2, and Emacs: Open-Source Solutions to Run Virtual Machines on Windows
BHIS · 2024-10-24 · via Black Hills Information Security, Inc.

Penetration Tester. Developer. Pure GNU/Linux Phone Enthusiast.

As a tester, I do all my work inside a Virtual Machine (VM). Recently, I found myself in a situation where I needed to get a VM on a Windows PC. The problem is, I did not want to create an account with Broadcom or work with VirtualBox. I needed to get QEMU (https://www.qemu.org/), the Quick Emulator, up and running. QEMU is open-sourced (always a win in my book!) and allows for running virtual machines from a qcow2 image.   

That started the quest to find a decent QEMU walkthrough to get started and one did not exist, so I decided to write my own. 

QEMU is both an emulator and a virtualizer. As an emulator, QEMU can run VMs that use a different architecture than your host. Android Virtual Device (AVD), for example, uses QEMU to run ARM-based Android systems regardless of your host’s physical architecture. This feature is especially useful in the event you are working with IoT firmware, where translating instructions between the two architectures can be difficult/cumbersome/impossible.   

As a virtualizer, QEMU uses hardware virtualization on the host to create a virtual machine.  

Whatever your requirements, QEMU can do both! 

On to how to get QEMU to work with Windows. I could install QEMU directly on the Windows PC, but that would require manual configuration and managing dependencies. I wanted the easy button. I also wanted to use an open-source project to accomplish this. That is where MSYS2 (https://www.msys2.org/) came in. An open-sourced project, MSYS2 gave me the UNIX shell I wanted to set up QEMU, which is more native to QEMU’s design. MSYS2 automatically handles the dependencies, saving time. Also, it has an Arch Linux vibe and uses Pacman package manager so bonus points! Keep in mind that when you install MSYS2, multiple terminals will be installed. For this write-up, we are using MSYS2 MinGW 64-bit shell. This shell gives us a native Windows environment. 

Installing MSYS2 is as easy as downloading the installer and running the installer. Once you install MSYS2, open a MSYS2 terminal, update the package databases, and install QEMU: 

Update: 

pacman -Syu
Updating Using Pacman 

Install:

pacman -S mingw-w64-x86_64-qemu

Verify the install:

qemu-system-x86_64 --version
Installed Version of QEMU 9.1.0 

Awesome – QEMU is up and running. Next, download your favorite GNU Linux distro (I guess you could use Windows, and there are BSD people out there, but we are sticking with GNU Linux). We are grabbing a 64-bit Kali virtual machine image for this walkthrough, which will give us a virtualized environment. 

Downloading the Kali qcow2 Image 

Once you have your image, create a snapshot if you would like. You will more than likely need to run this from a MYSYS2 console opened as Administrator:

qemu-img create -f qcow2 -F qcow2 -b "C:\path\to\image\kali-linux-2024.2-qemu-amd64.qcow2" "C:\path\to\snapshot\kali-snapshot.qcow2"

Then, running this command will give you a Kali VM. A description of the flags is provided in the comments: 

qemu-system-x86_64 \
        #Uses a modern PC chipset model and enables Windows Hypervisor Platform
        -machine type=q35,accel=whpx \
        #Basic x86_64 CPU model.
        -cpu qemu64 \
        #2 CPU cores to VM
        -smp 2 \
        #4GB of RAM
        -m 4G \
        #Path to qcow2 image. MSYS2 also accepts this format: /c/Path/to/snapshot
        -drive file="C:\Path\to\your\kali-snapshot.qcow2",format=qcow2,if=virtio \
        #virtuio GPU for performance
        -vga virtio \
        #Display is using SDL
        -display sdl \
        #Setting this option improves mouse performance and integration
        -device usb-tablet \
        #Gives VM networking
        -netdev user,id=net0 \
        -device virtio-net-pci,netdev=net0

This is the command I used for improved performance. Your mileage will vary based on your host. 

qemu-system-x86_64 \
    -name "Kali Qemu" \
    -machine type=q35,accel=whpx,kernel-irqchip=off \
    -cpu qemu64,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time \
    -smp cores=2,threads=1 \
    -m 4G \
    -drive file="C:\Path\to\your\kali-snapshot.qcow2",format=qcow2,if=virtio \
    -boot menu=on \
    -vga virtio \
    -display sdl,gl=off \
    -device usb-tablet \
    -usb \
    -device usb-ehci,id=ehci \
    -device nec-usb-xhci,id=xhci \
    -netdev user,id=net0 \
    -device virtio-net-pci,netdev=net0 \
    -audiodev id=audio1,driver=dsound \
    -device ich9-intel-hda \
    -device hda-output,audiodev=audio1 \
    -device virtio-balloon-pci \
    -monitor stdio
Running the VM Using QEMU 

And there we have it, a working VM using QEMU. 

Kali VM Running in QEMU 

But what if there are only VMWare virtual machine files? We can work with that. QEMU offers a disk utility that can convert VDMK files to a qcow2 file. I recently went to training that used SOF-ELK (https://github.com/philhagen/sof-elk) for the VM. A brief description of SOF-ELK provided in the project’s README file is as follows: “SOF-ELK® is a “big data analytics” platform focused on the typical needs of computer forensic investigators/analysts and information security operations personnel.”  

The pre-packaged VM comes configured as a VMWare package, including a VDMK file and the VMWare Configuration File (VMX). A qcow2 image was not available.   

VMWare Files 

We can use QEMU’s disk imaging tool to convert the VDMK file to a qcow2 file. The file conversion alone will not allow you to run the VM in QEMU as it does not address the virtual machine configuration that is defined in the VMX file. 

qemu-img convert -f vmdk -O qcow2 /c/path/to/sof.vmdk /c/path/SOF-ELK.qcow2
Converting VDMK File to qcow2 

The VMX File can be viewed with your text editor of choice. I am using Emacs and I encourage you to use Emacs as well! We want to review the VMX configuration to ensure we match the settings when running with QEMU. 

Partial View of VMX File  

Further down the configuration file, there is a reference to UEFI bios settings. Since MSYS2 uses Arch’s Pacman package manager, we need to address for a known issue (https://bugs.archlinux.org/task/64175) where libvirt fails to locate OVMF images. OVMF is an open-sourced UEFI firmware implementation for virtualized environments, which is required to run SOF-ELK. However, the edk2-ovmf package used by Arch Linux was unavailable using Pacman at the time.  

There are a number of workarounds for this issue — here is mine. At this repo: (https://www.kraxel.org/repos/jenkins/edk2/), we can grab the x64 RPM which contains OVMF files. 

Repo Containing OVMF RPM 

Once downloaded, we need to extract the RPM and access the files packaged in the RPM. Go ahead and extract the RPM file, I am using bsdtar (https://man.archlinux.org/man/bsdtar.1). In the example below, the files save in the MSYS2 path and not the Windows path.  

Extracting RPM File 

With the RPM extracted, we can now access the OVMF files contained in the path: /usr/share/edk2.git/ovmf-x64. The OVMF files are the UEFI firmware image needed to boot the VM using UEFI instead of BIOS. The OVMF files can be identified by the fd extension. While there are multiple fd files, I used the OVMF-pure-efi.fd image which I moved to my working directory. 

OVMF-pure-efi.fd File 

Now that we have a UEFI boot solution, we need to match our instructions to the Virtual Machine to match the VMWare Configuration. The command below mirrors the important VMWare Configuration values. The comments show the instructions added to match the VMX file. 

qemu-system-x86_64 \
  -name "SOF-ELK" \
  -machine q35 \
  #Matching AMD configuration
  -cpu EPYC,hv_vendor_id=AuthenticAMD \
  #Matching 4 CPU Cores
  -smp cores=4,threads=1,sockets=1 \
  #Memory from VMX
  -m 4096 \
  -drive file=SOF-ELK.qcow2,if=none,id=hd0,format=qcow2 \
  #VMX used SATA and could not 1:1 match – Provides a compatible disk interface
  -device ide-hd,drive=hd0,bus=ide.0 \
  -device vmxnet3,netdev=net0 \
  -netdev user,id=net0 \
  #USB Support that was in original VMX file
  -device usb-ehci \
  -device usb-tablet \
  #Sets up Audio that was in VMX file
  -device intel-hda \
  -device hda-duplex \
  #Emulating VMWare graphics
  -vga vmware \
  -display gtk \
  #Sets boot order to start from hard drive – Set in VMX file
  -boot order=c,menu=on \
  #OVMF File using UEFI firmware
  -bios "OVMF-pure-efi.fd" \
  #Uses host local time – How VMWare would handle time
  -rtc base=localtime,clock=host \
  -serial stdio
  #Sets MAC Address defined in VMX File
  -device vmxnet3,netdev=net0,mac=00:0c:29:ae:1b:b0 -netdev user,id=net0

Running the command gives us a SOF-ELK Virtual Machine with QEMU! 

SOF-ELK Running in QEMU 

Remember that QEMU is highly customizable, so research your host limitations and requirements and make the most of this open-source alternative for machine virtualization and emulation.  

When troubleshooting, a couple things to look for are:  

1.) If Hyper-V is enabled, it becomes the root hypervisor. Hyper-V can slow down QEMU, especially if not using Windows Hypervisor Platform (WHPX) accelerator. QEMU’s default accelerator Hardware Accelerated Execution Manager (HAXM) accelerator does not work with Hyper-V enabled. 

2.) When connecting physical USB devices to your VM, you may need your MSYS2 terminal opened as Administrator. 

3.) For performance, tailor your QEMU command to leverage your host’s CPU, GPU, and memory.    

5.) For networking, virtio-net drivers offer better performance. Virtio-net drivers reduce overhead compared to emulated network adapters and are especially useful if using more than one core. 



Ready to learn more?

Level up your skills with affordable classes from Antisyphon!

Pay-What-You-Can Training

Available live/virtual and on-demand