GithubHelp home page GithubHelp logo

meton-robean / cfg_dfg_generator Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 9.0 625 KB

generating DFG and CFG from source code (using LLVM ) or from binary (using LLVM and Mcsema) 二进制或者源码转CGF& DFG

C++ 76.31% CMake 16.36% Shell 4.80% C 2.53%
static-program-analysis cfg-dfg-generator mcsema llvm

cfg_dfg_generator's Introduction

DFG_CFG_generator

generating DFG and CFG from source code (using LLVM ) or from binary (using LLVM and Mcsema)

Install:

1. compile LLVM DFG pass and CFG pass

following their README in dir LLVM_PASS, the you can get libCFGPass.so and libDFGPass.so
(NOTE: in this test, we use LLVM 6.0 and Clang 6.0)

2. install Mcsema

install Mcsema following https://github.com/trailofbits/mcsema
after installing, you can use mcsema-disass and mcsema-lift in your Ubuntu
(NOTE: as Mcsema needs dependency of IDA, so you need to download IDA software as well. in this test we use IDA PRO 6.4 version)

Usage:

1.from source code to generate DFG&CFG:

CFG: run shell: ./gen_cfg.sh
clang-6.0 -emit-llvm test.c -c -o test.bc
opt-6.0 -load ./libCFGPass.so -CFG test.bc

DFG: run shell: ./gen_dfg.sh
clang-6.0 -emit-llvm test.c -c -o test.bc
opt-6.0 -load ./libDFGPass.so -DFGPass test.bc

2.from binary to generate DFG&CFG:

run mcsema_binary2llvmbitcode.sh to transfer binary to LLVM IR(bitcode format):
sudo mcsema-disass --arch amd64 --os linux --disassembler /home/cmt/Applications/ida-pro/ida-pro/idal64 --binary ./test --entrypoint main --output auth.cfg --log_file ./log

mcsema-lift-4.0 --arch amd64 --os linux --cfg ./auth.cfg --output ./test.bc --explicit_args
after get the bitcode we need, you can use gen_cfg.sh and gen_dfg.sh as above to get DFG&CFG

Test:

test.c:

void ff3(){
  printf("f3\n");
  int a=1;
  if(a==1){
    f1();
  }else{
    f2();
  }
 f1();
 f2();
}

Result:

CFG:
CFG
DFG:
DFG

cfg_dfg_generator's People

Contributors

meton-robean 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

Watchers

 avatar  avatar

cfg_dfg_generator's Issues

Collaboration

Hello,
I am an author of gem5-SALAM, which I see you checked out a while ago, and does now have a much more detailed readme. I was browsing your repositories and ran across the CFG_DFG_generator and think it would be a great tool to integrate into gem5-SALAM. We are currently implementing a LLVM wrapper which will allow internal llvm passes, and as a diagnostic tool having the option to generate a graphical CFG/DFG would be useful.

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.