#!/bin/bash
set +e
L=$HOME/new_cve.log; : > "$L"
E(){ echo "$@" | tee -a "$L"; }
S(){ echo; echo "═══ $* ═══" | tee -a "$L"; }

S "1. Copy Fail (CVE-2026-31431) prerequisites"
lsmod 2>/dev/null | grep -i algif
ls /lib/modules/$(uname -r)/kernel/crypto/algif_aead.ko 2>&1
grep -i "CONFIG_CRYPTO_USER_API_AEAD" /boot/config-$(uname -r) 2>/dev/null
modinfo algif_aead 2>&1 | head -3

S "2. CAN BCM (CVE-2026-17523, CVE-2026-72120)"
lsmod 2>/dev/null | grep -i bcm
ls -la /lib/modules/$(uname -r)/kernel/net/can/can-bcm.ko 2>&1
cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null
cat /proc/sys/user/max_user_namespaces 2>/dev/null

S "3. kernel version + patch status"
uname -r
cat /proc/version
dpkg -l | grep -E "linux-image" | grep "^ii"

S "4. pgAdmin 4.16 version + route probe"
/usr/lib/postgresql/9.5/bin/psql --version 2>/dev/null
curl -sI "http://127.0.0.1:5050/browser/constraints/nodes/1/1/1/1/1" 2>/dev/null | head -10
curl -sI "http://127.0.0.1:5050/login" 2>/dev/null | head -5

S "5. nginx SSI + AIO config"
nginx -v 2>&1
nginx -T 2>/dev/null | grep -E "ssi|aio" | head -10

S "6. PostgreSQL 9.5.19 refint CVE check"
export PGPASSWORD=649970
/usr/lib/postgresql/9.5/bin/psql -h 127.0.0.1 -p 5432 -U myfifasalon -d myfifasalon -tAc "SELECT version();" 2>&1
/usr/lib/postgresql/9.5/bin/psql -h 127.0.0.1 -p 5432 -U myfifasalon -d myfifasalon -tAc "SELECT count(*) FROM pg_proc WHERE proname='refint';" 2>&1

S "7. Modern LPE family checks"
# Check for direct LPE possibilities
ls -la /proc/sys/kernel/yama/ptrace_scope 2>&1
cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null
cat /proc/sys/vm/unprivileged_userfaultfd 2>/dev/null

S "8. آخر kernel تحديث متاح"
apt list --installed 2>/dev/null | grep linux-image | head -10

S "DONE"
wc -l "$L"
