Get a Pentest and security assessment of your IT network.

Cyber Security

Password Recovery: Brute Force & Alternatives

TL;DR

Recovering passwords from a shadow file is complex and often requires significant computing power. While brute-force attacks are possible, they’re slow and detectable. Dictionary attacks, hybrid approaches, and password cracking tools offer better chances of success, but ethical considerations and legal restrictions apply.

Password Recovery Methods

  1. Understanding the Shadow File
    • The shadow file (typically /etc/shadow on Linux systems) stores encrypted password hashes. It’s crucial for security, as it prevents attackers from directly accessing passwords if they gain access to user accounts.
    • Accessing this file usually requires root privileges.
  2. Brute-Force Attacks
    • A brute-force attack tries every possible password combination until the correct one is found. This is extremely time-consuming, especially with strong passwords.
    • Tools like john or hashcat can be used for brute-forcing, but success depends on password length and complexity.
    • Example using John (very basic):
      john --wordlist=/usr/share/wordlists/rockyou.txt /etc/shadow

      (This assumes you have the rockyou wordlist.)

    • Limitations: Slow, resource-intensive, easily detected by intrusion detection systems.
  3. Dictionary Attacks
    • A dictionary attack uses a pre-compiled list of common passwords (a ‘dictionary’) to try and match hashes in the shadow file.
    • More efficient than brute-force, but only effective against weak or commonly used passwords.
    • You can find wordlists online (e.g., rockyou.txt) or create your own based on target information.
  4. Hybrid Attacks
    • Combines dictionary attacks with brute-force techniques. For example, appending numbers or symbols to words from a dictionary.
    • Offers a good balance between speed and effectiveness.
    • Example using John with rule:
      john --rule=best64 /usr/share/wordlists/rockyou.txt /etc/shadow

      (Uses the ‘best64’ rule to modify dictionary words.)

  5. Password Cracking Tools
  6. Using Hashcat (Example)
    • First, identify the hash type: Use a tool like file or online resources to determine the hashing algorithm used in the shadow file.
    • Then run Hashcat with appropriate options:
      hashcat -m [hash_type] /etc/shadow /usr/share/wordlists/rockyou.txt --force

      (Replace [hash_type] with the correct hash type number.)

    • The `–force` option is needed if the shadow file isn’t a standard format.
  7. Important Considerations
    • Ethical Hacking: Only attempt password recovery on systems you have explicit permission to test. Unauthorized access is illegal and unethical.
    • Legal Restrictions: Be aware of local laws regarding password cracking and data security.
    • Password Complexity: Strong passwords (long, random combinations) are much harder to crack.
    • Account Lockout Policies: Systems often have lockout policies that prevent repeated failed login attempts, hindering brute-force attacks.
    • cyber security best practices: Implement strong password policies and multi-factor authentication to protect against unauthorized access.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation