Skip to content

Commit 7467514

Browse files
authored
Merge pull request #1601 from HackTricks-wiki/research_update_src_linux-hardening_useful-linux-commands_20251125_013852
Research Update Enhanced src/linux-hardening/useful-linux-co...
2 parents ea9955f + e419834 commit 7467514

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/linux-hardening/useful-linux-commands.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,52 @@ iptables -P FORWARD ACCEPT
307307
iptables -P OUTPUT ACCEPT
308308
```
309309
310+
## eBPF Telemetry & Rootkit Hunting
311+
312+
Modern rootkits (TripleCross, BPFDoor variants, etc.) increasingly persist as hidden eBPF programs. Baseline your fleet with `bpftool`/`eBPFmon` so you can spot unsigned programs, unexpected cgroup hooks, or malicious map contents before detaching them.
313+
314+
```bash
315+
#Enumerate all eBPF programs, attach points, owning PIDs and map IDs
316+
sudo bpftool prog
317+
318+
#Inspect suspicious bytecode + helper calls (replace 835 with the target program id)
319+
sudo bpftool prog dump xlated id 835 | less
320+
321+
#List and dump program maps to reveal covert sockets/credentials (replace 104 accordingly)
322+
sudo bpftool map show id 104
323+
sudo bpftool map dump id 104 | hexdump -C
324+
325+
#Verify kernel feature support before loading/patching custom probes
326+
sudo bpftool feature probe | less
327+
328+
#TUI wrapper that tracks program/map diffs in real time (wraps bpftool perf/net output)
329+
sudo ebpfmon
330+
```
331+
332+
Correlate the bpftool output with expected NIC/cgroup attachments; a sudden `xdp` or `kprobe` program owned by an unapproved PID is a strong indicator of an injected eBPF payload.
333+
334+
## Journald Incident Triage
335+
336+
systemd-journald keeps structured metadata, so you can pivot by boot, severity, unit, or UID without touching `/var/log/*`. Combine filters with relative timestamps to isolate attack windows or prove log tampering quickly.
337+
338+
```bash
339+
journalctl --list-boots #Enumerate boot IDs with timestamps
340+
journalctl -b -1 -p err -o short-iso #Previous boot only, severity >= err
341+
journalctl -u nginx.service --since="2025-06-01 01:00" --until="2025-06-01 02:00"
342+
journalctl -u ssh.service -f | grep "Failed password" #Live brute-force monitoring
343+
journalctl _UID=0 --output=json-pretty --since "1 hour ago"
344+
journalctl --disk-usage #Quickly show journal size
345+
sudo journalctl --vacuum-size=1G --vacuum-time=7days #Trim only after taking evidence
346+
journalctl --no-pager --since="2025-06-01" --until="2025-06-10" > system_logs_2025-06-01_to_06-10.log
347+
```
348+
349+
Add `--grep 'Invalid user' --case-sensitive` or `-k` (kernel ring buffer only) when you need tighter filters, and remember `_PID`, `_SYSTEMD_UNIT`, `_HOSTNAME`, and `_TRANSPORT` selectors stack together for multi-tenant hunts.
350+
351+
## References
352+
353+
- [eBPFmon: A new tool for exploring and interacting with eBPF applications](https://redcanary.com/blog/linux-security/ebpfmon/)
354+
- [How to use the journalctl command to view Linux logs](https://www.hostinger.com/tutorials/journalctl-command)
355+
310356
{{#include ../banners/hacktricks-training.md}}
311357
312358

0 commit comments

Comments
 (0)