Blog | G5 Cyber Security

Hydra: Non-ASCII Brute Force

TL;DR

Hydra can struggle with non-ASCII characters in usernames and passwords. This guide shows how to configure Hydra to handle UTF-8 encoding correctly, allowing you to brute force logins even when they contain special characters.

Solution Guide

  1. Understand the Problem: Hydra often defaults to using ASCII encoding. When it encounters non-ASCII characters (like é, ü, or Chinese characters), it can misinterpret them, leading to failed login attempts or incorrect password testing.
  2. Check Your Target System’s Encoding: Before you start, determine the character encoding used by the target system for usernames and passwords. Common encodings include UTF-8, ISO-8859-1, and others. You may need to consult documentation or test with known credentials containing special characters.
  3. Configure Hydra for UTF-8: The key is to tell Hydra to use UTF-8 encoding. This is done using the -e option.
    hydra -l username -P /path/to/passwordlist -t 4 -e utf-8 target_service

    Replace username with your target username, /path/to/passwordlist with the path to your password list file, 4 with the number of threads and target_service with the service you are attacking (e.g., ssh://192.168.1.1).

  4. Ensure Your Password List is UTF-8 Encoded: Make sure your password list file itself is saved in UTF-8 encoding.
    • Linux/macOS: Use a text editor like nano, vim or gedit and save the file with UTF-8 encoding. You can also use the file command to verify:
      file -i /path/to/passwordlist

      The output should include “charset=utf-8”. If not, convert it using iconv:

      iconv -f ISO-8859-1 -t UTF-8 /path/to/passwordlist > /path/to/passwordlist_utf8.txt
    • Windows: Use a text editor like Notepad++ and save the file with UTF-8 encoding (usually found in the Encoding menu).
  5. Test with a Known Credential: Create a small password list containing just one known valid credential that *includes* non-ASCII characters. This verifies your configuration.
  6. Run Hydra: Execute the Hydra command with the -e utf-8 option and your UTF-8 encoded password list. Monitor the output for successful logins.
    hydra -l username -P /path/to/passwordlist_utf8.txt -t 4 -e utf-8 target_service
  7. Troubleshooting: If you still encounter issues:
    • Double-check the target system’s encoding.
    • Verify that your password list is *actually* UTF-8 encoded using the file -i command (Linux/macOS).
    • Ensure there are no unexpected characters or formatting issues in your password list.
Exit mobile version