Giter Site home page Giter Site logo

cd3l3on / functionsimsearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alex-dengx/functionsimsearch

0.0 2.0 0.0 45 KB

Some C++ example code to demonstrate how to perform code similarity searches using MinHashing of small subgraphs

License: Apache License 2.0

Makefile 2.46% C++ 97.54%

functionsimsearch's Introduction

FunctionSimSearch

FunctionSimSearch - Example C++ code to demonstrate how to do MinHash-based similarity search over CFGs extracted from disassemblies.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This code has a few external dependencies. The dependencies are:

Installing

You should be able to build the code by doing the following:

  1. Download, build and install DynInst 9.3
  2. Get the dependencies:
mkdir third_party
cd third_party
git clone https://github.com/okdshin/PicoSHA2.git
git clone https://github.com/trailofbits/pe-parse.git
cd pe-parse
cmake ./CMakeLists
make
cd ..
make

This should build the relevant executables to try.

Running the tests

There are no tests yet. This will change eventually, most likely using gtest.

Running the tools

At the moment, the following executables will be built:

disassemble

./disassemble ELF /bin/tar
./disassemble PE ~/sources/mpengine/engine/mpengine.dll

Disassemble the specified file and dump the disassembly to stdout. The input file can either be a 32-bit/64-bit ELF, or a 32-bit PE file. Adding support for 64-bit PE is easy and will be done soon.

dotgraphs

./dotgraphs ELF /bin/tar /tmp/graphs
./dotgraphs PE ~/sources/mpengine/engine/mpengine.dll /tmp/graphs

Disassemble the specified file and write the CFGs as dot files to the specified directory.

graphhashes

./graphhashes ELF /bin/tar /tmp/graphs
./graphhashes PE ~/sources/mpengine/engine/mpengine.dll /tmp/graphs

Disassemble the specified file and write a hash of the CFG structure of each disassembled function to stdout. These hashes encode only the graph structure and completely ignore any mnemonic; as such they are not very useful on small graphs.

createfunctionindex

./createfunctionindex ./function_search.index

Creates a new search index to store function fingerprints in. The code currently creates 1 GB file (which should be plenty for the casual reverse engineer). Adjust the source code if you need more / less storage.

addfunctionstoindex

./addfunctionstoindex ELF /bin/tar ./function_search.index 5
./addfunctionstoindex PE ~/sources/mpengine/engine/mpengine.dll ./function_search.index 5

Disassemble the specified input file, and add every function with more than 5 basic blocks to the search index file.

matchfunctionsfromindex

./matchfunctionsfromindex ELF /bin/tar ./function_search.index 5 10
./matchfunctionsfromindex PE ~/sources/mpengine/engine/mpengine.dll ./function_search.index 5 10

Disassemble the specified input file, and for each function with more than 5 basic blocks, retrieve the top-10 most similar functions from the search index.

Built With

  • DynInst - Used to generate disassemblies
  • Boost - Boost for persistent map and set containers

Authors

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details

functionsimsearch's People

Watchers

James Cloos avatar  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.