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.3.1) requiresminGWto 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.3.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
# submit mmdt_hash
➜ mmdt-scan-online .\test\2f04b8eb993ca4a3d98607824a10acfb
{
"sha1": "a5ad744088e2739dc8b6a0622432106158d0abd8",
"md5": "2f04b8eb993ca4a3d98607824a10acfb",
"file_name": ".\\test\\2f04b8eb993ca4a3d98607824a10acfb",
"message": "查询任务已添加至查询队列,当前队列中还有0个任务",
"status": 20001,
"data": {}
}
# get check result
➜ mmdt-scan-online .\test\2f04b8eb993ca4a3d98607824a10acfb
{
"sha1": "a5ad744088e2739dc8b6a0622432106158d0abd8",
"md5": "2f04b8eb993ca4a3d98607824a10acfb",
"file_name": ".\\test\\2f04b8eb993ca4a3d98607824a10acfb",
"message": "success",
"status": 20000,
"data": {
"label": "APT28",
"labels": [
{
"label": "APT28",
"ratio": "20.00%"
},
{
"label": "virlock",
"ratio": "50.00%"
},
{
"label": "coinminer",
"ratio": "30.00%"
}
],
"similars": [
{
"hash": "a5ad744088e2739dc8b6a0622432106158d0abd8",
"label": "APT28",
"sim": 1.0
},
{
"hash": "9001f4cfe62367a282efc08b072a13a5e2e403db",
"label": "APT28",
"sim": 0.9896245046624919
},
{
"hash": "0d3d452a7e8d7d328bfe9862cbcee33ad1ce4cf4",
"label": "virlock",
"sim": 0.8511449567066024
},
...
}
}
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
scan online
Metadata
Release files for python-mmdt 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_mmdt-0.3.1.tar.gz | 27.3 kB | Without provenance | Details for python_mmdt-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_mmdt-0.3.1-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details for python_mmdt-0.3.1-cp38-cp38-win_amd64.whl |
Total release size: 67.7 kB
Release files / python_mmdt-0.3.1.tar.gz
| Download URL | python_mmdt-0.3.1.tar.gz |
|---|---|
| Size | 27.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2f18dda7ebcacd5552876e677a0c4fd7f33520ab43674e19fdec5270d2a8325
|
|
BLAKE2b-256 checksum How to use checksums |
3fc742a465a9edb1a2778f89d8852096ec0e80576d7496547d53ce3efd019803
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1
|
Release files / python_mmdt-0.3.1-cp38-cp38-win_amd64.whl
| Download URL | python_mmdt-0.3.1-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 40.4 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e7ad411bc7556860b5229dae1074abec3cb006113408c3c58138f615a408fd6d
|
|
BLAKE2b-256 checksum How to use checksums |
826d9e1d7816465b43ff9c135abcea31255d6a155d9b754b0f63a271e3e766af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1
|
Security for python-mmdt 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.