2018-05-17 17:11:34 +02:00
|
|
|
/**
|
|
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2016
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Operation from "../Operation";
|
|
|
|
import Utils from "../Utils";
|
|
|
|
import {HASH_DELIM_OPTIONS} from "../lib/Delim";
|
|
|
|
import ssdeepjs from "ssdeep.js";
|
|
|
|
import OperationError from "../errors/OperationError";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare SSDEEP hashes operation
|
|
|
|
*/
|
|
|
|
class CompareSSDEEPHashes extends Operation {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CompareSSDEEPHashes constructor
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "Compare SSDEEP hashes";
|
2018-12-26 00:58:00 +01:00
|
|
|
this.module = "Crypto";
|
2018-05-17 17:11:34 +02:00
|
|
|
this.description = "Compares two SSDEEP fuzzy hashes to determine the similarity between them on a scale of 0 to 100.";
|
2018-08-21 20:07:13 +02:00
|
|
|
this.infoURL = "https://forensicswiki.org/wiki/Ssdeep";
|
2018-05-17 17:11:34 +02:00
|
|
|
this.inputType = "string";
|
|
|
|
this.outputType = "Number";
|
|
|
|
this.args = [
|
|
|
|
{
|
|
|
|
"name": "Delimiter",
|
|
|
|
"type": "option",
|
|
|
|
"value": HASH_DELIM_OPTIONS
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} input
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {Number}
|
|
|
|
*/
|
|
|
|
run(input, args) {
|
|
|
|
const samples = input.split(Utils.charRep(args[0]));
|
|
|
|
if (samples.length !== 2) throw new OperationError("Incorrect number of samples.");
|
|
|
|
return ssdeepjs.similarity(samples[0], samples[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default CompareSSDEEPHashes;
|