@SandflySecurity was able to spot this malware very quickly and with multiple serious alerts. Let's have a walk-through about what it was up to and de-cloak it. #DFIR #sandflysecurity
Virus total shows very few results. But we saw many serious compromise tactics in use on this Linux system hit with the malware.
The top and ps commands show some odd things. Top is showing 100% of the CPU in use, but no process claiming responsibility. The ps listing shows nothing unusual. Something is hiding. Let's de-cloak it. #DFIR
We have multiple alerts for immutable files under /etc. The malware wants to make sure it can't be removed by making passwd, shadow, sudoers, and sshd files immutable. All of these files should be investigated. #DFIR.
We also found some weird files under /tmp directories marked immutable. On Linux immutable files are very uncommon and even less so hanging out in /tmp. The lsattr command will show you them. #DFIR
The malware also marked the root user SSH authorized_keys file as immutable. It also inserted a new key into it to allow remote access. #DFIR
Multiple suspicious entries were found in cron allowing the malware to pull over more files and maintain persistence. You can see the root cron with the command

crontab -l -u root
An entry was found under /etc/ld.so.preload which looks like our old friend the LD_PRELOAD cloaking rootkit. When this rootkit is running it will hide a pre-compiled binary, but is easily disabled.
To disable the LD_PRELOAD rootkit, simply rename /etc/ld.so.preload to something else. Then you can look inside the file it references for anything interesting. Here we see a reference to a binary called "java_c" #DFIR
Now with the rootkit disabled we run top and ps again and see our malicious process on the host.
Sandfly isn't affected by this rootkit so we saw it regardless. Here we flag the immutable binary and the fact that it's operating as a network service out of /tmp even with the cloak rootkit running. A big red flag here. #DFIR #sandflysecurity
We also flagged multiple accounts that were given root UID 0 permissions in /etc/shadow. The immutable flag set earlier was an indicator this file was tampered with as well. #DFIR #sandflysecurity
Because we hunt for compromise tactics we don't really care what the malware name is or the hashes, etc. The name can change but the tactics remain the same and we'll see it regardless. #sandflysecurity
This was an aggressive piece of Linux malware. It does scanning, inserts multiple backdoor methods, maintains persistence, and has a built in cloaking capability.

Linux malware is getting sophisticated. Keep an eye on your Linux systems so you don't get any nasty surprises.
Just saw this malware attempts to disable the open source tool we have to spot high entropy binaries on Linux hosts (along with firewalls and anti-forensics on history files). High praise for what we do. Full product is light-years ahead of the free tool.

github.com/sandflysecurit…
This code snippet was seen on a previous piece of malware. Detailed in the article below:

sandflysecurity.com/blog/getting-i…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Craig H. Rowland

Craig H. Rowland Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @CraigHRowland

25 Feb
You can find #Linux malware masquerading as a kernel thread using this command:

cat /proc/<PID>/maps

I'm going to show you how in this thread.

#DFIR #sandflysecurity Image
Malware will name itself with [brackets] to impersonate a Linux kernel thread. Bracketed names mean no cmd line argument. Kernel threads almost always are in brackets.

Use ps with tree view to find our candidates for investigation:

ps auxwf | grep "\["

#DFIR #sandflysecurity Image
Any #Linux process that looks like a [kernel thread] should have an empty maps file. If you look at the maps file for a process and it has data in it, it's not a kernel thread:

cat /proc/<PID>/maps

Our suspect below has entries under maps. Bad news.

#DFIR #sandflysecurity Image
Read 6 tweets
27 Sep 19
Let's go step-by-step and do some basic live process forensics for #Linux. Today's contestant is a bindshell backdoor waiting for a connection on Ubuntu. We saw something odd when we ran:

netstat -nalp

#DFIR #threathunting #forensics
netstat -nalp shows a process named "x7" PID with a listening port that we don't recognize. #DFIR Image
First thing we'll do is list out /proc/<PID> to see what is going on. Our PID is 5805:

ls -al /proc/5805

The current working directory is /tmp. The binary was in /tmp, but was deleted. A lot of exploits work out of /tmp and /dev/shm on Linux. This is a major red flag. #DFIR Image
Read 13 tweets
23 May 19
Here's how to recover a #Linux binary from a malicious process that has deleted itself from the disk.

cp /proc/<PID>/exe /tmp/recovered_bin

Let's see how this works. #DFIR #threathunting #forensics
Often, malware deletes itself after it starts so file scanners and integrity checks won't find it. It can make analysis harder if you can't get to the binary easily.

But if you remember /proc/<PID>/exe you can recover any deleted binary.

#DFIR #threathunting #forensics
Use the sleep command to simulate a deleted process:

cd /tmp
cp /bin/sleep x
./x 3600 &
[1] 32031
rm x

This copies the sleep command as "x" under /tmp and runs for 3600 seconds. Then, delete "x" so the binary appears removed. Practice on it.

#DFIR #threathunting #forensics
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!