Skip to content

phntmzn/Mac_EFI_Bootkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧬 mac_efi_bootkit

An educational EFI bootkit project for macOS that demonstrates the construction, deployment, and testing of UEFI shellcode. The toolkit includes:

  • 🧱 A shellcode builder (builder.py)
  • πŸ—‚ A FAT32 EFI System Partition injector (injector.py)
  • πŸ’Ύ Tools to extract and inspect ESP contents
  • πŸ”¬ Unit tests and safety guidelines

⚠️ WARNING: This is for educational use only on authorized systems. Misuse may cause irreversible damage.


πŸ“ Directory Structure

mac_efi_bootkit/
β”œβ”€β”€ bootkit/
β”‚   β”œβ”€β”€ builder.py          # Wraps raw shellcode in PE/COFF
β”‚   β”œβ”€β”€ injector.py         # Mounts and patches ESP
β”‚   β”œβ”€β”€ fs_utils.py         # FAT32 mount and patch logic
β”‚   β”œβ”€β”€ uefi_structs.py     # UEFI data structures
β”‚   β”œβ”€β”€ efi_payload.asm     # NASM x64 shellcode (UEFI entrypoint)
β”‚   └── efi_payload.bin     # Flat binary output
β”‚
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ nasm_compile.py     # Assembles efi_payload.asm
β”‚   β”œβ”€β”€ esp_extractor.py    # Mounts and copies ESP to folder
β”‚   β”œβ”€β”€ device_info.py      # Lists EFI volumes and partitions
β”‚   └── firmware_injector.py # Firmware DXE injection & SPI flash automation
β”‚
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ build_bootkit.sh    # Automates build + injection
β”‚   └── launch_vm.sh        # Boot EFI in QEMU + OVMF
β”‚
β”œβ”€β”€ tests/                  # Unit tests using unittest + mock
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ architecture.md
β”‚   └── safety_guidelines.md
β”œβ”€β”€ requirements.txt
└── setup.py

βš™οΈ Setup

  1. Install dependencies:
brew install nasm qemu
pip install -r requirements.txt
  1. Assemble payload:
python3 tools/nasm_compile.py
  1. Build EFI binary:
python3 -c "from bootkit import builder; builder.build_efi_image('bootkit/efi_payload.bin', 'bootkit/BOOTX64.EFI')"
  1. Inject to ESP:
sudo python3 -m bootkit.injector

πŸ§ͺ Test in VM

bash scripts/launch_vm.sh

Requires OVMF_CODE.fd and OVMF_VARS.fd in /usr/local/share/OVMF/.


🧼 Extract Existing ESP

python3 tools/esp_extractor.py

βœ… Running Tests

pytest tests/

⚠️ Disclaimer

This toolkit includes low-level firmware interaction tools that can irreversibly alter your hardware. It is for academic use only on test machines or virtual environments.

Do not attempt real-world deployment without full understanding of UEFI internals, SPI flash layout, and platform-specific protections.

The authors are not responsible for damage, data loss, or unintended behavior caused by use or misuse. See docs/safety_guidelines.md.

About

EFI bootkit for macOS. Includes UEFI payload builder, FAT32 ESP injector, VM test support, and DXE implant simulation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors