How do hackers know which hashing algorythm to use? – Digitalmunition

Home Forums How do hackers know which hashing algorythm to use?

This topic contains 1 reply, has 2 voices, and was last updated by  saucegerb 1 month, 3 weeks ago.

  • Author
  • #333740


    I read that when hackers steal passwords, usually they come in hashes and they have to bruteforce them.
    How do they know which algoryrythm was used to make the hashes so they cant bruteforce them?

  • #333741


    hashid and hash-identifier CLI tools on Kali are helpful in identifying the algorithm used for hashing.

  • #333742

  • #333743


    Hashes are not reversable, that means you can’t decrypt them. Thus the only way to “decrypt” an hash is brute forcing, meaning trying every possible combination to find the hash which takes too long.

    There are popular hashing algorithms like MD5, SHA-1, SHA-256 etc. Each has its own characteristics like hash length and other stuff.

    To securely store passwords you should try salt hashing the passwords.

    p.s. You can also use rainbow tables to “decrypt” an hash, meaning looking up the hash on a pre-computed table of words and their hashes

  • #333744


    1. Some hashes have special formatting, so you can identify them easily. This is good if you store the hashes in format A and to transition to format B. You can detect the “old” ones and as soon as the user logs in, you can hash them with a different algorithm.
    2. Some hashes have special characteristics (like length, characters used, etc.) so you can identify them. Similar to 1) but with less precision and more guessing
    3. Based on 2) you might have to try different algorithms if the hashes all look equally
    4. If you have access to the source you can look how they are generated
    5. If you know the product, it might already be known what algorithm it uses

  • #333745


    Others have posted tools like hashid, etc., and I suggest using those if you are unsure.

    But you can also visually see the difference between hashes, and after a while you start to be able to have a decent guess on what it is.

    An example:

    * Plaintext: admin
    * **md5(admin):** 21232f297a57a5a743894a0e4a801fc3
    * **sha1(admin):** d033e22ae348aeb5660fc2140aec35850c4da997
    * **sha256(admin):** 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
    * **sha512(admin):** c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec

    And this is if the hash string doesn’t give you the algorithm out-right… an example with ‘root’ as the password:

    * user1:**$6$x8wAJRpP$**:17887:0:99999:7:::

    The format of the above:

    **<username>:$<hash algorithm>$<hash salt>$<hash digest/string>:…**

    If you have this string, the algorithm and salt are given to you: $6$ is sha512 (sha512crypt) with some salt — you see them in Debian based systems lots.

    **[EDIT]: NOTE that the above examples are representing the hash as a string. You can get hashes in byte form too.**

    Hope that helps

    **[EDIT2]:** If you are interested, [the hashcat options page]( has a list of hash modes that you can use… CTRL+F and find “$6”

  • #333746


    It depends on the source. Sometimes the hash algorithm is baked right into the format. Take etc/password for instance: [](

  • #333747


    Along with all the other things said here generally when you get hashes you know where they came from. If you know where they came from you can look up the algorithm that site or applications uses. Granted not all the time, but a good amount of it.

  • #333748





  • #333749


    Generally the way the hash is stored tells you what kind of hash it is. This is because the reason for a website to store the hash is so that they can take the user password which has just been input, hash it, and compare the resulting hash with the hash stored on file — this allows them to determine if the correct password was entered without having to store the user’s password in an unprotected manner. But in order to be able to hash the current input, the software needs to know what hashing algorithm was used, so it can hash the current input with the same algorithm. Typically, a stored “hash” will look something like this:


    The “1” between the first pair of dollar-signs means “md5 hash”. The next part that says “saltsalt”, is arbitrary text that is supposed to be added onto the password before hashing. That should be different text for every stored password hash, so that an attacker cannot simply hash a single password and compare the result against the entire database of passwords. Since each entry has a different arbitrary “salt” value added to it before the hashing process, even if two users have the same password, the final hash result will be different for the different entries, because of the different salt values. The last part after the final dollar sign is the actual hash, probably base64 encoded in this example. Sometimes there is also an additional field for how many times to run the hashing algorithm, with each successive run taking the hash of the previous round’s hash result.

    However, even in cases where the hash was just stored as the hash data with no extra information, you can usually make an educated guess based simply on the length of the hash. Md5 hashes are 16 bytes, sha1 are 20 bytes, sha256 are 32 bytes, and sha512 are 64 bytes. And generally when they are stored in a just-the-hash-without-additional-information manner, then the data/password was just hashed one time with the hash function and no salt. That’s not always the case, but it’s the most likely.

    So if I give you this:


    And you put that in software that tells you what kind of hash something is, it will probably tell you it’s a sha1 hash. It’s not. That’s just 20 random bytes I generated. But sha1 is the most probable guess if you tell me you’re sure it’s a hash of some sort.

  • #333750


    I don’t see a direct answer, so I’ll post it: formatting. Formatting often differs between hashing algs (and encrypt/decrypt).

  • #333751


    i always use sha-257 cause it’s better than sha-256

  • #333752


    There are hash analyzers… some hashes are distinguishable from others by character set and length

  • #333753


    Many applications store passwords along with some hints; for example a string/varchar column with a delimited list of base64 or text columns. These often include the salt if present, or it might be in another db attribute. The size of the hash also gives a hint – for example; sha1 is 160 bits so 20 bytes, MD5 is 128 bit, sha256 is well 256 bits.

    They may even include what algorithm, so if they use something like pbkdf or bcrypt the db may store the number of iterations etc.

    In reality, if you have the MD5 hash of a password you can google it and it’ll work often enough. If you are trying to crack a large dataset you’re going to start with credential stuffing.

You must be logged in to reply to this topic.