LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   My First Brush With Linux Malware (http://www.linuxquestions.org/questions/slackware-14/my-first-brush-with-linux-malware-4175501872/)

GVrooman 04-15-2014 07:21 PM

My First Brush With Linux Malware
 
I never had any trouble with malware in Linux until the other day when I caught my Slackware box trying to download a number of files from dgnfd564sdf.com. A little Google searching revealed that this is a known malware site located in Beijing. Apparently they crack your root password and use ssh to modify your crontab to download the files. I never use ssh for anything so I was a little disconcerted to learn that I had this big security hole that somebody was trying to exploit.

One file that did get downloaded was sfewfesfs which showed up in my /etc directory. When I tried to delete it I discovered that, even as root, I couldn't delete it. Even worse the sticky bit was set. I did a Google search on the file name and discovered a page full of sinister looking crontab entries that somebody had posted on Pastebin.

I had been planning to upgrade the box to Slackware 13.37 anyway so I reformatted the hard drive and installed Slack with a tougher root password. Then, after doing a little reading up on the subject, I configured ssh to ban root logins altogether. Before I did the install I noticed that my computer was spawning a bunch of sendmail jobs that didn't go anywhere because I had my internet connection shutdown. Apparently the whole idea of this thing is to turn your computer into a spambot. Has anyone else had trouble with this?

ga_flyer 04-15-2014 08:39 PM

Immutable bit strikes again
 
The reason that you could not remove the file as root likely was that the hacker set the "immutable" bit on it. This is one of several additional permission bits outside of the normal *nix bits.

To see if the immutable bit is set on "foo" do:

lsattr foo

The "i" below indicates that the immutable bit is set:
----i---------- foo

Turn off the immutable bit as root thusly:

chattr -i foo

Then you can remove the file.


There are other solutions to prevent a brute-force attack against ssh passwords. The best is to use a private key for ssh access. You can generate one with:

ssh-keygen -b 1024 -t dsa [-C comment] -f outputfile

Then a read of "man ssh" shows how to use it.

Alternatively, use a password of at least 12 characters which cannot be guessed. E.g., don't use "root1234", "my favorite sports team", etc.


Using a private key (with a strong passphrase) or a strong password, it is safe to allow root access.

metaschima 04-15-2014 08:40 PM

Looks like it is call the BillGates botnet:
https://isc.sans.edu/forums/diary/Un...ditions/17282/

If you don't use a service, turn it off, that's part of basic security.

TobiSGD 04-15-2014 08:55 PM

1. Insecure root password
2. Remote root login allowed
3. SSH server running, though not used
You couldn't make it much easier for those crackers.

frankbell 04-15-2014 08:57 PM

You might also take a look at fail2ban. After a configurable number (three is a popular setting) of failed login attempts, it blocks the originating IP address for a configurable amount of time.

I have it on my one public facing machine.

Wikipedia has a nice article about it: https://en.wikipedia.org/wiki/Fail2ban

TommyC7 04-15-2014 09:31 PM

I think this topic is better suited for the Linux - Security section of LQ.org. The people there will likely know more than us about these things.

enorbet 04-17-2014 01:21 AM

Is there even a reason to have Sendmail service on a Desktop box?

unSpawn 04-17-2014 02:13 AM

Quote:

Originally Posted by TommyC7 (Post 5153569)
I think this topic is better suited for the Linux - Security section of LQ.org. The people there will likely know more than us about these things.

...some of the people there tend to be lured in easily by including words like "cracked", "hacked", "malware", etc, etc in thread titles :-]


Quote:

Originally Posted by TobiSGD (Post 5153544)
1. Insecure root password
2. Remote root login allowed
3. SSH server running, though not used
You couldn't make it much easier for those crackers.

Allowing root and not using pubkey auth and allowing remote root access, exactly! Shame people still have to learn things the hard way.


Quote:

Originally Posted by GVrooman (Post 5153486)
(..) I reformatted the hard drive and installed Slack with a tougher root password. Then, after doing a little reading up on the subject, I configured ssh to ban root logins altogether. (..)

Reinstalling the OS was a good choice given evidence elsewhere suggests both script-based as well as manual modifications as root. (Note crontab-based tricks aren't something new, its been around for ages, and depending on purposes may not even require root access. If one is stupid enough to allow say the web server user a crontab then, given a vuln in popular software in the web stack, that may be enough.) Do ensure all passwords are changed (not only root), ensure you implement the advice given, harden your machine basically, and if you have any 'net facing services do ensure you not only have active response (like fail2ban) but also regularly audit the box (say Samhain + Logwatch?) to be able to investigate any anomalies before they become a problem.

rkelsen 04-17-2014 09:13 AM

My First Brush With Linux Malware
 
You should be using shared keys.

smallpond 04-17-2014 09:27 AM

Actually, the real shame is that remote root login is allowed by default.

BenCollver 04-17-2014 11:04 AM

Regarding fail2ban, I prefer a more proactive approach: Using /etc/hosts.{allow,deny} and/or iptables to restrict who can connect to sshd in the first place. I also disable password authentication and root login. These settings are effective on Slackware. On other systems, it is also necessary to disable PAM, or else PAM will "override" the sshd configuration. Ideally, sshd wouldn't even be listening on the Internet. It would all be done over a VPN instead. This would help guard against undiscovered security bugs and 0-days.

mostlyharmless 04-17-2014 11:08 AM

Quote:

when I caught my Slackware box trying to download a number of files from dgnfd564sdf.com. A
The interesting question for me here is, what did you notice? How did you catch it?

pchristy 04-19-2014 12:35 PM

Quote:

Originally Posted by smallpond (Post 5154478)
Actually, the real shame is that remote root login is allowed by default.

Having just stumbled on this thread, I thought I'd better check this out. Looking at my sshd_config file I find:

#PermitRootLogin yes

which implies (to me!) that the default is not to allow a root login. My system is 14.0 (haven't got around to updating to 14.1 yet!). Am I reading this correctly? And does this mean that at some point between the OPs system and mine, this loophole was closed? I am no security expert!

--
Pete

metaschima 04-19-2014 12:38 PM

It is commented out, so it is NOT allowed by default. I have also checked the 14.1 package.

mancha 04-19-2014 12:49 PM

Quote:

Originally Posted by metaschima (Post 5155583)
It is commented out, so it is NOT allowed by default. I have also checked the 14.1 package.

That's unfortunately an incorrect analysis.

@pchristy: I agree with you the line, as written, suggests the default is to not allow root logins. However, the default does
allow them. Sound practice (unless you have special needs and know what you're doing) is to set "PermitRootLogin no" in
/etc/ssh/sshd_config. Maybe Slackware should ship that as default.

--mancha


All times are GMT -5. The time now is 05:39 PM.