You are not logged in.
Since I use ssh with password authentication to access my home router from anywhere, I've installed fail2ban to protect it.
It worked well, although I had an average of 20 daily break-in attempts from various IP addresses.
But I've got this on my routers sshd log:
febr 17 20:48:03 ROUTER sshd[2571]: Set /proc/self/oom_score_adj to 0
febr 17 20:48:03 ROUTER sshd[2571]: Connection from 108.166.117.141 port 45083 on 91.82.39.2 port 22
febr 17 20:48:05 ROUTER sshd[2571]: reverse mapping checking getaddrinfo for 108-166-117-141.static.cloud-ips.com [108.166.117.141] failed - POSSIBLE BREAK-IN ATTEMPT!
febr 17 20:48:06 ROUTER sshd[2571]: Accepted password for USERNAME from 108.166.117.141 port 45083 ssh2
febr 17 20:48:06 ROUTER sshd[2571]: pam_unix(sshd:session): session opened for user USERNAME by (uid=0)
and that is all...
and according to the systemd-logind log
febr 17 20:48:06 ROUTER systemd-logind[149]: New session 6 of user USERNAME.
febr 17 20:48:06 ROUTER systemd-logind[149]: Removed session 6.
As far as I know, nothing has changed, no files modified or created at that time.
After this one, I have several unsuccessful attempts in my logs too.
Of course, I've changed the password.
Well, the question is, was that really a successful break-in?
Last edited by scar (2014-02-19 16:32:33)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
The sshd log does seem to suggest a successful login. But looking at the logind log, the session didn't even last a second.
Were you using a weak password, because I doubt with fail2ban it can be brute forced.
In any case, this looks rather fishy. Maybe it's a vulnerability in the router that was exploited. What router are you using and which firmware?
Offline
It is an older astaro gw, but I'm using it since 4 years without any major issues. The box runs Arch.
The password was not random, but not really "coherent' one, with lowercase and uppercase letters, numbers and special characters.
Geolocation of the IP address shows Ohio, US - and when i'm googling after" ssh + that ip address":
http://oucsace.cs.ohiou.edu/~tysko/scanattack.2014.01
and that is an interesting one... six time the same IP as on my router.
Last edited by scar (2014-02-19 17:39:42)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
That certainly looks like they got in. Do you use the same passwords on multiple sites? Is it possible that they were able to get their hands on an unsalted hash of your password? That would allow them to perform an off-line brute force attack.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
I never use the same password on two different places or boxes.
And according to fail2ban that IP was never blocked.
And that was not my attempt to log in.
Imagine my face now...
Do you have any advices (besides changing my password, that I already did) ?
Last edited by scar (2014-02-19 18:09:12)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
You might do a port scan on the Internet side of your router to ensure there are no open ports. Any chance your are exposing a configuration interface, or an FTP server that would allow someone to retrieve a file such as /etc/passwd from your router? If such a file is available, and if the router does not use shadow, then Harry Hacker could obtain your username and and hash of the password. They could then use a brute force dictionary attack generating hashes at random until they find one that matches the hash you (may) have provided them. Once they get a match, they know your user name and password. Robust systems either use a shadow password file , salted passwords, or both. I am not saying this is what happened, but it is a common attack.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
No way someone could access my /etc/passwd or /etc/shadow remotely.
The only open ports were for ssh, iperf and for the web interface of my router.
I think I will close them all but iperf on the WAN side and set up an openvpn server...
Last edited by scar (2014-02-19 18:37:11)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
port 22
Don't use port 22 for SSH!
Use a random, free port, e.g. 5107. An easy change to improve security.
Offline
I know, but I've thought with changing my password frequently and using fail2ban I would be better protected.
By the way, I would like to know, what I have to check in this case.
I mean, I've verified if my UNIX users login conditions have changed since then (I had an rsync backup of the box which is a week older than the break-in). I've verified if there are new services running, files created or modified since that date, checked my .bash_history, closed sshd on the WAN side (I will only use openvpn to connect to it), changed the password, checked if there are new users, checked my iptables for suspicious rules. There is nothing.
I think, there is a plethora of documentation about hardening ssh, but what to do in a case like this?
What else do I have to verify?
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
As I said previously, the session lasted about a second. Assuming it was a successful login, it probably was an automated one.
Since, nothing seems to be changed, I am not sure what to suggest. Maybe see if any new cron jobs popped up, and check for rootkits.
Offline
@scar You can only verify the machine if you took it off-line and booted from trusted media. Otherwise it is possible that a rootkit has been installed that hides its traces.
If possible, disallow password logins (or if you really need them, restrict them to an IP). Then stick to SSH public-key auth only. Put the following in your sshd_config to restrict password-based auth to user scar in your LAN:
PasswordAuthentication no
Match Address 192.168.1.* User scar
PasswordAuthentication yes
# Set allowed users (scar, root) and limit logins to an address for root
AllowUsers scar root@192.168.2.*
Offline
Thank you. Off-line check this evening.
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
I've checked the system while off-line with rkhunter, nothing suspicious was found.
What else can I do?
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
I would re-install all packages with pacman too (something like pacman -S `pacman -Qq` from chroot). You could also use http://archlinux.spider007.net/pacman-f … unowned.sh to find any files that aren't then overwritten by pacman
Last edited by Spider.007 (2014-02-21 13:46:20)
Offline
This thread totally freaked me out. So last night I read through the wiki page on SSH keys and disabled username / password logins. I also changed the SSH port from 22 to something else.
...It's funny, I actually had some crazy trouble with my router. I had my router nicely setup to do port forwarding for port 22, right? I then changed it to the new port, I couldn't get SSH to login, so I changed it back to port 22, and I still couldn't login, even though everything was setup exactly the way it was an hour before! I ended up resetting my router to the default factory settings and reconfiguring it (only took about 10 minutes to do) and as I expected port forwarding starting working again as expected. For your information.
Anyway, with only-keys-allowed logins and a sneaky new SSH port hopefully my SSH server is nice and safe now from the badguys.
Offline
Well, maybe I'm paranoid, but I will zero out my routers CF card today and reinstall the whole thing; forbid ssh on WAN and use it only from a vpn connection. That is it.
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
Yeah I agree; it's a bit paranoid but lots better then discovering a rootkit a couple of months from now. I think that a successful login would only be registered somewhere to be abused later, but it's not worth the risk. Next time I'd disable pwd authentication entirely and use keys only
Offline
This is what I did. Thanks for the help, guys.
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline