From aldeid
Jump to navigation Jump to search


Computes a signature based on Context Triggered Piecewise Hashes (CTPH) for each input file, also called a fuzzy hash. If requested, the program matches those signatures against a file of known signatures and reports any possible matches. It can also examine one or more files of signatures and find any matches in those files. Output is written to standard out and errors to standard error. The program only accepts the first 100MB of data presented via standard input.


From sources (tested on Ubuntu 12.04)

$ cd /data/src/
$ wget
$ tar xzvf ssdeep-2.9.tar.gz
$ cd ssdeep-2.9/
$ ./configure
$ make
$ sudo make install



$ sudo aptitude install ssdeep
To ensure you have the latest version available, the installation from sources is recommended

ssdeep for Python

$ sudo aptitude install cython
$ sudo pip install ssdeep

Mac OS X


$ sudo port install ssdeep

ssdeep for Python

$ sudo port install py27-cython
$ sudo pip install ssdeep



Usage: ssdeep [-m file] [-k file] [-dpgvrsblcxa] [-t val] [-h|-V] [FILES]


-m <file>
Match FILES against known hashes in file
-k <file>
Match signatures in FILES against signatures in file
Directory mode, compare all files in a directory
Pretty matching mode. Similar to -d but includes all matches
Cluster matches together
Verbose mode. Displays filename as its being processed
Recursive mode
Silent mode; all errors are supressed
Uses only the bare name of files; all path information omitted
Uses relative paths for filenames
Prints output in CSV format
Compare FILES as signature files
Display all matches, regardless of score
-t <val>
Only displays matches above the given threshold
Display this help message
Display version number and exit


Scan a directory

$ ssdeep -brd -t 60 application-x-dosexec/
1fe919b64287b22cd7f7997166491051 matches 0c5aaeb4447d809a3237057e397d00c7 (61)
263d270b9f7529aacb437e3649d47b76 matches 10092daefa94ee9602b30b746b7770af (74)
2a1655c0d4f65537b49b80fd68cabf5c matches 10092daefa94ee9602b30b746b7770af (63)
2a1655c0d4f65537b49b80fd68cabf5c matches 263d270b9f7529aacb437e3649d47b76 (63)
2c1c0ea0b4a31962bd4d9402e7c62575 matches 1ef31cf21ea1d943a168d4ea403a833c (99)
2d07fb6c96dae9095ddd4689da2cea6c matches 14a09a48ad23fe0ea5a180bee8cb750a (69)
331f93f98cd45f7a3c4aa5b18e1bd75f matches 0c5aaeb4447d809a3237057e397d00c7 (68)
518140c9061ddcfcfe88d6ac3c1b94e7 matches 3a236ad06a27af93675bfbe8862a5381 (61)
518140c9061ddcfcfe88d6ac3c1b94e7 matches 3dd0150bcdd70c151cb58865a4993c28 (61)
5e60a735afb32c3b19b186170964ffb9 matches 1ef31cf21ea1d943a168d4ea403a833c (79)
5e60a735afb32c3b19b186170964ffb9 matches 2c1c0ea0b4a31962bd4d9402e7c62575 (79)
6319efb42f2a5cc8fc4f14402d7ee1c3 matches 5972eff0dc24bc7b5906ef2b95bcfc1a (100)
642a1387e47e54aabbcce4eac243176a matches 5d5138f09a10148f4a85547aa24f7877 (100)
68de34fbac8824e021398b76f94784ef matches 11598cff75be9bfce649a5a59de72447 (68)
690d2fb0c5bd6297127def02452fd4ac matches 5d5138f09a10148f4a85547aa24f7877 (97)
690d2fb0c5bd6297127def02452fd4ac matches 642a1387e47e54aabbcce4eac243176a (97)

Compare 2 files

Comparing files enables to find similar malware and hence group them into variants.

Generate a hash for the targeted file:

$ ssdeep -b application-x-dosexec/7fd4971a9bcee3e3cd844adc56e5eedd > hash.txt

Then compare the hash with the second file:

$ ssdeep -bm hash.txt application-x-dosexec/6bb58c8bc28655345b6842f17029075d
6bb58c8bc28655345b6842f17029075d matches hash.txt:7fd4971a9bcee3e3cd844adc56e5eedd (58)

It gives a score of 58.

The analysis of these 2 files with VirusTotal and Anubis confirm that:

  • Both files are identified as a Sality variant
  • Very few differences exist (e.g. name of created processes) while the malware are running

Python ssdeep

>>> import ssdeep
>>> hash1 = ssdeep.hash('Also called fuzzy hashes, Ctph can match inputs that have homologies.')
>>> hash1
>>> hash2 = ssdeep.hash('Also called fuzzy hashes, CTPH can match inputs that have homologies.')
>>> hash2'
>>>, hash2)