Coder Social home page Coder Social logo

sigmoid-bar / pardiff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zmw12306/pardiff

0.0 0.0 0.0 2.21 MB

A Static Differential Analysis Tool of Network Protocol Parsers

License: GNU Affero General Public License v3.0

C++ 97.83% Python 0.81% C 0.30% CMake 1.06%

pardiff's Introduction

ParDiff

ParDiff is the implementation for our paper published in OOPSLA 2024:

ParDiff: Practical Static Differential Analysis of Network Protocol Parsers
Mingwei Zheng, Qingkai Shi, Xuwei Liu, Xiangzhe Xu, Le Yu, Congyu Liu, Guannan Wei, Xiangyu Zhang
ACM SIGPLAN International Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '24) 

It aims to find logical bugs in network protocol implementations using static differential analysis.

Input

To use ParDiff, please prepare bitcode for two implementations under comparison: target1.bc and target2.bc. Here we provide an example under pardiff/tests.

To create your own test cases, please follow the steps below to get bitcode as input:

  • The source code must be implemented in C and can be compiled using clang-12 and wllvm.
  • Annotate the entry parsing function in the source code using the interfaces we provide below:
  void * pardiff_make_object(unsigned size);
  // This interface works as the C lib interface, malloc(), which allocates space in memory with a given size. 
  void * pardiff_make_message();
  // This interface creates a buffer of the networking data.
  unsigned pardiff_make_message_length();
  // This interface indicates the length of the input networking data

Here is an example how we do annotations on the FRR/babeld parser:

#include <stdint.h>
#include <stdio.h>
#include "config.h"
#include <stdlib.h>
#include "message.h"

void *pardiff_make_object(uint64_t size);

void *pardiff_make_message(void);

int pardiff_make_message_length(void);

int pardiff_main_message(){
    unsigned char *from = pardiff_make_object(sizeof(char));
    struct interface *ifp = pardiff_make_object(sizeof(struct interface));
    unsigned char *packet = pardiff_make_message();
    int len = pardiff_make_message_length();
    parse_packet(from, ifp,packet, len); 
    return 0; 
}
  • After finishing the annotation, use Clang-12 and WLLVM to compile the software project and get a bitcode. See WLLVM for more details on how to get a bitcode.

Build

Compiler

  • gcc-11.2.0

Dependency:

  • llvm-12.0.1
  • z3-4.8.12 better use our copy: z3 need to compile and install using cmake
$  mkdir  build
$  cd  build
$  cmake  ..
$  make -j8

Run with our example

./bin/pardiff ../tests/target1.bc ../tests/target2.bc -pardiff-entry=pardiff_main_message > diff.txt 2>&1

pardiff's People

Contributors

zmw12306 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.