Linux Forensics / Investigation
Securing binaries
- Trusted binaries should be in
/bin,/sbin, and/usr/bin- Anything else should be a red flag
export PATH=/mnt/usb/bin:/mnt/usb/sbinexport LD_LIBRARY_PATH=/mnt/usb/lib:/mnt/usb/lib64debsums-e --configconfig files-c --changedonly output changed files
whichwhere is the command/binary located?fileCheck the binaries and ensure they are not scripts
Alias
aliascheck if any commands have been aliasedalias >> aliases.txt && cat aliases.txtA bad actor could theoretically alias ANYTHING to
rm -rf /. This should realistically be the first thing you run. It would also be a good idea to use>>as mentioned for future investigation possibilites~/.bashrcoften contains aliases. logging in will reset all aliases defined in .bashrcunalias --allis a quick and dirty temporary solution to aliases.
Forensics
ls -lmtime (modify timestamp)ls -lcctime (change timestamp) metadeta/filename/permissionsls -laatime (access timestamp)
Volatility
Extractors
- LiME (Linux Memory Extractor) creates .dmp
- fmem
- avml
- memdump
- coredump
- process specific
Steps
python3 vol.py -f [file] bannergets the uname of Linux- Create symbol table (vol3) using dwarf2json if versions match or use https://isf-server.techanarchy.net/
- Move isf (.json) to
volatility3/symbolsfolder
- Move isf (.json) to
Symbols
- Linux.pslist process list
- linux.sockstat network list
- linux.bash bash history
- linux.pstree process tree
- linux.lsof
- linux.vmayarascan find malware signatures
User config
Config files
/etc/passwdcat /etc/passwd | cut -d: -f1,3 | grep ':0$'
/etc/group
Groups
/etc/groupgroups [USER]getent group admgetent group 27
Process snooping
lsof-iNetwork connections-Pdisplay port numbers-nshow ips instead of resolving hostnames-pPID
Network
osqueryiSELECT pid, fd, socket, local_address, remote_address FROM process_open_sockets WHERE pid = 267490;
iptable,ufw- Check the firewall
Processes
- ps
pstree [PID]-plist PID-slist child processes parents
top-d [seconds]refresh rate-cdisplay full command paths-u [user]only show a specific user's processes
whologged in users
Log Analysis
grep
grep [SEARCH TERM] file.txt
wc
- -c --bytes
- -m --chars
- -l --lines (newlines)
- -w --words
File Snooping
Shells
echo $SHELLcat /etc/shellschsh -s /usr/bin/zshhistorylast/lastbfind the last logins or bad logins
Find
find / -type f -executable 2> /dev/null
Good files to check
~/.bash_history- run
historyin terminal
- run
cat /var/log/auth.log | grep useradd/etc/systemd/system/var/log/syslog
System stuff
Systemd systemctl
/etc/systemd/system- sysd is a very legacy version of systemd
Cron
/var/spool/cron/crontabs/[username]/etc/crontabmain cron file/etc/cron*/Contains system cron jobs
Other persistance
~/.config/autostart//etc/init.d
Disks
df -hT- View usage and types of disks
dd if=<source> of=<destination> bs=<block_size> status=progresssudo dd if=/dev/sdb1 of=/path/to/disk_image.img bs=4M status=progress
mount -o ro [device] [destination]- Read only mount