Linux System එකක් compromise කළාට පස්සේ attacker කෙනෙක් තමන්ගේ presence එක hide කරගන්නේ කොහොමද?

Mic
By Mic

Cybersecurity වල rootkit කියන්නේ සාමාන්‍ය malware එකකට වඩා වෙනස් idea එකක්.

NIST අනුව rootkit එකක් කියන්නේ system එකේ normal functionality වෙනස් කරමින් malicious activity එක stealthily hide කිරීමට භාවිතා කරන files/tools එකතුවක්. Root-level access ලබාගත් පසු activity එක සඟවාගෙන privileged access maintain කිරීම සඳහා rootkits භාවිතා කළ හැකියි.

MITRE ATT&CK එකේ Rootkit technique එක T1014 ලෙස track කරන අතර එහි primary objective එක තමයි programs, files, network connections, services, drivers සහ වෙනත් system components වල presence එක hide කිරීම. MITRE අනුව rootkit functionality එක user-level, kernel-level, hypervisor-level හෝ system firmware වැනි lower layers වල පවා තිබිය හැකියි.

🧠 Rootkit එකේ real purpose එක මොකක්ද?

Rootkit = “virus එකක්” කියලා සරලව define කරන එක වැරදියි.

Rootkit එකේ main idea එක:

Compromise → Privilege → Hide → Persist

උදාහරණයක් ලෙස attacker කෙනෙක් system එකකට unauthorized access ලබාගත්තා කියලා හිතමු.

ඔහුට අවශ්‍ය වෙන්න පුළුවන්:

Malware process එක hide කරන්න

Malicious file එක hide කරන්න

Network connection එක hide කරන්න

Service/driver එක hide කරන්න

Admin-level access maintain කරන්න

Rootkit technologies මේ stealth layer එක ලබාදීමට භාවිතා වෙන්න පුළුවන්. MITRE rootkits ගැන සඳහන් කරන detection patterns අතර anomalous kernel-module loading, concealed services, boot-component modification සහ /proc වැනි system interfaces tampering ඇතුළත්.

⚙️ Rootkit එක වැඩ කරන levels

Rootkit එකක් එකම layer එකක තියෙන්න ඕනේ නැහැ.

1️⃣ User-mode Rootkit

Operating system එකේ userspace/API layer එක target කරනවා.

Concept එක:

Application

System libraries / APIs

Kernel

සාමාන්‍ය OS tools තමන්ට පෙන්වන information rootkit එක manipulate කළොත් malicious process/file එක system එකේ තිබුණත් normal enumeration එකෙන් නොපෙනෙන්න පුළුවන්.

MITRE අනුව user-level hooking techniques rootkit behavior එකක කොටසක් විය හැකියි.

2️⃣ Kernel-mode Rootkit

මේක ගොඩක් serious.

Rootkit code එක kernel level එකට load වුණොත් operating system එකේ low-level behavior manipulate කිරීමට හැකියාව ලැබෙන්න පුළුවන්.

Conceptually:

User Applications

System Calls / Kernel Interfaces

Linux Kernel

Hardware

Kernel එක trust boundary එකේ ඉතාම පහළ layer එකක් නිසා මෙහි tampering detect කිරීම significantly harder වෙන්න පුළුවන්.

MITRE rootkits සඳහා kernel-level hiding සහ anomalous kernel-module loading වැනි behavior specifically monitor කරන්න කියලා සඳහන් කරනවා.

3️⃣ Bootkit

Rootkit එක boot process එක target කළොත් ඒවා Bootkits කියලා හඳුන්වන්න පුළුවන්.

Firmware / Boot Component

Bootloader

Kernel

OS

මෙවැනි rootkit එකක් OS එක සම්පූර්ණයෙන් load වීමට පෙර code execute කිරීමේ persistence mechanism එකක් ලබාගැනීමට උත්සාහ කළ හැකියි.

MITRE අනුව boot sector එක modify කරන rootkits “Bootkits” ලෙස specifically classify කරනවා.

4️⃣ Firmware / UEFI Rootkit

මේක තවත් lower level එකක්.

System Firmware

Boot Process

OS

Firmware level compromise එකක් තිබුණොත් OS reinstall කිරීම පමණක් ප්‍රමාණවත් නොවන අවස්ථා පවා තිබිය හැකියි.

