GithubHelp home page GithubHelp logo

davidbuchanan314 / pwn-mbr Goto Github PK

View Code? Open in Web Editor NEW
179.0 13.0 44.0 932 KB

A simple MBR hijack demonstration

License: MIT License

Makefile 3.27% C 54.35% Assembly 42.38%
mbr bootloader hooking

pwn-mbr's Introduction

pwn-mbr

A simple MBR hijack demonstration

Principles of operation:

Phase 1: Injection

  1. A malicious binary is run with root privileges.
  2. The original MBR is copied to the next "free" location (first sector found containing only zeroes) on the disk, before the first partition. A magic number is appended, so that it can be found later.
  3. The boot sector is overwritten with "malicious" code.

Phase 2: Execution

  1. Next time the machine is rebooted, the BIOS starts execution of the payload.
  2. In this example, the text "MBR PWNED!" is written to the screen a few hundred times.
  3. The payload locates the backup of the original boot sector (via the magic number) and copies it over to where it would normally reside in memory (0x7C00). However, this is where the payload is initially running from, so it copies itself elsewhere first.
  4. Finally, the payload jumps back to 0x7C00, resuming normal boot operations.

Notes:

  • Only works on BIOS/legacy boot systems.
  • Although this demo doesn't do anything malicious, it is very possible that it corrupts your filesystem, so only run it on a dedicated VM unless you're very brave.

Demo:

Demo

pwn-mbr's People

Contributors

davidbuchanan314 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

pwn-mbr's Issues

Segfault after "Copying original MBR."

root@ubuntu:/home/asdf/pwn-mbr-master# ./inject /dev/sda
Injecting to /dev/sda
Empty sector found at offset 0x0000ca00. Copying original MBR.
Segmentation fault (core dumped)

What to enter as Device Name

Sorry for this noob question but I dont know what to put at "Usage: '%s DEVICE'\n".

I tried \.\PhysicalDrive0 aswell as other things but could not figure it out.

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.