The Optimum Attack Rate For SSH Bruteforce? Once Every Ten Seconds
badger.foo writes "Remember the glacially slow Hail Mary Cloud SSH bruteforcers? They're doing speedup tweaks and are preparing a comeback, some preliminary data reported by Peter Hansteen appear to indicate. The optimum rate of connections seems to be 1 per ten seconds, smack in the middle of the 'probably human' interval."
RSA keypair auth, disable password auth, bruteforcers irrelevant.
perl -e "eval pack(q{H*},join q{},qw{70 72696e74207061636b28717b482a7d2c717b343 637323635363534323533343430617d293b})"
So, set your fail2ban or denyhosts configuration to 11 seconds intervals, and problem solved?
I'm going to guess it was a dictionary attack because otherwise it is even dumber.
That's 6 attempts per minute.
360 per hour
8640 per day
60,480 per week
3,144,960 per year.
So unless you're allowing usernames such as "root" or "admin" or "administrator" AND using dictionary passwords wouldn't this fail? And be obvious in the logs?
So what I've never understood is why it's not possible (as far as I know) for a server to require BOTH a key AND a password. Sure, I can put a password on my key, but that isn't the same at all. Is this possible yet?
Most of the bruteforce attacks I see on my home server are trying to get in as root. I don't allow remote root logins anyways (and even say so on the ssh greeting) so they'll never get in, even if they do manage to guess the password.
Hence their most optimal rate for my system would be never, because they won't get in that way. Not that my system is impenetrable - I'm sure an intelligent hacker could compromise it - but they will never get in trying to ssh in as root.
If they're doing white pages username + dictionary password - or white pages username + blank password (I've seen both, from botnet attacks), they still won't get in on my system as none of the common user names are used there.
Damn_registrars has no butt-hole. Damn_registrars has no use for a butt-hole.
I have a portknocking setup. All your packets bounce when you touch my port 22 until you have touched a "magic sequence" of port numbers first. That sequence can be cryptographically strong, time-dependent, etc. but even a simple one-port knock is enough to stop all this random SSH spam and has been for years.
And if you do "get lucky" and find the right ports and then detect that port 22 is open and then start a brute-force on that? Public-key-only authentication and no root logins allowed.
Impact on me? Another line in a shell script that I use to connect (and hell, even Android has free port-knocking apps, not to mention them being standard-enough to be in Ubuntu/Debian). Impact on server? Greatly reduced number of fake connections bouncing off iptables and a tiny little daemon that does nothing but listen on the ports I need (and can ONLY open the SSH port even if compromised). Impact on brute-forcers? They might as well give up and go home.
Even those remote companies that we do allow to port-forward direct to their device on my work network (e.g. telecoms providers, etc.) understand it and "knock" before they come in (which tells us exactly when they are about to log in), while everyone else in the world sees closed ports.
Why everyone doesn't use it, I have no idea. Even our VPN users have an automated script that just knocks to open the VPN ports (and only the VPN ports) before they connect. Transparent to them, invisible to everyone else, no different if "compromised".
iptables with the recent module...ssh brute force attacks a thing of the past. Actually, same with RDP and just about any other service you can identify via iptables.
Rate limit those suckers to something useful ( for ssh, I configured 2 attempts in 5 minutes, everything else is dropped ), call it done.
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state ESTABLISHED -j ACCEPT
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --set
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -m recent --name sshattack --update --seconds 300 --hitcount 3 -j DROP
iptables -I INPUT -i eth0 -p tcp --dport 22 -m state --state NEW -j ACCEPT
( Disclaimer: the above is from memory. I am positive there are better ways and more things you can do with it )
Mod me down with all of your hatred and your journey towards the dark side will be complete!
1 attempt per 10 seconds, so 360 attempts per hour, 8640 per 24 hours, 3,153,600 per year or 31 million passwords per 10 years.
Well, if your password is not in some rainbow table and it's at least moderately strong, then you should be fine.
You can't handle the truth.
Who cares about blocking them? They're not getting in anyway. Blocking is just additional work that may cause problems.
That's the reason that they're not going to get in. They're using usernames that don't exist (unless the sysadmin is an idiot in which case you have the regular idiot problems and it's probably been cracked already through one of those).
If you're using JUST first names or last names as usernames then you have a bigger problem.
Instead use something like one of the following:
FIrstnameLastname
Firstname.Lastname
FirstnameMiddleinitialLastname
You should be able to easily distinguish the potential threats from the random script-kiddies. That being a REAL username on your system with hundreds of login attempts.
And then you deal with that issue by changing the username. Then investigate how that username leaked.
knockd on Linux. Apt-get should find it for you. It will execute a specified shell script when it receives a specified knock (default one is specified). That shell script can be passed the IP that knocked (so you can include it in an iptables opening within the script).
There are also implementations for Windows, should you need that.
I personally use Denyhosts on my Linux server; it is a simple application that keeps an eye on SSH log and blocks access to SSH and any other services you have configured when the limit threshold is reached. You can also configure whether to keep those IP-addresses blocked forever, or for a specified time. Plenty useful. And the attack described here wouldn't work with Denyhosts.
Since I don't use my server for any actual business-use I have just configured Denyhosts to flat-out block access to any and all services altogether when the limit threshold is reached, and I've configured it to retain the block lists forever. These days I've got several thousand IP-addresses there and I rarely see anything malicious in my logs anymore.
Of course, denying root login altogether and using either SSH-keys or proper, long passwords is still essential.
I've been blocking these "attacks" using a script+firewall for many years now. And I still think that, really, OpenSSH should have a configuration switch to block them internally. But BSD folks don't see it as a real threat, and they don't want to risk having actual users to get locked out of their servers. Fair enough, I guess.
So we're left with mitigation strategies. At 6 connections per minute, it's more a a nuisance than an attack, but I've seen rates as high as 200 connections per minute in the past, and there is no reason it couldn't go higher on an out-of-the-box OpenSSH configuration.
Some solutions, as others have pointed out:
- Have ssh listen on a port other than 22
- Turn on OpenSSH's internal rate limiting (MaxStartups config)
- Use key-based authentication
- Roll your own script to grep the log for failed connections, and firewall any IP addresses with 10 or more failures
A real brute-force attack would do a portscan first so putting ssh on a high port isn't much of a solution. Key-based auth is a nearly perfect solution, except that there are situations in which it is undesirable/awkward to use keys. The others just slow down the attack, which prevents the force part of brute-force.
It's the name of a botnet. Assume any unfamiliar word in any Slashdot summary is the name of a botnet; it makes them eminently more readable. You can try out the technique on this one.
Bio questions? Ask me to start a Q&A journal. Computer analogies available for most topics!
The problem is that botnets have a lot of IP addresses. They can do one try from one machine then another from the next. If you disable the account entirely after a certain number of failed logins, you've just created a simple DoS attack. If you disable it just from that IP, it doesn't matter because it will just try from another. There are some realtime block lists that you can use to reject things, but these add another attack route that can let someone who can spoof DNS prevent you from logging in to your own machine...
I am TheRaven on Soylent News
At home? Yes.
I think I seen where you're going with that and I don't think you understand. Collecting email login names is easy.
But being able to login to an outward-facing server (email or ftp or ssh or whatever) should be limited to a certain amount of failed logins (no matter from which IP address) per time period.
The crackers would have to go through an ADDITIONAL step to try to match email login names with ssh login names and an ADDITIONAL ADDITIONAL step to match that name to a different type of server (such as ssh).
Let me see if I can illustrate this.
1. Attacking ssh on server A.B.C.D with username aaron - if there's any chance that the cracker can do it then the sysadmin failed. Even more so with "root" or "admin" or such.
2. Collecting username aaron.aaronson via email spammer and then trying to attack ssh on server mail.example.com - more work for the cracker than scenario #1 but still the same as #1. If there is any chance that the cracker can succeed then the sysadmin has failed. SSH should only be allowed on the mail server from the inside interface.
3. Collecting username aaron.aaronson via email spammer and then trying to attack ssh on servers in the block A.B.C.D through A.B.C.Z (and one of those is your SSH server). And the cracker is using multiple machines to make multiple attempts (one per machine) within time period X. - Again, if it works then the sysadmin has failed. Too many attempts in time period X should lock out the account for a set number of minutes. No matter how many IP addresses are involved.
-continued-
And that depends upon aaron.aaronson being a LEGITIMATE USERNAME ON THAT SYSTEM. Once the sysadmin sees that attack in the logs then the logins to that should be changed (ssh.aaron.aaronson or such) to break that attack if they were not already such. Or change them AGAIN (aaron.aaronson.ssh) and be aware that something leaked somewhere.
4. See #3 except the logins are from multiple machines but only 1 login attempt in time period X so it never triggers the account lockout. Again, change the login names (ssh.aaron.aaronson) to break that attack (and did they leak?).
In summary, getting your system cracked via SSH means that your sysadmin failed so many times.