MITRE documented example එකක් ලෙස Hacking Team UEFI Rootkit එක persistence සඳහා භාවිතා කළ බව සඳහන් කරනවා.

🐧 Linux වල Rootkit ගැන වැදගත් concept එක

Linux system එකක් investigate කරනකොට අපි normally tools use කරනවා:

ps aux

lsmod

ss -tulpn

find /

ප්‍රශ්නය මෙන්න:

ඔබ භාවිතා කරන visibility mechanism එකම attacker modify කරලා තිබුණොත්?

උදාහරණයක්:

Real system state

Kernel / system interface

rootkit manipulation

security tool

“Nothing suspicious”

ඒ නිසා:

“Command එකෙන් කිසිම දෙයක් පෙනුනේ නැහැ”

“System එක clean”

NIST සහ Kali documentation දෙකම automated rootkit scanners එකකට පමණක් rely කිරීමෙන් system එක uncompromised කියලා guarantee කරන්න බැහැ කියලා අවධාරණය කරනවා.

🔍 Linux Rootkit Detection — Practical Lab

මෙතනින් පස්සේ commands ඔබගේම Linux/Kali lab machine එකක හෝ explicit authorization තියෙන system එකක run කරන්න.

⚠️ Permission නැති system එකකට security investigation / testing කරන්න එපා.

1. Kernel version එක බලමු

uname -a

හෝ:

uname -r

මේකෙන් running kernel version එක identify කරගන්න පුළුවන්.

2. Loaded Kernel Modules

Rootkit investigation එකේ වැදගත් area එකක් තමයි kernel modules.

lsmod

තවත් detail සඳහා:

cat /proc/modules

Specific module එකක් ගැන:

modinfo module_name

උදාහරණ:

modinfo kvm

⚠️ Unknown module එකක් පෙනුණා කියලා ඒක rootkit කියලා conclude කරන්න බැහැ.

Legitimate third-party drivers, virtualization modules සහ hardware drivers තිබිය හැකියි.

Investigation එකේ බලන්න:

Module name

Module location

Author

Version

Dependencies

Signature

🔐 3. Kernel Module Signing

Linux kernel එකේ module-signing mechanism එකක් තියෙනවා.

Kernel documentation අනුව signed modules load වෙද්දී signature verification කරන්න පුළුවන් අතර CONFIG_MODULE_SIG_FORCE enable කරලා තිබුණොත් valid signature එකක් නැති modules reject කරන්න පුළුවන්.

Current configuration check:

grep CONFIG_MODULE_SIG /boot/config-$(uname -r)

උදාහරණ output එකක්:

CONFIG_MODULE_SIG=y

CONFIG_MODULE_SIG_ALL=y

CONFIG_MODULE_SIG_FORCE=y

නමුත් signed ≠ automatically trustworthy.

Attackers legitimate-looking signing chains හෝ compromised trust material abuse කළ හැකි architecture-level risks තිබිය හැකියි. ඒ නිසා signature එක කියන්නේ one signal එකක් විතරයි.

👀 4. Running Processes Compare කරන්න

Normal process listing:

ps aux

PID-oriented:

ps -ef

/proc වල process directories බලන්න:

ls /proc | grep ‘^[0-9]’

Basic consistency investigation එකක් සඳහා:

ps -e -o pid,ppid,user,cmd –sort=pid

මෙහි අරමුණ malicious process හොයාගන්න magic command එකක් use කිරීම නෙවෙයි.

අරමුණ:

Different visibility sources compare කිරීම.

🌐 5. Network Connections

Listening ports:

ss -lntup

Established connections:

ss -ntup

Alternative:

sudo lsof -i -n -P

Check කරන්න:

Unexpected LISTEN port

Unknown process

Unexpected remote IP

Unexpected persistent connection

Rootkits network connections hide කිරීමට use කළ හැකි බව MITRE specifically documents කරනවා.

📁 6. Hidden Files

Hidden files basic investigation:

find / -xdev -type f -name ‘.*’ 2>/dev/null

Temporary directories:

find /tmp /var/tmp -type f -ls 2>/dev/null

Sensitive system locations සඳහා:

find /usr /bin /sbin /lib -type f -mtime -7 2>/dev/null

මෙයින් output එකක් ආවා කියලා malicious කියලා label කරන්න එපා.

Recent legitimate package updates පවා files වෙනස් කරනවා.

🧩 7. Suspicious Kernel Messages

Kernel messages:

