How Do Brute-Force Attackers Know They Found The Key?
Tags: cryptography, security, tutorial, bruteforce
Published: 2020-02-11 14:20:05

---
title: How Do Brute-Force Attackers Know They Found The Key?
published: true
date: 2020-02-11 14:19:11 UTC
tags: cryptography,security,tutorial,brute force
canonical_url: https://qvault.io/2020/02/11/how-do-brute-force-attackers-know-they-found-the-key/?utm_source=rss&utm_medium=rss&utm_campaign=how-do-brute-force-attackers-know-they-found-the-key
---

By Lane Wagner – [@wagslane](https://twitter.com/wagslane) on Twitter

Brute force attackers guess passwords, passphrases, and private keys in an attempt to eventually get the right answer and crack the security of a system, but how do they know when they have the right key?

![](https://qvault.io/wp-content/uploads/2020/02/armstrong.jpg)

It depends on the system.

Let’s answer the question three times, once for three different common systems.

**Cipher Text With Authentication**

In this case, let’s assume we have direct access to an encrypted hard drive (like that of a MacBook) that has been ciphered using [AES-256-GCM](https://qvault.io/2020/01/02/very-basic-intro-to-aes-256-cipher/). Because we have access to the raw encrypted data, we can’t be locked out for too many failed attempts. ![😈](https://s.w.org/images/core/emoji/12.0.0-1/72x72/1f608.png)

Since we are free to guess as hard and as fast as we can, all we need to know is when to stop deciphering. This is easy if the encryption was done using an authentication tag as required by [GCM mode](https://en.wikipedia.org/wiki/Galois/Counter_Mode). When we get the correct password, the authentication tag will check out.

**Web Application**

Brute forcing your way through the front door of a web application will prove difficult if not impossible. Because the cryptosystem lives on a server you don’t have control over, they can lock you out after a number of failed guesses.

However, if the server doesn’t have these kinds of protections in place, then it is easy to tell when you have the right password because you will likely be given an [HTTP 200 response OK](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes), and perhaps some form of login token.

**Public-Private Key Encryption**

![](https://qvault.io/wp-content/uploads/2020/01/1_Th9nPlIhYveMMsG9RvqQsQ-1024x621.png)<figcaption>Symmetric Cipher vs Asymmetric Public Key Encryption</figcaption>

We have data that was encrypted using a private key, and we can decrypt it using the public key that was given to us. Our goal is to find the private key that corresponds to this public key so that we can then trick other users into thinking we are the original owner of the private key.

_Ignoring the fact that it is practically impossible to brute force a 256-bit key, let’s pretend that we have an infinite amount of resources and are able to eventually get the correct answer._

How do we know when we have the right answer?

Well, it depends a bit on the algorithm that was used to create the key pair. If we know the algorithm and its parameters, then we can just generate public keys from the randomly generated private keys and see if the public key we already have matches.

If this isn’t reasonable because we don’t have all the algorithm information, then we are likely stuck with encrypting a random string of text with our generated private keys, then trying to decrypt with the public key we have.

_Again, this would never work in practicality, the search space is 2^256_

## Brute-Force Attacks Explained

![](https://qvault.io/wp-content/uploads/2020/02/maxresdefault-1024x576.jpg)

[A brute-force attack](https://en.wikipedia.org/wiki/Brute-force_attack) in cryptography is when an attacker guesses many passwords in succession hoping to _eventually_ get one right.

For example, the most naive form of brute force attack would be to try every permutation of characters from length 0 to length n.

> a, b, c …
> 
> aa, ab, ac, … ba, bb, bc
> 
> aaa, aab, aac, … aba, abb, abc… bba, bbb, bbc…

Assuming 26 lowercase letters, 26 uppercase letters, 10 digits, and 10 special characters, it would take 66^10 (~1560000000000000000) guesses just to try all the combinations of exactly length 10. Assuming a modest 200 guesses per second, it would take ~247,336,377 years to crack the password.

## So I’m Safe Right?

Based on the math above, it certainly seems like 10 digit passwords are impervious to brute force attacks. While that may be true of the most naive attacks, there are other things to watch out for.

Instead of the attacker guess every single combination, instead, they may try every word in the English dictionary, with every three-digit combination appended to the end.

- apple001, apple002, apple003…

- baby001, baby002, baby003…

Assuming 50,000 words in the English dictionary, there are only 50,000,000 combinations! Again, assuming 200 guesses per second, it would take ~2.9 **days** to crack the password… that isn’t very long. It is also trivial for the attacker to throw in special characters for corresponding letters. For example, “_@pp1e001_“

## Thanks For Reading

Lane on Twitter: [@wagslane](https://twitter.com/wagslane)

Lane on Dev.to: [wagslane](https://dev.to/wagslane)

Download Qvault: [https://qvault.io](https://qvault.io/)

The post [How Do Brute-Force Attackers Know They Found The Key?](https://qvault.io/2020/02/11/how-do-brute-force-attackers-know-they-found-the-key/) appeared first on [Qvault](https://qvault.io).