Giter VIP home page Giter VIP logo

smmloader's Introduction

Overview

SmmLoader is a smm module used to load/unload smm standalone modules during runtime.

Compilation

SmmLoader requires Visual studio 2019 or higher and EDK2. If you do not have it downloaded here is a guide for setting it up. After setting up edk2 you can compile SmmLoader:

  1. Open command line and head up to edk2 directory and prompt edksetup.bat
  2. Clone SmmLoader repo
  3. Prompt build -b RELEASE -a X64 -t VS2019 -p SmmLoader/SmmLoader.dsc

Now SmmLoader should have been succesfully built in edk2/Build/SmmLoader.

Getting Firmware Image

In order to get firmware image, you need to install chipsec and then run this command as administrator: python chipsec_util.py spi dump firmware.bin

Ebmeding SmmLoader

To embed the SmmLoader in the firmware:

  1. Download UefiTool version 0.28.0

  2. Open your firmware image and find Volume Image Section where all SMM modules are located

  3. Find last SMM module

  4. Right click on it and select Insert after...

  5. Select either precompiled ffs or the one you have built, you can find it here edk2/Build/SmmLoader/RELEASE_VS2019/FV/Ffs/1B68BD50-BE1D-43F4-9571-9276A02DE8D0SmmLoader/1B68BD50-BE1D-43F4-9571-9276A02DE8D0.ffs

  6. Save the modified firmware image

Now in order to write firmware back to your flash memory:

  1. Connect your SPI programmer (in my case it's Bus Pirate) to SPI Flash on your mother board

  2. Use flashrom to writeback firmware by running command flashrom -VV -p buspirate_spi:dev=COM3 -w infected_firmware.bin

  3. Disconnect programmer

Usage

You need to install chipsec so you can communicate with SmmLoader by using SmmLoader.py (Administrator priviligaes required)

Supported commands:

  • SmmLoader.py --load <smm_module_path> - loads a module (currently the maximum number of modules is 16)
  • SmmLoader.py --unload <smm_module> - smm_module must be a file name + extension of file which was loaded using --loads command
  • SmmLoader.py --info - Prints info about all loaded modules (works only if SmmLoader was compiled with DebugLibNvVar)
  • SmmLoader.py --debug - Goes into infinite loop and prints debug messages (works only if SmmLoader was compiled with DebugLibNvVar)

Writing new smm module

If you want to create new module, you need to append it in SmmLoader.dsc and add StandaloneMmDriverEntryPoint and MmServicesTableLib library classes.

[Components] 
YourModule/YourModule.inf {
  <LibraryClasses>
   StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
   MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
}

Or you can use SampleSmmModule as a template.

Issues and limitations:

  1. Smm module must be a of MM_STANDALONE module type because DXE_SMM_DRIVER needs an access to Boot services and Runtime services during execution of it's entrypoint, which are not avalible because we are at runtime. You can read more about differences between these two types of modules here.
  2. If you want to see debug output in SmmLoader.py, you need to compile your smm module with DebugLibNvVar as your DebugLib Library class (In SmmLoader.dsc it's seleceted as a default one).
  3. Be careful with calling DebugPrint inside SmiHandler, because in case of DebugLibNvVar, it uses SmmGetVariable/SmmSetVariable which reads and writes to the DebugBuffer, what can generate a smi that puts you in an infinite loop.

Example

Supported hardware & platforms

SmmLoader should work on every hardware and platform supported by chipsec.

Credits

SmmBackdoor by Cr4sh

License

SmmLoader is under GPLv2 license.

smmloader's People

Contributors

air14 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.