Skip to content
Buy me a coffee

Hashes

tag: file-typestag: beginners

A hash function reads every byte of a file and produces a short string of hex characters. Two files that differ by one letter look nothing alike:

Input SHA256
hello 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
Hello 66a045b452102c59d840ec097d59d9467e13a3f34f6494e539ffd32c1bb35f18

(Both are the word followed by a line break, as printf 'hello\n' produces it.)

Hash Length Notes
MD5 32 hex characters Old and broken: two different files can be made to share an MD5. Still listed because older tools use it.
SHA1 40 hex characters Also broken for the same reason. Still common in reports.
SHA256 64 hex characters The one to use as a sample’s name.
System Command
macOS shasum -a 256 FILE
Linux sha256sum FILE
Windows (PowerShell) Get-FileHash FILE (SHA256 by default; add -Algorithm MD5 for MD5)
  • Naming samples. A SHA256 is a name no one else’s file will have.
  • Looking things up. Search a hash on VirusTotal or MalwareBazaar to see what’s already known, without uploading anything.
  • Sharing indicators. Hashes go in the IOC table of a report.
  • Checking downloads. Compare a tool’s published hash with the one you calculate to make sure the download wasn’t changed.
  • A hash matches only that exact file. Change one byte and it’s a new hash, so attackers can make every copy unique with no effort.
  • Similarity hashes find files that are close rather than identical: ssdeep and TLSH compare content, and imphash compares the list of functions a PE file imports.

One Reverse Look

"A little learning is a dangerous thing." ~ A. Pope

One Reverse Look · Made with ❤ · Your friendly knowledge seeker