22.5 Hydra: Online Login Testing
Hydra tries username/password combinations against a live service – SSH, FTP, HTTP forms, and more. This is an online attack, so it is slow and noisy. Lab only.
# SSH
hydra -l msfadmin -P /usr/share/wordlists/rockyou.txt ssh://192.168.56.20
# FTP with a user list
hydra -L users.txt -P rockyou.txt ftp://192.168.56.20
# a web login form (path:params:failure-string)
hydra -l admin -P rockyou.txt 192.168.56.20 http-post-form \
"/dvwa/login.php:username=^USER^&password=^PASS^&Login=Login:Login failed"
-l one user, -L a user list; -p one password, -P a list; -t sets parallel tries. For a web form you must give the path, the parameters with ^USER^/^PASS^, and the text that appears on a failed login so Hydra knows what "wrong" looks like.
Online attacks are loud and often illegal
Hydra hammers a login and fills logs; against a real service it will trigger lockouts and alerts, and it is a crime without permission. Keep it on lab hosts.
Ravindra Bagale's Tip
For web forms, students get the failure string wrong, and then Hydra reports every password as "correct". First do one wrong login in the browser and copy the message you see (like "Login failed") exactly. If this one step is wrong, the whole attack is wasted.
Ravindra Bagale's Tip – मराठी
Web form साठी students failure string चुकवतात, मग Hydra सगळे passwords "correct" म्हणतो. आधी browser मध्ये एक चुकीचा login करा आणि जो message दिसतो (जसा "Login failed") तो exactly copy करा. हा एक step बरोबर नसेल तर पूर्ण attack फुकट.
Ravindra Bagale's Tip – हिंदी
Web form के लिए students failure string गलत कर देते हैं, फिर Hydra सारे passwords को "correct" बताता है. पहले browser में एक गलत login करो और जो message दिखे (जैसे "Login failed") उसे exactly copy करो. यह एक step सही नहीं हुआ तो पूरा attack बेकार.
Lab
Run Hydra against SSH on Metasploitable 2 with -l msfadmin and a small wordlist that includes msfadmin. Confirm it finds the password. Then, on your own EC2 server from Chapter 4, note that key-only SSH (password login disabled) makes this attack impossible – that is the fix.
Extended teaching notes
Why this lesson matters
Cryptography fails when people invent it. Use standard libraries, modern algorithms (AES-GCM, TLS 1.2+, bcrypt/argon2) and protect keys in a KMS or secrets manager.
Where crypto shows up
[('Passwords', 'bcrypt/argon2/PBKDF2 via the framework hasher — never plain MD5/SHA1.'), ('TLS', "Terminate on ALB/nginx with ACM/Let's Encrypt; redirect HTTP to HTTPS."), ('JWT / API tokens', 'Short lifetime, rotate signing keys, store secrets outside Git.'), ('Disk / S3', 'Provider or customer-managed keys; least privilege on decrypt.')]
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.