• Stars
    star
    541
  • Rank 82,114 (Top 2 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

First open source and publicly available System Management Mode backdoor for UEFI based platforms. Good as general purpose playground for various SMM experiments.
  SMM backdoor for UEFI based platforms

*****************************************************************

For more information about this project please read the following article:

http://blog.cr4.sh/2015/07/building-reliable-smm-backdoor-for-uefi.html


Repository contents:

  * SmmBackdoor.py -- Python program that allows to infect PE image of UEFI DXE driver with backdoor code, communicate with installed backdoor to read SMRAM and do some other useful things.

  * SmmBackdoor/ -- source code of UEFI part that runs in System Management Mode.

  * SmmBackdoor.efi, SmmBackdoor.pdb -- UEFI part binary and it's debug symbols.

  * smm_call/ -- proof of concept Linux program that interacts with installed backdoor to get root privileges for it's process.
 

To build SmmBackdoor project you need to have a Windows machine with Visual Studio 2008 and EDK2 source code (https://github.com/tianocore/edk2).

Step by step instruction:

  1. Copy SmmBackdoor subdirectory to EDK2 source code directory.

  2. Edit Conf/target.txt file and set ACTIVE_PLATFORM property value to OvmfPkg/OvmfPkgX64.dsc.

  3. Edit OvmfPkg/OvmfPkgX64.dsc and add the following lines at the end of the file:

    #
    # 3-rd party drivers
    #
    SmmBackdoor/SmmBackdoor.inf {
      <LibraryClasses>
        DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
        MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
    }

  4. Run Visual Studio 2008 Command Prompt and cd to EDK2 directory.

  5. Execute Edk2Setup.bat --pull to configure build environment and download required binaries.

  6. cd SmmBackdoor && build

  7. After compilation resulting PE image file will be created at Build/OvmfX64/DEBUG_VS2008x86/X64/SmmBackdoor/SmmBackdoor/OUTPUT/SmmBackdoor.efi


To run SmmBackdoor.efi as infector payload on example of Intel DQ77KB motherboard:

  1. Dump motherboard firmware using hardware SPI programmer.

  2. Open dumped flash image in UEFITool.

  3. Extract PE image of FFS file with GUID = 26A2481E-4424-46A2-9943-CC4039EAD8F8 and save it to extracted.bin file.

  4. Infect extrated image with SmmBackdoor.efi using SmmBackdoor.py:

    $ python SmmBackdoor.py --infect extracted.bin --output infected.bin --payload SmmBackdoor.efi

  5. In UEFITool replace original PE image with infected.bin.

  6. Save modified flash image to file and write it to the motherboard ROM with programmer.

Backdoor also has debug output capabilities that allows to see DXE phase debug messages on the screen and receive runtime phase debug messages over COM port.


To use SmmBackdoor.py you need to install a pefile Python library (https://pypi.python.org/pypi/pefile) and CHIPSEC framework (https://github.com/chipsec/chipsec) including Python bindings. 

Supported commands:

  * SmmBackdoor.py --infect <source_path> --output <dest_path> --payload <payload_path> - Infect PE image of DXE driver with specified backdoor code.

  * SmmBackdoor.py --test - Check for backdoor presence and print status information from BACKDOOR_INFO structure.

  * SmmBackdoor.py --dump-smram - Dump all available SMRAM regions into the files.

  * SmmBackdoor.py --read-phys <address> - Print hexadecimal dump of physical memory page at given address.

  * SmmBackdoor.py --read-virt <address> - Print hexadecimal dump of virtual memory page at given address.

  * SmmBackdoor.py --timer-enable - Enable periodic timer SMI that required for smm_call (by default it's enabled).

  * SmmBackdoor.py --timer-disable - Disable periodic timer SMI.


smm_call usage:

  * smm_call <code> [<arg_1> [<arg_2>]] - Send specified control code and arguments to SMM backdoor.

  * smm_call --privesc - Ask the backdoor to give a root privileges for caller process and run command shell.


Please note, that this code was tested only with Intel DQ77KB motherboard. You may try to run it on any other UEFI compatible hardware, but some of the backdoor features might not work.


Written by:
Dmytro Oleksiuk (aka Cr4sh)

[email protected]
http://blog.cr4.sh

More Repositories

1

ThinkPwn

Started as arbitrary System Management Mode code execution exploit for Lenovo ThinkPad model line, ended as exploit for industry-wide 0day vulnerability in machines of many vendors
C
641
star
2

s6_pcie_microblaze

PCI Express DIY hacking toolkit for Xilinx SP605. This repository is also home of Hyper-V Backdoor and Boot Backdoor, check readme for links and info
C
599
star
3

MicroBackdoor

Small and convenient C2 tool for Windows targets. [ Русский -- значит нахуй! ]
C++
497
star
4

openreil

Open source library that implements translator and tools for REIL (Reverse Engineering Intermediate Language)
C
482
star
5

WindowsRegistryRootkit

Kernel rootkit, that lives inside the Windows registry values data
C
464
star
6

KernelForge

A library to develop kernel level Windows payloads for post HVCI era
C++
310
star
7

fwexpl

PC firmware exploitation tool and library
C++
231
star
8

PeiBackdoor

PEI stage backdoor for UEFI compatible firmware
C
185
star
9

ioctlfuzzer

Automatically exported from code.google.com/p/ioctlfuzzer
C
148
star
10

UEFI_boot_script_expl

CHIPSEC module that exploits UEFI boot script table vulnerability
Python
128
star
11

DrvHide-PoC

Hidden kernel mode code execution for bypassing modern anti-rootkits.
C++
75
star
12

IDA-VMware-GDB

Helper script for Windows kernel debugging with IDA Pro on VMware + GDB stub
Python
72
star
13

PTBypass-PoC

Bypassing code hooks detection in modern anti-rootkits via building faked PTE entries.
C++
68
star
14

smram_parse

System Management RAM analysis tool
Python
59
star
15

Code-coverage-analysis-tools

Code coverage analysis tools for the PIN Toolkit
C++
57
star
16

Aptiocalypsis

Arbitrary SMM code execution exploit for industry-wide 0day vulnerability in AMI Aptio based firmwares
Python
55
star
17

MsFontsFuzz

OpenType font file format fuzzer for Windows
C++
51
star
18

secretnet_expl

LPE exploits for Secret Net and Secret Net Studio
C++
48
star
19

qc_debug_monitor

Debug messages monitor for Qualcomm cellular modems
Python
44
star
20

zc_pcie_dma

DMA attacks over PCI Express based on Xilinx Zynq-7000 series SoC
Tcl
43
star
21

DbgCb

Engine for communication with remote kernel debugger (KD, WinDbg) from drivers and applications
C++
36
star
22

SimpleUnpacker

Simple tool for unpacking packed/protected malware executables.
C++
30
star
23

prl_guest_to_host

Guest to host VM escape exploit for Parallels Desktop
C++
28
star
24

IDA-UbiGraph

IDA Pro plug-in and tools for displaying 3D graphs of procedures using UbiGraph
C++
24
star
25

blog

Stuff for blog.cr4.sh website
4
star