單用戶模式雖為密碼遺失時的救命稻草,卻也是實體存取攻擊者的便利後門。本文介紹透過 LILO 設定 restricted 與 password 參數,強制進入單用戶模式需輸入密碼,為系統增加關鍵防線。
linux single 或 linux 1/etc/shadow、建立後門、竊取資料/etc/lilo.conf,在 global 區段或特定 image 區段加入:
restricted
password=your_strong_password
restricted:僅在傳遞額外開機參數(如 single、1、init=/bin/bash)時要求密碼;正常開機不提示password:設定密碼明文(建議使用 mkpasswd 產生雜湊值,格式 password=$1$salt$hash)/sbin/lilo 更新開機載入器linux single 應提示 Password:GRUB 2 使用 grub-mkpasswd-pbkdf2 產生雜湊,編輯 /etc/grub.d/40_custom:
set superusers="admin"
password_pbkdf2 admin grub.pbkdf2.sha512.10000.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# 將上述加入 40_custom,執行 grub2-mkconfig -o /boot/grub2/grub.cfg
此設定保護整個 GRUB 選單編輯與命令列模式,比 LILO 更完善。
/var/log/secure、last -x 監控單用戶模式登入嘗試