M64.pl – how I learned that the default settings are not production settings
artur.co
artur.co
It includes the equivalent of fail2ban, manages iptables, watches log files, can email on failed logins, processes gone mad, and a few other things through a very simple config file.
It's that simplicity of the config file that I like, it means I can hand it to someone and know that they're unlikely to break something due to misconfiguration or failure to actually apply something.
This is on top of obvious things like running ssh on a non-default port, turning off password auth and restricting ssh to named users only (never root).
The install script is easy enough: http://www.configserver.com/free/csf/install.txt so it's really the case that I can do whatever work I'm doing for someone (hello Wordpress) and this can be my simple security solution which at least means I'm sure that I haven't left every window open.
Moving off the default port is a good way to avoid your logs getting filled up with failed login attempt messages.
Host example.com
IdentityFile ~/.ssh/id_rsa_example
User foobar
Hostname 127.0.0.1
Port 1234If you run it on a privileged port (1024, or lower), it means that it can be trusted to root-level.
It does nothing for security, but does help to reduce noise which in turn helps to reduce the time it takes to manage this stuff.
Sure there might have also been a local privilege escalation vulnerability, so rootkits are definitely something to check for. Depending on the situation, re-installing might be less work, so then it'd make sense.
But especially if you're not the only one using the machine, having to reinstall the OS every time a single user fucks up and has 'password' for a password, it's going to get really tedious really quickly.
I certainly don't know enough about computer forensics to make sure that a system hasn't been altered (and I dissect malware for recreational purposes). So unless it's a system that hosts something completely unimportant I'd take the weekend free to wipe + reinstall the stuff.
Even recently a linux local privilege escalation has been discovered[0]. So who knows what the hacked www user really had access to.
This is what automated installs are for. Kill the box, fire up a new one, and run the provisioning scripts. As a bonus you've got actual documentation showing how the box should be set up.
And you shouldn't trust them either, so you need to assume they have if they could have. That means definitely reinstall when you find out you've been vulnerable to e.g. a local root exploit, regardless of user accounts have been hacked.
I did immediately change www's password again and de-privilege the ssh key that that box had been equipped with. In fact I've recently started always ssh-ing into servers with the -A flag so I don't have to give them keys at all.
So far I don't see any more mysterious activity. Thanks for the word of caution.
Meaning one of his administrators must have set one (likely for temporary troubleshooting), kicking off the whole issue...
edit: if SSH access was indeed the first cause. Running any upload-and-run script as `www` would let them set the password themselves, I think.
Maybe default settings are production settings after all!
Run 'sudo su www -s /bin/bash'. using '-s /bin/bash' will override the usual nologin shell, and running 'su' as root will mean a passwordless account can be su'd too.
This will allow you to try accessing files and directories as if you had the user 'www's privileges without having to make the 'www' account regularly usable.
You should never set a real shell or password for any accounts that a real user will not be using.
Also, I would guess the attack is fully automated.
it was a very long week.
I guess if you disable password logins, someone would need to get a pubkey into a user's ~/.ssh directory.
If I got hacked with m64.pl, I'd get as far as running top and killing the process. His immediate assumption was that someone got a file that file on to his server and so he went on to check the logs and found all the failed login attempts. I would have wondered what the file was, googled around and sat around confused.
Luckily deploying a new instance on Digital Ocean sounds simple enough so I would probably just do that but that approach would leave me with a sense that I don't know what I'm doing at all. There was a time when my solutions to problems on Windows machines was to restart and/or format but I don't do that anymore but still meet people who do. I'd rather not start from square 1 when I make the leap to Linux.
What are the things one should know to legitimately say they can manage their own Linux server? I could try to just wing it and solve every problem as I encounter them but for right now I'd just like to identify the gaps in my knowledge.
My 2 cents about defending against scripters:
* SSH: non-standard port, no passwords, special user-group who is allowed to login.
* WWW: redirect everything to https. For some reason bot-attacks dropped from hundreds to none over night. :D
off: does anyone know which font he uses in the terminal? Looks awesome.
Firefox: Right click, inspect element, click the "fonts" tab on the right.
Chrome: Right click, inspect elmeent, look at "Computed" styles on the right, find Rendered Fonts.
Ironically, the answer is he's not using a font. It uses Times New Roman on my Chrome and DejaVu Serif on my firefox because those are my default system fonts, not because he specified them. If you look at the source of the webpage, you'll see he has zero stylesheet links, all his styles are inline in <style> blocks... So searching font in that one source page is sufficient to find he only styles code blocks, the rest is default.
If you're referring to some other font, I have no clue, sorry!
The author will soon know that if the situation repeats without the ssh access.
"I work for Linode, but everything I say is me being an idiot." so..
I have always been surprised that fail2ban is so popular, since iptables can do rate limiting, etc. So, it's easy to block most attacks with the in-kernel firewall:
Since clearly you are confused what it actually does.
But you probably thought that I was suggesting to block IPs by hand. I wasn't.
ssh -l "root@ 1.2.4.5" ssh.example.com
Allowing you to lockout the specified IP.That looked like a pretty amateur attempt yet he managed to log in as www.
Was there no password for www?
Why was it even available to SSH into?
This leaves a lot of questions unanswered.
I guess change the password so someone else can't break in after you?
I can't explain the mining script. Maybe they want to alert you the box is owned, as a means to find only targets who don't wipe their system after being infected? What's the point...?
Details of minerd at https://bitcointalk.org/index.php?topic=55038.0
I was just posting a single option to complement the other comments.