This website collects cookies to deliver better user experience, you agree to the Privacy Policy.
Accept
Sign In
The Texas Reporter
  • Home
  • Trending
  • Texas
  • World
  • Politics
  • Opinion
  • Business
    • Business
    • Economy
    • Real Estate
  • Crypto & NFTs
  • Tech
  • Lifestyle
    • Lifestyle
    • Food
    • Travel
    • Fashion
    • Books
    • Arts
  • Health
  • Sports
  • Entertainment
Reading: Linux Host Compromise Playbook
Share
The Texas ReporterThe Texas Reporter
Font ResizerAa
Search
  • Home
  • Trending
  • Texas
  • World
  • Politics
  • Opinion
  • Business
    • Business
    • Economy
    • Real Estate
  • Crypto & NFTs
  • Tech
  • Lifestyle
    • Lifestyle
    • Food
    • Travel
    • Fashion
    • Books
    • Arts
  • Health
  • Sports
  • Entertainment
Have an existing account? Sign In
Follow US
© The Texas Reporter. All Rights Reserved.
The Texas Reporter > Blog > Uncategorized > Linux Host Compromise Playbook
Uncategorized

Linux Host Compromise Playbook

Editorial Board
Editorial Board Published September 5, 2023
Share
SHARE

Published on 5th September, 2023

By Sivaraju Kuraku

Introduction

In today’s digital landscape, ensuring the security and integrity of Linux hosts is paramount. As Linux servers are frequently targeted by cyber attackers, having a comprehensive playbook to identify, investigate, and remediate suspicious activities is crucial for system administrators and security professionals. This playbook provides detailed steps and commands to help in examining various aspects of a Linux system, such as file paths, processes, services, cron jobs, network connections, and persistence mechanisms. By following these guidelines, you can effectively detect and mitigate potential compromises on your Linux hosts, thereby maintaining a secure and resilient infrastructure.

Common Places to Search for Suspicious Activity

  1. /var/spool/cron – Location of user crontabs
  2. /etc/cron/.d – Other cron jobs
  3. /home – User home directory
  4. /var/log – Local log files
  5. /tmp – Most common place for malware

File Paths

Investigation Commands and Purposes

Paths: /tmp, /var/tmp, /dev/shm
Command: find /tmp /var/tmp /dev/shm -type f
Purpose: Temp directories are commonly used by attackers to store malware or scripts temporarily. Investigating these paths can uncover hidden malicious files.

Paths: /home/[username]/.ssh/, /home/[username]/.bashrc, /home/[username]/.bash_profile
Command: grep -iR ‘base64\|wget\|curl’ /home/[username]/
Purpose: Searches for base64 encoding and download commands in user profiles and SSH configurations, which might indicate backdoor setup or persistence mechanisms.

Paths: Web root directories, e.g., /var/www/html, /usr/share/nginx/html
Command: find /var/www/html -name “*.php” -exec grep -l ‘eval\|base64_decode’ {} \;
Purpose: Identifies PHP files containing eval or base64_decode functions, often used in web shells or malicious scripts.

Paths: /bin, /usr/bin, /sbin, /usr/sbin
Command: find / -perm -4000 -exec ls -ldb {} \;
Purpose: Finds all SUID (Set User ID upon execution) files. Malicious binaries might be placed here to execute with elevated privileges.

Paths: /etc/passwd, /etc/shadow, /etc/cron*, /etc/systemd/system
Command: auditctl -w /etc/passwd -p wa -k passwd_changes
Purpose: Monitors changes to critical configuration files, alerting on unauthorized modifications.

Paths: /etc/crontab, /var/spool/cron/crontabs/, /etc/cron.d/
Command: grep -Ri ‘base64\|curl\|wget’ /etc/cron* /var/spool/cron/crontabs/ /etc/cron.d/
Purpose: Identifies suspicious commands in cron jobs that could be used for executing malicious activities on a schedule.

Paths: /home/[username]/.ssh/authorized_keys
Command: cat /home/[username]/.ssh/authorized_keys | grep ‘ssh-rsa’
Purpose: Checks for unauthorized SSH keys that may grant attackers persistent remote access.

Paths: Suspicious Hidden Files or directories starting with .
Command: find / -name “.*” -type f
Purpose: Finds hidden files which may be used to store malicious scripts or data.

Paths: /var/log/, specifically auth.log, syslog, or messages showing gaps or edits
Command: ls -lt /var/log/ | head
Purpose: Checks for recent modifications in log files that could indicate tampering to hide malicious activities.

Remediation Commands

  • Command: rm -f /suspicious/path/malicious_file – Deletes identified malicious files. Use cautiously to avoid removing legitimate system files.
  • Command: chmod 644 /suspicious/file – Resets permissions on files that may have been modified to prevent unauthorized access.
  • Command: Review and harden configuration files, e.g., vi /etc/ssh/sshd_config – Ensures services are configured securely, minimizing the attack surface. Focus on disabling root login, enforcing key-based authentication for SSH, and applying the principle of least privilege.
  • Command: echo ” > /home/[username]/.ssh/authorized_keys – Clears all authorized keys to remove unauthorized access. Ensure legitimate keys are backed up and re-added carefully.

