GithubHelp home page GithubHelp logo

pombredanne / joern-old Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fabsx00/joern-old

0.0 1.0 0.0 7.42 MB

Old version of joern used for ACSAC'12 paper. Only kept around for archiving.

License: GNU General Public License v3.0

Python 100.00%

joern-old's Introduction

joern

joern is a tool for robust analysis of C/C++ code. It generates abstract syntax trees, control flow graphs and searchable indexes of code constructs, even for code that does not compile due to missing headers. As such, it has been specifically designed to meet the needs of code auditors, who often find themselves in a situation where constructing a working build environment is not a feasible option or is simply impossible due to missing code.

joern enables you as a code auditor to write quick-and-dirty but language aware static analysis tools. To achieve this, it writes all acquired information to disk as text files or serialized Python objects, thus providing simple and direct access to the data.

Installation:

joern is written in Python2. To install it, execute the following:

$ sudo python2 setup.py install

You will also require a Java Virtual Machine to run CodeSensor.

Usage:

  1. Parsing

To parse a codebase, execute the following:

$ joern_parser $path_to_codebase

This will create a directory named '.$codebase' containing the results generated by the parser, where $codebase is the name of the directory containing the codebase.

For each filename, the generated directory .$codebase contains the following entries:

filename/source: The original source file

filename/ast.csv: The source file's abstract syntax tree in a grep'able version.

filename/ast.pickl: The source file's abstract syntax tree saved as a pickle'd Python object.

filename/funcname/cfg.pickl: The functions control flow graph saved as a pickle'd Python object.

  1. Filtering

The saved ASTs and CFGs contain all information generated by the parser. To concentrate your analysis only on certain types of nodes, you can use joern_filter_asts and joern_filter_cfgs respectively.

First, run the following:

$ joern_filter_asts .$codebase $ joern_filter_cfgs .$codebase

This will filter ASTs and CFGs using a default filter and create the following files:

filename/funcname/prunedCfg.pickl filename/funcname/prunedAst.pickl

You can design your own filter by specifying nodes of interest as command line parameters to joern_filter_asts and joern_filter_cfgs. Run joern_filter_asts --help and joern_filter_cfgs --help for more information. Alternatively, you can design your own filters and row2string converters and place them in sourceutils/pythonASTFilter/pruning and sourceutils/pythonCFGFilter/pruning respectively. Take a look at the existing scripts in these directories for more information.

  1. Indexing

Run the following to create index files:

$ joern_index .$codebase

callIndex.pickl: Python dictionary mapping the names of functions to the list of locations where they are called.

conditionIndex.pickl Python dictionary mapping conditions to the locations where they are imposed.

declarationIndex.pickl Python dictionary mapping the names of types to the locations where they are used to declare a variable.

functionIndex.pickl: Python dictionary mapping the names of functions to function definitions with that name.

Take a look at sourceutils/codeIndex/CodeIndexCreator.py to see how simple it is to create these indexes based on the data in .$codedir. You can add any index you require to be generated in this file.

  1. Visualization

joern provides some very basic functionality to visualize abstract syntax trees and control flow graphs. This is mainly intended for debugging, i.e. to make sure that the filters you define generate the expected output.

For example, to plot a filtered CFG, run the following:

$ ./joern_plot filename/funcname/prunedCfg.pickl

Credits:

Developed by: Fabian 'fabs' Yamaguchi (University of Goettingen)

Greetings: @trapflag, @nion, @mlsec, @teh_gerg, @sergeybratus, @joernchen

joern-old's People

Watchers

 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.