Stephan Berger Profile picture
Jun 7, 2022 25 tweets 8 min read Read on X
1/ Linux #Hardening and #ThreatHunting

The screenshot below is from Microsoft [1] - using XorDdos as an example, we can learn a lot about Linux forensics and hardening. 🧵

#CyberSecurity
2/ XorDdos bruteforces (root) access via SSH.

Learning: Prevent logging in via SSH with passwords (use priv/pub keys instead).

Within the SSH config (/etc/ssh/sshd_config), modify at least the following two lines:

PermitRootLogin no
PasswordAuthentication no
3/ SSH can, of course, be secured in much more detail.

DigitalOcean has put together an excellent guide on this topic:

digitalocean.com/community/tuto…
4/ To examine XorDdos more closely, we download the ELF file from VT and infect our test machine with it (this file would be placed on the server after the root account has been compromised):

virustotal.com/gui/file/8a006…
5/ As seen in the first screenshot from MS, XorDdos creates various persistence mechanisms, including a cron job.

Cron jobs are one of the first things I check on a Linux system when assuming a compromise.
6/ The malware created a new entry in the /etc/crontab file - the /etc/cron.hourly/gcc4.sh file is called periodically.

Scripts called by a cron job should always be examined very carefully.
7/ Inside the shell script called by the cron job, a file is copied inside the /lib/ directory and then started.
8/ The hash sum is the same as from the started binary (/4) - according to Microsoft [1], the malware copies itself into the /lib directory, among other directories.
9/ In addition to the cron job, a new init entry was created on our (Ubuntu) machine that starts and stops the malware.

The init file gets the same name as the invoker program. The content of this init file should look at least suspicious enough to dig deeper.
10/ "After running the ELF file, uses an anti-forensic technique that hides its past activity by overwriting the content of the following sensitive files with a newline character:" [1].
11/ On our test machine, a journal is kept where all log messages are written by the journald (in the path /var/log/journal). We can export the journal for easier analysis:

journalctl --file <path>/system.journal -o export > /tmp/journal
12/ Read more about the journal from the sample chapter from the highly recommended book "Practical Linux Forensics" from @nostarchpress:

nostarch.com/download/sampl…
13/ Inside the journal, we find out from which IP address was logged in via SSH, even if other log files were deleted (see /10).

By the way, the malware does NOT delete the auth.log file (consciously or unconsciously), which we can use for forensic purposes.
14/ There are also traces of the cron job in the journal:
15/ Even though XorDdos deletes various log files, and according to Microsoft, also uses other techniques for hiding, it should be relatively easy to identify a machine infected with XorDdos.
16/ The spoofed command-line (see again [1]) can be used for hunting (there should not be too many processes running on a network that execute "cat resolv.conf").
17/ Even better is to look for the file gcc4.pid in the /var/run directory.

This value is sent to the C2 to identify the infected host uniquely.

If this file is present on a system, a deeper search must be done to check for a compromise by XorDdos.
18/ For those who have been following me on Twitter for a while.... exactly, @Sandfly! :)

We create a new sandfly where we specifically search for the file gcc4.pid on the whole file system.
19/ Our newly created Sandfly can now be selected for searching across our Linux fleet.
20/ And we get a hit (or a failure - that means the search have returned a hit).

Interestingly, the file is not stored under /var/run/, but under /run. A strict search for the fixed file path (from the IOC from MS) would not have found this file.
21/ Within the result from the Sandfly hit, we see the unique value used for sending back to the C2, indicating a true positive hit.
22/ As a last check, we take a closer look at the network connections. We see that "cat resolv.conf" has sent a SYN to an external IP address. Suspicious ;-)
23/ This IP address, in turn, brings us back to XorDdos:

virustotal.com/gui/file/00007…
24/ Also a good hunt: Searching for connections on the firewall with successful or attempted connections to a high port (like in our example to port 60000).
25/ Reference:

[1] microsoft.com/security/blog/…

• • •

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

Keep Current with Stephan Berger

Stephan Berger 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 @malmoeb

Jun 16, 2023
1/ We recently had an interesting #Azure case where the TA, instead of creating a new Inbox Rule, added email addresses of interest to the list of blocked senders and domains.

The incoming emails will get flagged as spam and moved to the Junk email folder. 📂

🧵
2/ Here is a screenshot from Outlook web access

(the view might differ, as, for example, here on the screenshot from the theitbros [1]) Image
3/ And here from an Outlook client: Image
Read 11 tweets
Apr 18, 2023
1/ Customer receives an email from a network monitoring device that a host is supposedly infected with a #CoinMiner. The Task Manager on the said system shows the following screenshot 🤕.

A story of an unpatched system, incorrect scoping, and 🍀. 🧵

#CyberSecurity Image
2/ The affected (and remotely accessible) server have had Confluence installed.

One of my first questions I asked the customer was if the system was up to date (Spoiler: it wasn't).

Confluence 6.0.4 was installed at the time of the incident.
3/ Confluence 6.0.4 was released in January 2017 🤯 Image
Read 14 tweets
Apr 17, 2023
1/ I used #AutoRuns v14.09 (GUI) in my lab setup but noticed that it failed to find (or display) the malware in the Startup folder, although the file is there (screenshot below).

I checked back and forth, searched manually for the file, and restarted the OS and AutoRuns.

🧵 Image
2/ With #Velociraptor, I ran the hunt Sysinternals.Autoruns, and with the CLI version of AutoRuns, the malware is found in the Startup folder. Image
3/ The same for the #Velociraptor hunt Sys.StartupItems. Image
Read 4 tweets
Mar 21, 2023
1/ The content below is from a file named install.bat and stems from a recent investigation where a TA launched this batch file. 👀

What's going on?

Well, VboxUpdate.exe is, in fact, tor.exe, and a new service is created, launching tor with a config file.

🧵 #CyberSecurity Image
2/ Below is an excerpt from the content of config.txt; the configuration file passed as an argument to the tor service.

If you think this looks a lot like RDP Tunneling, you are absolutely right. 🥇 Image
3/ Head over to the allthingsdfir blog to read a more profound write-up about the techniques used here and how they work together.

allthingsdfir.com/rdp-over-tor/
Read 5 tweets
Mar 20, 2023
1/ Real-World #PingCastle Finding #13: Allow log on locally

➡️ Domain Users are eligible to log into DC's 🤯🙈

"When you grant an account the Allow logon locally right, you are allowing that account to log on locally to all domain controllers in the domain." [1]

#CyberSecurity Image
2/ Why is this a bad idea?

"If you do not restrict this user right to legitimate users who must log on to the console of the computer, unauthorized users could download and run malicious software to elevate their privileges." [1]
3/ I encountered this finding several times in our AD assessments, so you better check your settings in your domain right now (better safe than sorry 🔒).

Good luck 🍀
Read 4 tweets
Mar 18, 2023
1/ Do you monitor newly created services within your environment, and would you notice when a (vulnerable) driver is loaded?

The screenshot below (#Velociraptor 🤩) is from a recent #XMRig CoinMiner investigation ⤵️

🧵 #CyberSecurity
2/ We talked about vulnerable drivers before:

Read 4 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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(