The malware heartbeat
Marini Engineering suspects that one computer is talking to the outside without anyone knowing. The internal DNS resolver has logged six hours of queries: malicious programs that "phone home" betray a regular rhythm, but antivirus, time sync and backup have one too. Compare with the inventory of authorised services and decode the right file.
Lab 9 of 10 in the Blue Team / Defense path. If you get stuck you have 3 hints, from the vaguest to the most precise: they cost 0, 60 and 150 XP.
What you learn
Objectives complete themselves while you work in the terminal; each one is worth experience points:
- Read the inventory of authorised services (100 XP)
- Count the queries per computer+domain pair with cut, sort and uniq (150 XP)
- Check the rhythm of the queries to the suspicious domain (150 XP)
- Decode the file of the right computer and domain (150 XP)
Topics: defense, dns, beaconing, threat-hunting.
Commands you will use
The terminal is simulated and understands about forty Linux commands. In this lab you will mostly need these:
cat: prints the contents of a file: the most direct way to read configurations, notes and logs.cut: extracts one column from each line using a chosen separator, to isolate a specific field of a log.sort: sorts lines, numerically (-n) or in reverse (-r) too.uniq: removes repeated adjacent lines and counts them with -c: together with sort it builds rankings, such as the most insistent addresses.head: shows only the first lines of a file, handy for understanding a log format without reading all of it.grep: finds the lines that contain a word, even across whole folders with -r. It is the main tool for analysing text and logs.base64: encodes and decodes Base64, the format that turns bytes into text. It protects nothing: it can be undone without a key.|: the vertical bar | chains commands: the output of the first becomes the input of the next, so small tools form a complete analysis.
The simulated environment
You work in a simulated Linux shell, in the home folder of the user runner: invented files and folders, no network target.
Besides the home folder there is a complete simulated system, with configuration files, logs, users and permissions to examine.
The defensive lesson
Once the lab is solved, the write-up explains what went wrong and how to protect yourself:
A malicious program talking to its command centre often does so at regular intervals, even when the computer is idle: in the DNS log it is a domain queried by a single computer with a clockwork rhythm. It is not the most numerous, because legitimate services (antivirus, time, backup) are even more frequent: the inventory is needed to tell what is authorised. Defense: an inventory of services that call outside, internal DNS with logging and alerts on new domains, a sinkhole for malicious domains, outbound filtering and quick isolation of the host.
Before and after this lab
To unlock it you must have solved:
- Who is taking the data? (Blue Team / Defense, medium)
- DNS talks (Recon & Scanning, medium)
After this lab you can move on to:
- Ransomware: the right backup (Blue Team / Defense, hard)
The Blue Team / Defense path
Blue Team / Defense is the path of those who protect. You read access logs, count failed attempts to find out who is forcing a login, rebuild the timeline of an incident, compare an SSH configuration with the recommended one, shut down unnecessary services and handle incident response in four steps: detect, contain, clean up, document. The commands are the same as in the other paths, but used through the eyes of someone who must understand what happened and stop it from happening again.