Giter VIP home page Giter VIP logo

flip-qemu's Introduction

QEMU-flip

Testing utility to cause determinstic and composable bit flips in CPU registers, flags, memory and binaries.

A bitflip is represented by the tuple: < pc, L, M, i >

pc: Program counter @ which flip is to be triggered
L: target register, or memory address
M: mask to xor L with, allows flipping multiple bits
i: Iteration number at which PC hits that value (helps prevent FLIP from triggering flip each time the virtual CPU hits that PC value)

Building

(Verified to work with Ubuntu 18.04 LTS)

mkdir build
cd build
../configure --disable-kvm --enable-debug --target-list="x86_64-linux-user"
make

Example

Altering the value of variable a in asmexample.c

Without bitflips:

$ qemu-x86_64 asmexample
Value of A is 6

With bitflips:

$ qemu-x86_64 -bitflips ex-asm-mem.txt asmexample
Read following 1 bitflip(s):
Bitflip 0:
pc = 40000006c8,
mem_ptr = 4001a0243c,
mask = 2,
itr = 1.
Value of A is 8

Creating your own bitflips

To create your own bitflips, you need to know the instruction pointer that you are targeting, and the memory address. You can find these using GDB. You will need to open two terminals, and remotely attach GDB.

For instance, in order to find possible bitflip targets for asmexample.c, in one terminal run $ qemu-x86_64 -g 12345 asmexample and in the another, $ gdb asmexample, followed by (gdb) target remote localhost:12345, and then proceed normally.

Note that the IP (or program counter) you need points to the instruction that is exactly after the instruction you are targeting, because the QEMU translation of instructions adds bitflips immediately before the next instruction is executed.

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.