Investigating and Remediating Linux Processes

  • Command: ps aux – Displays all running processes. It is useful for spotting unusual or unknown processes that could signify a compromise.
  • Command: top or htop – Provides a dynamic, real-time view of running processes. It helps in identifying processes that are using excessive system resources, which may indicate malicious activity.
  • Command: pstree -p – Shows running processes as a tree, making it easier to understand the parent-child relationships between processes. This can help track the origin of suspicious processes.
  • Command: lsof -p [PID] – Lists all files opened by a specific process (indicated by its PID). This is crucial for identifying what resources a suspicious process is accessing.
  • Remediation Command: kill -9 [PID] – Immediately stops a specific process identified as potentially malicious. The -9 option ensures a forceful termination.

Investigating and Remediating Linux Services

  • Command: systemctl list-units –type=service –state=running – Lists all currently active services. This command helps identify unexpected or unauthorized services that may be running.
  • Command: systemctl status [service_name] – Provides detailed information about a specific service, including its current status, recent logs, and whether it’s enabled to start at boot. It is useful for diagnosing issues with known services or investigating suspicious ones.
  • Command: journalctl -u [service_name] – Displays the systemd journal logs for a specific service. Logs can reveal errors, unauthorized access attempts, or other suspicious activities associated with the service.
  • Command: cat /etc/systemd/system/[service_name].service – Displays the contents of the service’s unit file, which defines how the service starts and operates. Reviewing this file can help identify malicious configurations or modifications.
  • Remediation Command: systemctl stop [service_name] – Stops a service that might be running a malicious process. This is a softer approach than killing a process and is useful for services that will be investigated further.
  • Remediation Command: systemctl disable [service_name] – Prevents the service from automatically starting on system boot, reducing the risk of the persistence of malicious activities.
  • Remediation Command: systemctl mask [service_name] – Prevents the service from being started manually or automatically. Masking is a stronger version of disable, ensuring the service cannot be activated without being unmasked.
  • Remediation Command: rm /etc/systemd/system/[service_name].service and then systemctl daemon-reload – Deletes the service’s unit file and reloads the system to apply changes. Use this to remove unauthorized or malicious services permanently.
  • Restore Command: sudo systemctl revert [service_name] – Restores the original system service file if it has been modified. This can be useful if a legitimate service’s configuration is altered for malicious purposes.

Investigating and Remediating Cron Jobs and Scheduled Tasks

  • Command: for user in $(cut -f1 -d: /etc/passwd); do echo “Cron jobs for $user:”; crontab -u $user -l; done – Enumerates all cron jobs across all user accounts, including system users, which helps in identifying unexpected or malicious entries.
  • Command: ls -al /etc/cron* – Lists content in system-wide cron directories (cron.daily, cron.hourly, cron.monthly, cron.weekly, and cron.d). Reviewing these directories is crucial for spotting unauthorized scheduled tasks.
  • Command: cat /etc/anacrontab – Displays tasks scheduled with Anacron, which, unlike Cron, can run commands not strictly tied to the system’s clock. It’s vital for systems that don’t run 24/7.
  • Command: systemctl list-timers –all – Lists all active systemd timers, an alternative to cron jobs used in newer distributions. This command uncovers scheduled tasks managed by systemd.
  • Remediation Command: crontab -u [username] -e – Opens the crontab editor for a specific user, allowing the removal of unauthorized or malicious cron jobs.
  • Remediation Command: chmod -x /etc/cron.daily/[job_name] – Removes execution permissions from a system-wide cron job script, effectively disabling it without deletion.
  • Remediation Command: rm /etc/cron.d/malicious_cron – Completely removes a cron job file from the system-wide cron directory, used when a cron job is identified as malicious.
  • Remediation Command: systemctl stop [timer_name].timer && systemctl disable [timer_name].timer – Stops and disables a systemd timer, preventing the scheduled task from running again.

Investigating and Remediating Network Connections

  • Command: ss -tunapl or netstat -tunapl – Lists all active network connections (TCP/UDP), along with the processes responsible for them. This can help identify unauthorized connections or processes communicating with suspicious external IP addresses.
  • Command: lsof -i – Lists open network connections and the associated processes. Useful for understanding which processes are communicating over the network.
  • Command: iptables -L -n -v – Displays the current firewall rules, which can reveal unauthorized or malicious rules that allow or block certain traffic.
  • Command: tcpdump -i eth0 – Captures network traffic on a specific interface. Analyzing this traffic can help detect unusual patterns or data exfiltration attempts.
  • Remediation Command: iptables -A INPUT -s [suspicious_IP] -j DROP – Blocks incoming traffic from a suspicious IP address, helping to mitigate ongoing attacks.
  • Remediation Command: iptables -D INPUT -s [suspicious_IP] -j ACCEPT – Removes an existing rule that allows traffic from a suspicious IP address, tightening network security.
  • Remediation Command: kill -9 $(lsof -ti:[port]) – Forcefully terminates all processes using a specific network port, useful when a port is identified as being used for malicious communication.
  • Remediation Command: ss -K dst [suspicious_IP] – Terminates all network connections to a specific IP address, helping to disrupt active malicious communications.
  • Remediation Command: tcpkill host [suspicious_IP] – A tool that allows for the targeted termination of network connections, which is useful for quickly stopping communication with known malicious IPs.

