Python wrapper for the mmdt library
Project description
python_mmdt
python_mmdt is a python-based mmdt library implementation. This library allows you to use mmdt through python to calculate sensitive hashes.
mmdt is a sensitive hash implementation that can be used to calculate file similarity
Pre-Install
cmake
: 2.6 and abovewindows
: The current version (0.2.2) requiresminGW
to be installed on windows
Install from Pypi
$ pip install python_mmdt
Install by Whl
.whl
download from Release
$ pip install python_mmdt-xxx.whl
Usage
Command Line
# calculate mmdt sensitive
➜ mmdt-hash $file_path
# calculate file similarity
➜ mmdt-compare $file_path1 $file_path2
# use classifier to detected malicious file
➜ mmdt-classify -h
usage: python_mmdt malicious file scan tool [-h] [-s SCANS] [-t THRESHOLD]
[-c CLASSIFY_TYPE]
A malicious scanner tool based on mmdt_hash. Version 0.2.1
optional arguments:
-h, --help show this help message and exit
-s SCANS, --scans SCANS
set file/path to scan.
-t THRESHOLD, --threshold THRESHOLD
set threshold value to determine whether the file is a
malicious file. (default 0.95)
-c CLASSIFY_TYPE, --classify CLASSIFY_TYPE
set classify type.set 1 for simple classify, set 2 for
knn classify.(default 1)
Use like:
1. use simple classify
mmdt-classify -s $sample_path -t 0.95 -c 1
2. use knn classify
mmdt-classify -s $sample_path -t 0.95 -c 2
python code
# -*- coding: utf-8 -*-
import unittest
import os
from python_mmdt.mmdt.mmdt import MMDT
class Testmmdt(unittest.TestCase):
def test_process(self):
mmdt = MMDT()
test_path = os.path.dirname(__file__)
test_samples = os.path.join(test_path, "samples")
files = os.listdir(test_samples)
for f in files:
file_path = os.path.join(test_samples, f)
r1 = mmdt.mmdt_hash(file_path)
print(r1)
r2 = mmdt.mmdt_hash_streaming(file_path)
print(r2)
sim1 = mmdt.mmdt_compare(file_path, file_path)
print(sim1)
sim2 = mmdt.mmdt_compare_hash(r1, r2)
print(sim2)
Screenshot
calculate file similarity
use classifier to detected malicious file
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_mmdt-0.3.0.tar.gz
(25.0 kB
view hashes)
Built Distributions
Close
Hashes for python_mmdt-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d6c83ea2a7027116cc986b12dec1639aa0ab2b49c1f18a12a5e662f2bd1c57d |
|
MD5 | aef62bf9d7a708c48f8d782168696396 |
|
BLAKE2b-256 | b423a4d94f060d2a2389d1c3c9367cea0173d92f04be698fbad3543703151142 |
Close
Hashes for python_mmdt-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f79ef126a2081fd8737842d5709c7105d8ee52943a177ff29f1a0782ca32b3e |
|
MD5 | bea88c4a640bbae8d13037390967cdf6 |
|
BLAKE2b-256 | 013c2987c3d87ccfd1044b41ef877f4bf3cef5ba2632c8180ae93cd4dd4ed775 |
Close
Hashes for python_mmdt-0.3.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 354ce421a74fae1a1e0eb15d42c00e314ffe51b0e417ff126feea16c60840a1b |
|
MD5 | 1ba7df5ae06a35d9a4ce6df23c5ac51f |
|
BLAKE2b-256 | 69311dded047c64ce87036598f5db08ca5be62a40a264a6d86ee058dab721524 |
Close
Hashes for python_mmdt-0.3.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26942460e1b99903334cc3617de70a1367de7f34f48c8c3c60f5a67bc9720126 |
|
MD5 | 5d827c972bbe129f509592cc61e43998 |
|
BLAKE2b-256 | b7205389bb4d43f47b1c8756baa423b3bb89a6143e6544fd7e027bafa917ae75 |