dmesg –level=err,warn

හෝ:

journalctl -k

CISA technical guidance එක Linux investigation වල lsmod, dmesg, /var/log සහ journald වැනි artifacts examine කිරීමට recommend කරනවා.

🛡️ 8. RKHunter

Linux rootkit detection සඳහා popular defensive tool එකක් තමයි:

Rootkit Hunter — rkhunter

Kali Linux current tools page අනුව rkhunter rootkits, backdoors, sniffers සහ exploits සඳහා scanning capabilities ලබාදෙන අතර file hashes, suspicious permissions, kernel-module strings සහ hidden files වැනි දේ check කරනවා. Kali page එක currently version 1.4.6 list කරන අතර install command එක:

sudo apt install rkhunter

ලෙස දක්වනවා.

Install:

sudo apt update

sudo apt install rkhunter

Help:

rkhunter –help

Version:

rkhunter –version

Configuration check:

sudo rkhunter –config-check

🔄 RKHunter database update

sudo rkhunter –update

Full check:

sudo rkhunter –check

Warnings only:

sudo rkhunter –check –report-warnings-only

RKHunter documentation අනුව –update සහ –propupd එකම දෙයක් නෙවෙයි. –propupd locally trusted file-property baseline එක establish/update කරන operation එකක්.

⚠️ –propupd blindly run කරන්න එපා

මේක ගොඩක් beginners miss කරන point එකක්.

Suppose RKHunter කියනවා:

Warning: File properties have changed

ඒකට immediately:

sudo rkhunter –propupd

run කරන එක dangerous troubleshooting habit එකක්.

මොකද?

ඔබ actual malicious modification එකක් තිබියදී new state එක “known good” baseline එකක් ලෙස record කරගන්න පුළුවන්.

RKHunter documentation එක explicitly කියන්නේ property database update කරන්න කලින් reported changes authorized / legitimate කියලා validate කරන්න ඕනේ කියලා.

🔎 9. CHKROOTKIT

Another defensive scanner:

sudo apt install chkrootkit

Run:

sudo chkrootkit

Kali Linux documentation අනුව chkrootkit rootkit infection indicators සඳහා scan කරන අතර known rootkits 70+ කට signs detect කළ හැකි බව current Kali documentation කියනවා. ඒත් automated scanner එකක් නිසා system එක clean කියලා guarantee කරන්නේ නැහැ; results human investigation එකකින් validate කළ යුතුයි.

🧪 10. Package Integrity Check — Debian/Kali

Rootkit investigations වලදී system binaries modify වෙලාද කියන එක වැදගත්.

Debian ecosystem එකේ:

sudo apt install debsums

Changed files:

sudo debsums -c

All package files:

sudo debsums -a

Only errors:

sudo debsums -s

Debian documentation අනුව debsums installed package files package-provided MD5 checksums සමඟ compare කරලා integrity changes identify කිරීමට භාවිතා කළ හැකියි.

🧠 Rootkit detection වල biggest problem එක

Rootkit එක already trusted layer එකක් modify කරලා තිබුණොත්, infected OS එක ඇතුළෙන් run කරන tools fully trustworthy නොවෙන්න පුළුවන්.

ඒ නිසා advanced incident response එකේ:

Compromised OS

Local tools

Potentially manipulated visibility

වෙනුවට:

Known-good environment

Acquire disk / memory evidence

Offline analysis

Compare with trusted baselines

වැනි methodology එකකට move වෙනවා.

මෙය rootkit investigations වල fundamental concept එකක්:

Don’t trust the compromised host blindly.

🚨 Rootkit එකක් suspect වුණොත්?

Random files delete කරන්න එපා.

මෙවැනි situation එකක:

1. Isolate the host

2. Preserve evidence

3. Capture relevant logs

4. Record running state

5. Examine persistence points

6. Compare trusted binaries / packages

7. Inspect kernel modules

8. Investigate network activity

9. Determine scope

10. Rebuild from a known-good source when necessary

CISA guidance එකත් logs, kernel modules, dmesg, journald, SSH keys සහ network artifacts collect කිරීම වැනි forensic indicators ගැන අවධානය යොමු කරනවා.

විශේෂයෙන් sophisticated kernel/firmware compromise එකක් suspect නම් “scanner එකක් run කළා → clean” කියන conclusion එක ප්‍රමාණවත් නැහැ.

