Skip to main content

MinHash-based Code Relationship & Investigation Toolkit (MCRIT)

Test Ask DeepWiki

MCRIT is a framework created to simplify the application of the MinHash algorithm in the context of code similarity. It can be used to rapidly implement "shinglers", i.e. methods which encode properties of disassembled functions, to then be used for similarity estimation via the MinHash algorithm. It is tailored to work with disassembly reports emitted by SMDA.

Usage

Dockerized Usage

We highly recommend to use the fully packaged docker-mcrit for trivial deployment and usage. First and foremost, this will ensure that you have fully compatible versions across all components, including a database for persistence and a web frontend for convenient interaction.

Standalone Usage

Installing MCRIT on its own will require some more steps. For the following, we assume Ubuntu as host operating system.

MCRIT requires Python 3.11 or newer. Its dependencies are declared in pyproject.toml and are installed together with the package:

# install python and MCRIT along with its dependencies
$ sudo apt install python3 python3-pip
$ pip install -e .

By default, MongoDB 5.0 is used as backend, which is also the recommended mode of operation as it provides a persistent data storage. The following commands outline an example installation on Ubuntu:

# fetch mongodb signing key
$ sudo apt-get install gnupg
$ wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
# add package repository (Ubuntu 22.04)
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
# OR add package repository (Ubuntu 20.04)
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
# OR add package repository (Ubuntu 18.04)
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
# install mongodb
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
# start mongodb as a service
$ sudo systemctl start mongod
# optionally configure to start the service with system startup
$ sudo systemctl enable mongod

When doing the standalone installation, you possibly want to install the MCRIT module based on the cloned repository, like so:

$ pip install -e .

After this initial installation and if desired, MCRIT can be used without an internet connection.

Operation

The MCRIT backend is generally divided into two components, a server providing an API interface to work with and one or more workers processing queued jobs. They can be started in seperate shells using:

$ mcrit server

and

$ mcrit worker

By default, the REST API server will be listening on http://127.0.0.1:8000/.

Interaction

Regardless of your choice for installation, once running you can interact with the MCRIT backend.

MCRIT Client

We have created a Python client module that is capable of working with all available endpoints of the server. Documentation for this client module is currently in development.

MCRIT CLI

There is also a CLI which is based on this client package, examples:

# query some stats of the data stored in the backend
$ mcrit client status
{'status': {'db_state': 187, 'storage_type': 'mongodb', 'num_bands': 20, 'num_samples': 137, 'num_families': 14, 'num_functions': 129110, 'num_pichashes': 25385}}
# submit a malware sample with filename sample_unpacked, using family name "some_family"
$ mcrit client submit sample_unpacked -f some_family
 1.039s -> (architecture: intel.32bit, base_addr: 0x10000000): 634 functions

A more extensive documentation of the MCRIT CLI is available here

MCRIT IDA Plugin

An IDA plugin is also currently under development. To use it, first create your own config.py and make required changes depending on the deployment of your MCRIT instance:

cp ./plugins/ida/template.config.py ./plugins/ida/config.py
nano ./plugins/ida/config.py

Then simply run the script found at

./plugins/ida/ida_mcrit.py

in IDA.

Reference Data

In July 2023, we started populating a Github repository which contains ready-to-use reference data for common compilers and libraries.

Version History

See CHANGELOG.md for the full release history.

Credits & Notes

Thanks to Steffen Enders and Paul Hordiienko for their contributions to the internal research prototype of this project! Thanks to Manuel Blatt for his extensive contributions to and refactorings of this project as well as for the client module!

Pull requests welcome! :)

License

    MinHash-based Code Relationship & Investigation Toolkit (MCRIT)
    Copyright (C) 2022  Daniel Plohmann, Manuel Blatt

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Some plug-ins and libraries may have different licenses.
    If so, a license file is provided in the plug-in's folder.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcrit-1.8.1.tar.gz (446.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcrit-1.8.1-py3-none-any.whl (433.4 kB view details)

Uploaded Python 3

File details

Details for the file mcrit-1.8.1.tar.gz.

File metadata

  • Download URL: mcrit-1.8.1.tar.gz
  • Upload date:
  • Size: 446.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for mcrit-1.8.1.tar.gz
