Skip to content

Commit 96c2eea

Browse files
Update Commands.sh
1 parent bbd6e63 commit 96c2eea

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

DFIR/Digital Forensics/Linux/Commands.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,54 @@ cd /etc/systemd/system # Check for any sus initialization services
7676
select username, directory from users; # Look for any backdoor accounts
7777
cut -d : -f1 /etc/passwd # List down names from /etc/passwd
7878

79+
# LOG INVESTIGATION
80+
dmesg # Kernel Logs: /var/log/dmesg
81+
sudo dmesg -T | grep 'custom_kernel'
82+
sudo tail -f /var/log/auth.log
83+
grep 'Accepted password' /var/log/auth.log # Successful Authentication Logs
84+
grep 'sudo' /var/log/auth.log # Tracking actions with elevate privileges
85+
grep 'CRON' /var/log/syslog # Cron job executions
86+
grep 'kernel' /var/log/syslog # Kernel related messages
87+
/var/log/btmp # Failed login attempts
88+
/var/log/wtmp # Successful login attempts
89+
/etc/rsyslog.d/50-default.conf # Default syslog config file, Controls how messages are logged
90+
journalctl
91+
/etc/systemd/journald.conf # JournalCTL conf
92+
sudo grep -i "failure" /var/log/auth.log # Failed login attempts
93+
sudo grep -i "session opened" /var/log/auth.log # Sessions opened
94+
sudo awk '/2024-06-04 15:30:00/,/2024-06-05 15:29:59/' /var/log/auth.log # To filter auth logs by a specific date and time range, we can use awk
95+
sudo grep "$(date --date='2 hours ago' '+%b %e %H:')" /var/log/auth.log # To filter entries from the last few hours, we can use tail in combination with grep and date
96+
/var/log/apache2/access.log # Apache access logs
97+
/var/log/apache2/error.log # Apache Error logs
98+
/etc/apache2/apache2.conf # Apache log config file
99+
grep "10.10.24.106" /var/log/apache2/access.log* # Filtering for access requests from a specific host
100+
grep "404" /var/log/apache2/access.log* # Find any 404 Errors
101+
grep "error" /var/log/apache2/error.log* # Find server errors
102+
awk '{print $1}' /var/log/apache2/access.log* | sort | uniq -c | sort -nr # Counting requests from hosts
103+
awk '{print $9}' /var/log/apache2/access.log* | sort | uniq -c | sort -nr # Summarize http status codes from logs
104+
105+
106+
# Auditd
107+
/etc/audit/audit.rules # Auditd rules conf file
108+
sudo auditctl -a always,exit -F arch=b64 -S execve -k execve_syscalls # logs every program execution through the execve system call on a 64-bit architecture (arch=b64) and tags these events with the key execve_syscall
109+
sudo auditctl -w /etc/passwd -p wra -k users # Watches the /etc/passwd file for write, read, and change attributes and tag it as 'users'
110+
/var/log/audit/audit.log # Audit logs file
111+
sudo ausearch -k users # Searching for logs with the key we associated our audit logs with in our auditd rules
112+
sudo ausearch -k execve_syscalls
113+
sudo ausearch -k users | aureport -f user-logs # Get a report of the logs
114+
115+
# JOURNALCTL
116+
journalctl -f # Follow the journal and show new entries as they are added
117+
journalctl -k # Show messages from a specific boot.
118+
journalctl -u apache.service # Filter messages by a specific unit.
119+
journalctl -p err # filter messages by priority
120+
journalctl -S "2021-05-24 14:08:01" # Show messages since a specific time.
121+
journalctl -U "2021-05-24 15:46:01" # Show messages until a specific time.
122+
journalctl -r # Reverse the output, showing the newest entries first.
123+
journalctl -n 20 # Limit the number of shown lines.
124+
journalctl --no-pager # Do not pipe the output into a pager.
125+
126+
127+
79128

80129

0 commit comments

Comments
 (0)