vusec / drammer

Native binary for testing Android phones for the Rowhammer bug
484 stars 164 forks source link

Drammer

This software is the open-source component of our paper "Drammer: Deterministic Rowhammer Attacks on Mobile Devices", published in ACM Computer and Communications Security (CCS) 2016. It allows you to test whether an Android device is vulnerable to the Rowhammer bug. It does not allow you to root your device.

This code base contains our native, C/C++-based mobile Rowhammer test implementation.

Disclaimer

If, for some weird reason, you think running this code broke your device, you get to keep both pieces.

Android GUI app

If you don't want to build the test yourself, we also provide an Android app as a GUI for the native component that may or may not be currently available on the Google Play Store depending on the store's policy.

The app supports relaxed and aggressive hammering, which corresponds to the number of seconds to run 'defrag' (-d command line option described below): you can choose a timeout between 0 (no defrag) and 60 seconds, although higher timeouts likely cause the app to become unresponsive.

The app optionally collects basic statistics on the type of device and test results so that we can gain insights into the number and type of vulnerable devices in the wild, so please consider sharing them for science.

Native installation

To build the native binary, you need an Android NDK toolchain. I used android-ndk-r11c:

wget https://dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
unzip android-ndk-r11c-linux-x86_64.zip
cd android-ndk-r11c
./build/tools/make-standalone-toolchain.sh --ndk-dir=`pwd` \
  --arch=arm --platform=android-24 \
  --install-dir=./sysroot-arm/ \
  --verbose

You can then build the program setting STANDALONE_TOOLCHAIN variable to point to the toolchain:

STANDALONE_TOOLCHAIN=path/to/android-ndk-r11c/sysroot-arm/bin make

This gives you a stripped ARMv7 binary that you can run on both ARMv7 (32-bit) and ARMv8 (64-bit) devices. The Makefile provides an install feature that uses the Android Debug Bridge (adb) to push the binary to your device's /data/local/tmp/ directory. You can install adb by doing a sudo apt-get install android-tools-adb (on Ubuntu) or by installing the Android SDK via android.com. Then do a:

make install
make test

to install and start the Rowhammer test binary. Once installed, you may also invoke it from the shell directly:

adb shell
cd /data/local/tmp
./rh-test

Command line options

The native binary provides a number of command line options:

Description of source files

The native code base is written in C and abuses some C++ functionality. There are some comments in the source files that, combined with run-time output dumped on stdout, should give you an indication of what is happening. The main output of a run consists of numbers that indicate the average DRAM access time (in nanoseconds).

What follows is a short description of all source files.