Giter Site home page Giter Site logo

purseclab / dnd Goto Github PK

View Code? Open in Web Editor NEW
62.0 8.0 8.0 4.2 MB

A decompiler to automatically reverse-engineer the DNN semantics from its compiled binary using program analysis

License: Apache License 2.0

Jupyter Notebook 1.80% Python 78.47% Shell 0.15% C 19.11% Dockerfile 0.47%
decompiler deep-learning neural-network program-analysis symbolic-execution angr reverse-engineering

dnd's Introduction

DnD: A Cross-Architecture Deep Neural Network Decompiler

DND is a deep neural network (DNN) decompiler capable of reverse engineering DNN models from compiled binaries.

Environment

  1. Create a Python virtual environment
  2. pip install -r ./angr_env/requirements.txt
  3. Move ./angr_env/base.py to overwrite the counterpart in the virtual environment claripy (usually in $USERNAME/.virtualenvs/$VIRTUALENVNAME/lib/python$VERSION/site-packages/claripy/ast/base.py)

Docker container

We provide a docker container. To use it, just run:

docker build . -t dnd
docker run -it dnd

Usage

  • Run python decompiler.py <model_binary> <model_onnx> to decompile a binary sample (<model_binary>) and export it into an ONNX file (<model_onnx>).For instance:
python ./decompiler.py binary_samples/evkbimxrt1050_glow_lenet_mnist_release.axf onnx_models/mnist.onnx
python ./decompiler.py binary_samples/evkbimxrt1050_glow_cifar10.axf onnx_models/resnet.onnx
  • Two samples are provided:
    ./binary_samples/evkbimxrt1050_glow_lenet_mnist_release.axf: a MNIST binary on NXP imrt1050-evk board
    ./binary_samples/evkbimxrt1050_glow_cifar10.axf: a Resnet binary on NXP imrt1050-evk board

  • The folder onnx_models containes ONNX models exported by DND for the binaries in binary_samples.

  • The folder patches showcases how to patch binaries implementing DNNs.

  • Please check decompiler.py for more details.

Citing this work

  title={$\{$DnD$\}$: A $\{$Cross-Architecture$\}$ deep neural network decompiler},
  author={Wu, Ruoyu and Kim, Taegyu and Tian, Dave Jing and Bianchi, Antonio and Xu, Dongyan},
  booktitle={31st USENIX Security Symposium (USENIX Security 22)},
  pages={2135--2152},
  year={2022}
}

dnd's People

Contributors

antoniobianchi333 avatar dennydai avatar wuruoyu 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnd's Issues

A problem

Traceback (most recent call last):
File "decompiler.py", line 175, in
decompile(sys.argv[1], sys.argv[2])
File "decompiler.py", line 138, in decompile
lifted_ast = lift_func_to_ast(proj, f)
File "decompiler.py", line 62, in lift_func_to_ast
lifted_ast = lift(proj, mem_write_dict, solver)
File "/home/Newdisk2/jianghaiqi/DnD/src/lifter.py", line 759, in lift
lifted_ast = lift_mem_write(proj, new_mem_write_dict, solver)
File "/home/Newdisk2/jianghaiqi/DnD/src/lifter.py", line 557, in lift_mem_write
outer_loop = list(mem_write_dict.values())[0].outer_loop

IndexError: list index out of range

How to get self .axf file

I have compiled a alexnet model by TVM, and get 3 outputs (mod.json, mod.prams, and mod.so). How can I get sample .axf file from this 3 outputs?

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.