Giter Site home page Giter Site logo

emusca's Introduction

emusca - Power trace simulator using Unicorn Engine

This project uses Unicorn to emulate a binary. Every instruction is traced and the hamming distance between every register before and after the instruction is calculated and stored. The target binary is run over many input ciphertexts (or plaintexts) to generate simulated power traces (simply the hamming distance for now) and Daredevil input, output, trace, and config file are generated. Marker functions consisting of NOPs are added to the target binary and the instruction hook records when they are hit. This is to facilitate finding the boundaries of the rounds of AES. deco is used for easy multiprocessing to speed up trace generation.

Example Traces

AES S-Box based implementation simulated power trace. The different colored plots are the same trace smoothed at different levels. The nine humps are the inner full rounds of AES. S-Box Trace

AES T-Table based implementation simulated power trace. The plateau on the right hand side are the rounds of AES. They are more difficult to distinguish compared to the S-Box trace since they take approximately 10 times fewer instructions per round. T-Table Trace

The activity on the left hand side in both plots is key expansion.

Other Notes

Before I realized the MBEDTLS_AES_ROM_TABLES option existed for mbedTLS, I was frustrated by the time wasted on generating the AES tables for every trace emulation. Thus I wrote a hacky save/restore system for Unicorn that runs a dummy encryption to make sure the tables are initialized, dumps the mapped memory to a global cache and then uses that global cache when creating the Unicorn instances for each trace simulation. I thought it might be useful later so I left it in. Registers are not saved/restored but could be thanks to the save/restore context API that the angr project got upstreamed to Unicorn.

LIEF is used to map the ELF binary into Unicorn and to find various symbols for marker tracing and crypto input/output setting/getting.

This may be rewritten in C++ in the future to see if that appreciably improves the performance. The Python version will always exist since it is so easy to hack on.

Build/Run notes:

The ARM build assumes an NXP toolchain is present. I need to switch to using devkitARM or something easier to install.

This needs my jevmaster branch of unicorn for the batch register read Python bindings. Remind me to create a PR for Unicorn to upstream this.

TODO

Write up tutorial for building, collecting traces, and running CPA on them.

Lots of code cleanup.

emusca's People

Contributors

jevinskie avatar

Stargazers

 avatar  avatar aramya avatar mizukiyyds avatar 突突兔 avatar 藤真健司 avatar  avatar MonKey Lee avatar SomeDev avatar  avatar Tunnelblick avatar Jian Wang avatar Junwei Wang avatar  avatar lifewouldbebetter avatar  avatar LZ avatar Angelo avatar  avatar Sukanta Dey avatar Vedad Hadžić avatar  avatar  avatar  avatar Alexei Zaviruha avatar  avatar Norm avatar Mohamed Saher avatar Rix Tox avatar  avatar  avatar  avatar 0ri0n ☠ avatar FrenchYeti avatar ik5 avatar TÖRÖK Attila avatar muuk avatar Jack Lloyd avatar Denis Denisov avatar  avatar Ryan Lahfa avatar  avatar Ugo Baroncini avatar  avatar Scott Egerton avatar John Fitzgerald avatar Ali avatar Logyi, hajnalvédő avatar Ben Gardiner avatar Jeff Carpenter avatar DARCEL Frédéric avatar  avatar  avatar  avatar Dimitrios Athanasakis avatar yibit avatar Gorgias avatar  avatar Romain Thomas avatar  avatar Thierry avatar Alex avatar  avatar r0lan avatar alan avatar Hyun Yi avatar Fan Jiang avatar Nguyen Anh Quynh avatar xrw67 avatar Daniel Peters avatar Andrey Voloshin avatar Ashish Kumar Singh avatar Boris Hajduk avatar Theodor Arsenij avatar dukebarman avatar jay avatar Dylan Laws avatar Alexandro Sanchez avatar Vincent R0m3 avatar Aleksei Kulaev avatar Emanuele avatar  avatar Tim Yardley avatar Philip avatar

Watchers

 avatar James Cloos avatar Fernand Lone Sang avatar Ali avatar Romain Thomas avatar  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.