17. Why Learn All This Before Kali Linux?
17.3 From Linux and SSH to Brute Force, Privilege Escalation and Hardening
Kali swatah Linux aahe – aani bahutek targets pan Linux servers aahet. Part 2 che commands attack aani defence donhi madhe roj lagtat.
| You learnt (Part 2) | Attack side | Defence side |
|---|---|---|
SSH, key pairs, chmod 400 |
Hydra password brute force against SSH | Key-only login, PasswordAuthentication no, fail2ban |
Users, groups, sudo |
Privilege escalation (विशेषाधिकार वाढ) via weak sudo rules |
Least privilege, review sudo -l |
Permissions, SUID, find |
find / -perm -4000 to hunt SUID binaries |
Remove unnecessary SUID bits, correct ownership |
Processes, services, ss |
Finding vulnerable services running as root | Disable unused services |
Logs, grep, awk |
Attackers try to clear logs | Reading /var/log/secure or auth.log to detect attacks |
| cron | Persistence through cron jobs | Auditing crontabs |
| Package management | Exploiting outdated software | sudo yum update / sudo apt upgrade regularly |
sudo grep "Failed password" /var/log/secure | tail # Amazon Linux: failed SSH logins
sudo grep "Failed password" /var/log/auth.log | tail # Ubuntu
sudo -l # what can this user run as root?
Why this matters for security
Tools like linPEAS only list possible weaknesses; you must understand Linux permissions to know which findings are real. The same knowledge makes you a good defender: every hardening step in Part 11 (SSH config, fail2ban, firewall, updates) is a Linux command you already know.
Ravindra Bagale's Tip
Tumcha EC2 internet var asel tar /var/log/secure ekda ughda – tumhi kahi na karta pan anek "Failed password" attempts distil. He bots aahet. Students ghabartat – ghabru naka! Key-only SSH aahe aani port 22 fakt tumchya IP la open aahe tar he attempts nirupyogi aahet. Hach "defence" cha pahila dhada.
Practice task
On your EC2 instance, count failed SSH attempts with grep and wc -l, list the top source IPs with awk and sort | uniq -c, and check sshd_config for PasswordAuthentication.