Coder Social home page Coder Social logo

coresight-decoder's Introduction

coresight-decoder

coresight-decoder is an experimental CoreSight decoder dedicated to fuzzing purposes. It currently supports CoreSight trace from ARM64 ETMv4 or later. We tested it with ARM64 Ubuntu 20.04 and 18.04.

NOTE: coresight-decoder is in the early development stage. Not applicable for production use.

Installation

coresight-decoder depends on Capstone version 4.0 or later. This restriction is due to a bug in the ARM64 branch disassembly #1213. Please do not use older versions (e.g. libcapstone-dev from Ubuntu apt packages).

In the below example, install Capstone from the source.

git clone https://github.com/aquynh/capstone.git
cd capstone
git checkout 4.0.2 # checkout the latest version
sudo ./make.sh install

Next, checkout and build coresight-decoder.

git clone https://github.com/RICSecLab/coresight-decoder.git
cd coresight-decoder
make

After the build is finished, the static library libcsdec.a and the simple decoder application processor should be in the root directory. The Makefile also provides make test for testing and make debug for a debug build.

Refer to HOWTO for the library usage example.

Notes on using coresight-decoder

To use libcsdec.a, link it with the -lcapstone flag to the Capstone shared library. The processor application will show usage when no argument is supplied.

Contributing

Please open GitHub Issues and Pull Requests. All commits must include a Signed-off-by line using git commit --signoff to enforce the Developer Certificate of Origin (DCO).

License

coresight-decoder is released under the Apache License, Version 2.0.

Acknowledgements

This project has received funding from the Acquisition, Technology & Logistics Agency (ATLA) under the Innovative Science and Technology Initiative for Security 2020 (JPJ004596).

coresight-decoder's People

Contributors

mmxsrup avatar retrage avatar

Stargazers

Yuzhong Wen avatar Seonghyun Park avatar xiangyang avatar Ryota Sakai avatar mmmly avatar

Watchers

Ren Kimura avatar  avatar  avatar Ryo ICHIKAWA avatar  avatar  avatar

coresight-decoder's Issues

std::exit()の回避

たまにアドレスが0のトレースが含まれることがあり,ライブラリ側で終了されてしまうとトレーサでハンドルできないため,修正をお願いしたいです.
エラーを伝搬できると良さそうなのですが,うまい修正方法が分からずIssueを立てました.

std::exit(1);

逐次的なデコード対応

背景

AFL++ CoreSight modeは現状QEMU modeより少し速い程度でPtrixのように高速とは言えない.ハードウェアによるトレースを利用している利点を生かすためにはさらなる高速化が必要.

gprofでプロファイリングを見るとdeformatTraceData(unsigned char const*, unsigned long, unsigned char)の実行時間が支配的となっている.

機能

Ptrixでは開始時にデコーダスレッドを立ち上げ,実行時にある程度トレースが溜まったらデコーダに通知して逐次的にデコードしてカバレッジのビットマップを更新している.これと同じような動きを実現したい.

  1. トレーサがデコーダスレッドを生成
  2. トレーサはETRのバッファの書き込み状況をpollingで監視してある程度溜まったらデコーダにトレースのバッファへのポインタと大きさを渡してデコードを依頼
  3. デコーダはデコードしてカバレッジビットマップを更新

逐次的なデコードは現在のエッジカバレッジからビットマップを更新する方法では実現できないはず(トレースの途中の状態では完全なエッジカバレッジを構築できない,という認識).そのためPtrixにあるPT-friendlyなフィードバックに変える必要がある(Issue #4).

実装の進め方

前提としてIssue #4の機能が必須なのでそちらの実装を先にお願いしたいです.スレッドなどについてはトレーサ側で管理するのでAPIの大枠は @retrage で作る形で進めたいと思います.

Address with Context packet support

Jetson Nanoでトレースを取得すると以下のように"Address & Context"パケットが生成される.

Idx:68; ID:13;  I_TRACE_ON : Trace On.                                          
Idx:69; ID:13;  I_ADDR_CTXT_L_64IS0 : Address & Context, Long, 64 bit, IS0.; Addr=0x00000055711556B0; Ctxt: AArch64,EL0, NS;
Idx:80; ID:13;  I_ATOM_F2 : Atom format 2.; EE                                        
Idx:81; ID:13;  I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.; Addr=0x0000007F84492640;

Jetson対応を行うにはこの種類のパケットのデコード対応が必要である.

"Address & Context"パケットについてはETMv4 Specification IHI0064H.a 6-298に仕様が記述されている.

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.