先看一下 shadow 紀錄的帳密

cat /etc/shadow

然後會看到像這樣的內容

username:$1$TrOIigLp$b0q/YK8aTsfpKZ40y7obu1:15020:0:99999:7:::

$1 指的是密碼是用 MD5 hash

$TrOIigLp 指的是加密用的 salt

$b0q/YK8aTsfpKZ40y7obu1 指的是密碼 MD5 hash 後的值

知道這些後就可以用 openssl 來驗證密碼

openssl passwd -1 -salt TrOIigLp

這邊示範輸入密碼 "username" 得出跟 shadow 一樣的內容就表示密碼一樣

$1$TrOIigLp$b0q/YK8aTsfpKZ40y7obu1

 

 

ref:

https://www.cyberciti.biz/faq/where-are-the-passwords-of-the-users-located-in-linux/

https://stackoverflow.com/questions/18035093/given-a-linux-username-and-a-password-how-can-i-test-if-it-is-a-valid-account

arrow
arrow
    全站熱搜

    JohnDX 發表在 痞客邦 留言(0) 人氣()