Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Linux 普通使用者偽裝 root:修改 /etc/passwd UID/GID 為 0 的風險與驗證

編輯:Linux 系統常見問題解答

操作步驟 (需 root 權限)

  1. 新增使用者:useradd username
  2. 設定密碼:passwd username
  3. 編輯 /etc/passwd,將該行 UID/GID 改為 0,家目錄改為 /root,Shell 同 root:
    username:x:0:0:root:/root:/bin/bash

驗證

su - username
# 提示符變為 [root@hostname ~]#

嚴重警告:

  • 此為**極高風險**操作,系統將擁有兩個 UID 0 帳號,審計日誌無法區分真實操作者。
  • 檔案權限檢查僅看 UID,該帳號擁有完整 root 權限,繞過 sudo 稽核。
  • 安全合規環境嚴禁此配置,屬權限提升後門手法之一。
  • 正規授權請使用 sudo、su -、setuid 程式或 Capabilities (CAP_DAC_OVERRIDE 等)。

本文僅供原理教學與入侵偵測參考 (檢查 /etc/passwd 是否存在多行 UID 0),**嚴禁生產環境使用**。

Copyright © Windows教程網 All Rights Reserved