Exploit databaseDownload repository ZIP
GH-5879bc97b40d5c8abf93d600a8040aab
dinosn/pack2theroot-lab
Sources for CVE-2026-41651
9 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files6
dinosn/pack2theroot-labRevision f85796021a3a
- ↑..Parent directory
- apply-polkit-mitigation.sh
- check-preconditions.sh
- check-version.sh
- compare-env.sh
- exploit-check.sh
- monitor-ioc.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scripts/check-preconditions.sh
Shell · 4,450 bytes#!/usr/bin/env bash
# Pack2TheRoot lab — pre-condition check.
#
# Verifies that the current environment matches the attacker precondition
# the advisory assumes: an unprivileged local user on a host running a
# reachable PackageKit daemon under polkit.
#
# Output is intentionally designed to be diff-friendly so that
# compare-env.sh can pair the vulnerable and patched results.
set -u
pass() { printf ' [PASS] %s\n' "$*"; }
fail() { printf ' [FAIL] %s\n' "$*"; }
info() { printf ' [INFO] %s\n' "$*"; }
host_name() {
if command -v hostname >/dev/null 2>&1; then hostname
elif [[ -r /etc/hostname ]]; then cat /etc/hostname
else uname -n
fi
}
printf 'Pack2TheRoot (CVE-2026-41651) — pre-condition check\n'
printf ' user: %s (uid=%s, groups=%s)\n' \
"$(id -un)" "$(id -u)" "$(id -Gn | tr ' ' ',')"
printf ' hostname: %s\n' "$(host_name)"
printf '\n'
# ---------------------------------------------------------------------------
# 1. unprivileged?
# ---------------------------------------------------------------------------
if [[ "$(id -u)" -eq 0 ]]; then
fail "running as root — the advisory assumes an unprivileged attacker"
else
pass "running as non-root user"
fi
if id -Gn | grep -qwE 'wheel|sudo|admin'; then
info "user is in an admin group — elevated already, this isn't the target posture"
else
pass "user is NOT in wheel/sudo/admin"
fi
# ---------------------------------------------------------------------------
# 2. PackageKit reachable?
# ---------------------------------------------------------------------------
if command -v pkcon >/dev/null 2>&1; then
pass "pkcon present at $(command -v pkcon)"
else
fail "pkcon not installed"
fi
if command -v gdbus >/dev/null 2>&1; then
if gdbus introspect --system \
--dest org.freedesktop.PackageKit \
--object-path /org/freedesktop/PackageKit >/dev/null 2>&1; then
pass "PackageKit D-Bus service reachable on the system bus"
else
fail "PackageKit D-Bus service not reachable — daemon may not be running"
fi
else
info "gdbus missing; skipping D-Bus reachability probe"
fi
# ---------------------------------------------------------------------------
# 3. polkit rules referencing PackageKit
# ---------------------------------------------------------------------------
POLKIT_HITS=0
for d in /usr/share/polkit-1/actions /etc/polkit-1/rules.d /usr/share/polkit-1/rules.d; do
[[ -d "$d" ]] || continue
hits=$(grep -rl 'org.freedesktop.packagekit' "$d" 2>/dev/null | wc -l | tr -d ' ')
if [[ "${hits}" -gt 0 ]]; then
POLKIT_HITS=$((POLKIT_HITS + hits))
info "$d : ${hits} file(s) reference org.freedesktop.packagekit"
fi
done
if [[ "${POLKIT_HITS}" -gt 0 ]]; then
pass "polkit has PackageKit action definitions (${POLKIT_HITS} files)"
else
fail "no polkit files reference PackageKit — not the advertised config"
fi
# ---------------------------------------------------------------------------
# 4. pkcon dry-run (safe — no actual install)
# ---------------------------------------------------------------------------
if command -v pkcon >/dev/null 2>&1; then
# `pkcon resolve` is a read-only lookup; it exercises the same D-Bus
# surface as install but cannot mutate the system. If it returns a
# structured response without prompting for auth, the non-interactive
# policy path is active.
out=$(timeout 10 pkcon --noninteractive resolve bash 2>&1 || true)
if printf '%s' "$out" | grep -qi 'authent'; then
info "pkcon resolve requires authentication — normal polkit behaviour"
elif printf '%s' "$out" | grep -qiE 'finished|installed|available'; then
pass "pkcon resolve ran without an auth prompt (matches advisory observation)"
else
info "pkcon resolve output inconclusive:"
printf '%s\n' "$out" | sed 's/^/ /'
fi
fi
# ---------------------------------------------------------------------------
# 5. cockpit present? (amplifies the attack surface per the advisory)
# ---------------------------------------------------------------------------
if command -v cockpit-bridge >/dev/null 2>&1 || systemctl is-enabled cockpit.socket >/dev/null 2>&1; then
info "cockpit is present — per the advisory, this amplifies exposure"
else
info "cockpit not detected"
fi
printf '\nDone. See docs/threat-model.md for how these map to the advisory.\n'