驗證系統帳號與密碼

    檢查帳號

    MyLinuxBox root ~ > grep mandar /etc/passwd
    mandar:x:500:500:Mandar Shinde:/home/mandar:/bin/bash
    
    MyLinuxBox root ~ > id -u mandar
    500
    MyLinuxBox root ~ > echo $?
    0
    
    MyLinuxBox root ~ > grep -w mandar /etc/passwd
    mandar:x:500:500:Mandar Shinde:/home/mandar:/bin/bash
    MyLinuxBox root ~ > echo $?
    0
    

    檢查密碼

    /etc/shadow:

    mandar:$6$5H0QpwprRiJQR19Y$bXGOh7dIfOWpUb/Tuqr7yQVCqL3UkrJns9.7msfvMg4ZO/PsFC5Tbt32PXAw9qRFEBs1254aLimFeNM8YsYOv.:16431:0:99999:7:::
    mysql:!!:16550::::::
    nagios:$6$P9zn0KwR$tgfvvFWJJ5FKmoXiP5rXWOjwoEBOEoAuBi3EphRbJqqjWYvhEM2wa67L9XgQ7W591FxUNklkDIQsk4kijuhE50:16632:0:99999:7:::
    
    MyLinuxBox root ~ > grep -w mandar /etc/shadow | cut -d: -f2
    $6$5H0QpwprRiJQR19Y$bXGOh7dIfOWpUb/Tuqr7yQVCqL3UkrJns9.7msfvMg4ZOPsFC5Tbt32PXAw9qRFEBs1254aLimFeNM8YsYOv.
    

    shadow 檔案格式

    $6$5H0QpwprRiJQR19Y$bXGOh7dIfOWpUb/Tuqr7yQVCqL3UkrJns9.7msfvMg4ZO/PsFC5Tbt32PXAw9qRFEBs1254aLimFeNM8YsYOv. |1|-------2--------|-----------------------------------------3--------------------------------------------|
    

    欄位一: Hash Algorithm

    --------------------
    | 1  | MD5         |
    --------------------
    | 2  | Blowfish    |
    --------------------
    | 2a | eksBlowfish |
    --------------------
    | 5  | SHA-256     |
    --------------------
    | 6  | SHA-512     |
    --------------------
    

    欄位二: Salt Value

    欄位三: 加密字串

    密碼加密指令

    perl -e 'print crypt("<PASSWORD>","\$<HASH-ALGO>\$<SALT-VALUE>\$") . "\n"'
    

    應用範例

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core