Conclusion

By following the outlined procedures and utilizing the provided commands, you can systematically investigate and remediate suspicious activities on your Linux hosts. Regularly updating and practicing these steps ensures that you stay prepared to address potential threats effectively. Remember, maintaining a secure environment is an ongoing process that requires vigilance, regular updates, and continuous improvement of your security practices. By implementing this playbook, you take a significant step towards safeguarding your systems against potential compromises.

Share This Article
Twitter Email Copy Link Print
Previous Article Ethical Concerns in AI: Navigating the Moral Landscape Ethical Concerns in AI: Navigating the Moral Landscape
Next Article Branden Condy and Don Resin: From Party Scene to Business Dreams Branden Condy and Don Resin: From Party Scene to Business Dreams

Editor's Pick

30 Dinner Recipes for When You Don’t Really feel Like Cooking (And It’s Too Sizzling Anyway)

30 Dinner Recipes for When You Don’t Really feel Like Cooking (And It’s Too Sizzling Anyway)

There’s a lot to like about summer time: the straightforward, breezy, carefree days, the extra hours of sunshine, and naturally,…

By Editorial Board 13 Min Read
Alpine’s Sizzling Hatch EV Has a Constructed-In, ‘Gran Turismo’ Model Driving Teacher

One other win over its Renault 5 sibling is a multi-link rear…

3 Min Read
Louis Vuitton Is Dropping a New Perfume As a result of It’s Sizzling | FashionBeans

We independently consider all beneficial services and products. Any services or products…

2 Min Read

Latest

Flawed information used repeatedly to dismiss claims about ‘Asian grooming gangs’, Baroness Casey finds | UK Information

Flawed information used repeatedly to dismiss claims about ‘Asian grooming gangs’, Baroness Casey finds | UK Information

Flawed information has been used repeatedly to dismiss claims about…

June 16, 2025

Coinbase faces crypto backlash over sponsoring navy parade in D.C.

As the primary large-scale navy parade…

June 16, 2025

CoinShares Seeks SEC Approval for Spot Solana ETF, Eighth Submitting in Rising Race – “The Defiant”

Digital-asset supervisor CoinShares submitted an S-1…

June 16, 2025

Britney Spears Exhibits Off Good-looking Son Jayden: He is So Tall!!

Studying Time: 3 minutes Britney Spears…

June 16, 2025

Trump household’s newest grift is coming on your cellphone

The Trump household’s newest enterprise enterprise…

June 16, 2025

You Might Also Like

5 Questions for YouTuber Omar Parker, Director of The Prince, the Sister & the Serpent
Uncategorized

5 Questions for YouTuber Omar Parker, Director of The Prince, the Sister & the Serpent

Inteview By | Eric ThompsonJournalist @ Enspirers News Network. Omar Parker has spent the last decade building a reputation as…

6 Min Read
Camden Francis: Building a Legacy of Innovation and Compassion
Uncategorized

Camden Francis: Building a Legacy of Innovation and Compassion

Introduction In an era where rapid technological advancements and societal challenges dominate, Camden Francis shines as a unique blend of…

7 Min Read
Edouard Patrick Junior Onana: Pioneering Document Security with an Unforgeable Stamp
TrendingUncategorized

Edouard Patrick Junior Onana: Pioneering Document Security with an Unforgeable Stamp

Edouard Patrick Junior Onana has spearheaded the creation of the world's first unforgeable stamp, marking a groundbreaking move to enhance…

4 Min Read
Emerging tech company ProductScope AI share details of how their Generative AI tools empower small E-commerce businesses
Uncategorized

Emerging tech company ProductScope AI share details of how their Generative AI tools empower small E-commerce businesses

ProductScopeAI hopes to solve the industry-wide problem of small businesses struggling to achieve high-quality product photos and fully optimizing their…

4 Min Read
The Texas Reporter

About Us

Welcome to The Texas Reporter, a newspaper based in Houston, Texas that covers a wide range of topics for our readers. At The Texas Reporter, we are dedicated to providing our readers with the latest news and information from around the world, with a focus on issues that are important to the people of Texas.

Company

  • About Us
  • Newsroom Policies & Standards
  • Diversity & Inclusion
  • Careers
  • Media & Community Relations
  • WP Creative Group
  • Accessibility Statement

Contact Us

  • Contact Us
  • Contact Customer Care
  • Advertise
  • Licensing & Syndication
  • Request a Correction
  • Contact the Newsroom
  • Send a News Tip
  • Report a Vulnerability

Term of Use

  • Digital Products Terms of Sale
  • Terms of Service
  • Privacy Policy
  • Cookie Settings
  • Submissions & Discussion Policy
  • RSS Terms of Service
  • Ad Choices

© The Texas Reporter. All Rights Reserved.

Welcome Back!

Sign in to your account

Lost your password?