GithubHelp home page GithubHelp logo

00mjk / emusca Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jevinskie/emusca

0.0 0.0 0.0 437 KB

Power trace simulator using Unicorn Engine for side channel analysis attack testing

License: zlib License

CMake 3.70% C 8.55% Python 81.35% Jupyter Notebook 6.40%

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

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.