🛡️ Rootkit වලින් defend වෙන්නේ කොහොමද?

01 — Least Privilege

හැම application එකකටම root privileges දෙන්න එපා.

sudo -l

මේකෙන් current userට sudo permissions මොනවාද කියලා inspect කරන්න පුළුවන්.

02 — System Updates

sudo apt update

sudo apt upgrade

Security vulnerabilities patch නොකරන system එකකට attacker initial access ලබාගන්න chance එක වැඩි වෙනවා.

03 — Secure Boot / Module Signing

Hardware/firmware trust chain සහ kernel module signing controls appropriately configure කිරීම kernel-level tampering risk reduce කරන්න උපකාරී වෙනවා. Linux kernel documentation module-signature enforcement ගැන specifically support කරනවා.

04 — File Integrity Monitoring

Known-good baseline එකක් maintain කරන්න.

Examples:

AIDE

Tripwire

Package integrity verification

EDR telemetry

Centralized logging

Goal එක:

Expected state

Current state

Unexpected change?

🎯 Rootkit ගැන Common Myths

❌ “Rootkit = එක executable file එකක්”

Necessarily නෙවෙයි.

Rootkit functionality files, modules, libraries, boot components, firmware හෝ වෙනත් layers වල තිබිය හැකියි.

❌ “rkhunter clean නම් machine එක 100% clean”

නැහැ.

Kali documentation itself කියන්නේ rkhunter alone එකෙන් compromise නැති බව guarantee කරන්න බැහැ කියලා.

❌ “Hidden file එකක් = rootkit”

නැහැ.

Linux වල legitimate hidden files / configuration files ගොඩක් තියෙනවා.

❌ “Unknown kernel module = malware”

නැහැ.

Hardware drivers, virtualization සහ third-party software නිසා legitimate modules තිබිය හැකියි.

❌ “Rootkit කියන්නේ hacking stage එකේ first tool එක”

බොහෝ අවස්ථාවල rootkit එකේ value එක තියෙන්නේ post-compromise stealth තුළ.

NIST rootkit ගැන attacker privileged access ලබාගත්ත පසු activity hide කිරීමට භාවිතා කරන mechanism එකක් ලෙස describe කරනවා.

🔥 Advanced Perspective

Rootkit එකේ dangerous part එක “malware file එකක් hidden කරන එක” විතරක් නෙවෙයි.

Real problem එක:

Visibility itself is being attacked.

SOC analyst කෙනෙක් බලන්නේ:

Processes

Network

Files

Services

Logs

Drivers

Kernel

Boot

Firmware

Rootkit එකේ objective එක මේ visibility chain එකේ එකක් හෝ කිහිපයක් manipulate කිරීම.

MITRE ATT&CK මේක T1014 — Rootkit ලෙස classify කරන්නේ ඒ stealth objective එක නිසා.

ඒ නිසා rootkit defense එක antivirus scan එකකට වඩා deeper:

Trust

+

Integrity

+

Visibility

+

Baseline

+

Telemetry

+

Independent Verification

කියන layers හරහා හිතන්න ඕනේ.

🧠 Final Takeaway

Rootkit එකේ power එක malware එක run වෙන එකේ නෙවෙයි — malware එක run වෙනවා කියලා ඔබට නොපෙනෙන තත්වයක් create කරන එකේ.

ඔයා ps, ss, lsmod, find, rkhunter වගේ tools use කරනකොට ඒ tools පෙන්වන state එක real system state එකද? කියන ප්‍රශ්නය තමයි advanced rootkit analysis එකේ heart එක.

Compromise

Privilege

Stealth

Persistence

Long-term access

Rootkit ගැන ඉගෙනගන්න එකේ real goal එක “rootkit install කරන එක” නෙවෙයි.

එකක් තිබුණොත් එය හඳුනාගන්නේ කොහොමද, visibility එක trust කරන්නේ කොයි මට්ටමටද, evidence preserve කරන්නේ කොහොමද, සහ system එක known-good state එකකට restore කරන්නේ කොහොමද කියන එක තේරුම් ගැනීමයි.

⚠️ මේ commands / techniques තමන්ගේම lab එකක හෝ explicit permission තියෙන environment එකක විතරක් test කරන්න. වෙනත් කෙනෙකුගේ system එකකට permission නැතුව use කිරීම නීතිවිරෝධී.

Fsociety.LK

Share This Article