Algorithm Hash digest
SHA256 c31f5673dd38c478ef88623211b69bf6b92b9909a1f518deb40ce8c3a64e32c4
MD5 c514219fd196816c76e419da06fdb432
BLAKE2b-256 5654f6b9c22d5a706bdf91e9a9e2d64464ae4f196036f5cb2cc9c476e40c6059

See more details on using hashes here.

File details

Details for the file mcrit-1.8.1-py3-none-any.whl.

File metadata

  • Download URL: mcrit-1.8.1-py3-none-any.whl
  • Upload date:
  • Size: 433.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for mcrit-1.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 092ce79529a890c42de86a732060e1213a8437caecc8e86843c17fc084b71d9a
MD5 48e982f6f4511bdf9cfe48bad8a50c33
BLAKE2b-256 9a294b34998ce11692a0a3ec63bf91706cf6836107f689c2970307b0d8e8ed2d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.8.1 This release

2 files

1.8.0

2 files

1.7.1

1 file

1.7.0

1 file

1.6.2

1 file

1.6.1

1 file

1.6.0

2 files

1.5.3

1 file

1.5.2

1 file

1.5.1

1 file

1.5.0

1 file

1.4.3

1 file

1.4.2

1 file

1.4.1

1 file

1.4.0

1 file

1.3.22

1 file

1.3.21

1 file

1.3.20

1 file

1.3.18

1 file

1.3.17

1 file

1.3.16

1 file

1.3.15

1 file

1.3.14

1 file

1.3.13

1 file

1.3.12

1 file

1.3.11

1 file

1.3.10

1 file

1.3.9

1 file

1.3.8

1 file

1.3.7

1 file

1.3.6

1 file

1.3.5

1 file

1.3.4

1 file

1.3.2

1 file

1.3.1

1 file

1.3.0

1 file

1.2.26

1 file

1.2.25

1 file

1.2.24

1 file

1.2.22

1 file

1.2.21

1 file

1.2.20

1 file

1.2.19

1 file

1.2.18

1 file

1.2.15

1 file

1.2.14

1 file

1.2.11

1 file

1.2.10

1 file

1.2.9

1 file

1.2.8

1 file

1.2.7

1 file

1.2.6

1 file

1.2.5

1 file

1.2.4

1 file

1.2.3

1 file

1.2.2

1 file

1.2.1

1 file

1.2.0

1 file

1.1.7

1 file

1.1.6

1 file

1.1.5

1 file

1.1.4

1 file

1.1.3

1 file

1.1.2

1 file

1.0.21

1 file

1.0.20

1 file

1.0.19

1 file

1.0.18

1 file

1.0.17

1 file

1.0.16

1 file

1.0.15

1 file

1.0.14

1 file

1.0.13

1 file

1.0.12

1 file

1.0.11

1 file

1.0.10

1 file

1.0.9

1 file

1.0.8

1 file

1.0.7

1 file

1.0.6

1 file

1.0.5

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

0.24.2

1 file

0.24.1

1 file

0.24.0

1 file

0.23.0

1 file

0.22.0

1 file

0.21.0

1 file

0.20.6

1 file

0.20.4

1 file

0.20.3

1 file

0.20.2

1 file

0.20.1

1 file

0.19.4

1 file

0.19.3

1 file

0.19.2

1 file

0.19.1

1 file

0.19.0

1 file

0.18.10

1 file

0.18.9

1 file

0.18.8

1 file

0.18.7

1 file

0.18.6

1 file

0.18.5

1 file

0.18.4

1 file

0.18.2

1 file

0.18.1

1 file

0.18.0

1 file

0.17.4

1 file

0.17.2

1 file

0.17.1

1 file

0.17.0

1 file

0.16.0

1 file

0.15.4

1 file

0.15.3

1 file

0.15.2

1 file

0.15.1

1 file

0.15.0

1 file

0.14.2

1 file

0.14.1

1 file

0.14.0

1 file

0.12.2

1 file

0.12.1

1 file

0.10.0

1 file

0.9.5

1 file

0.9.1

1 file

0.9.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page