本文共 1167 字,大约阅读时间需要 3 分钟。
1、简介
shadow文件存放用户密码文件,一般存放在/etc目录下。
2、详解
/* Structure of the password file. */ struct spwd { char *sp_namp; /* Login name. */ char *sp_pwdp; /* Encrypted password. */ long int sp_lstchg; /* Date of last change. */ long int sp_min; /* Minimum number of days between changes. */ long int sp_max; /* Maximum number of days between changes. */ long int sp_warn; /* Number of days to warn user to change the password. */ long int sp_inact; /* Number of days the account may be inactive. */ long int sp_expire; /* Number of days since 1970-01-01 until account expires. */ unsigned long int sp_flag; /* Reserved. */ };
sp_namp表示账号名称 sp_pwdp表示密码,这个密文字符串格式为:$id$salt$encrypted,通过$来分割 $id用来指定使用的算法, ID | Method ─────────────────────────────────────── 1 | MD5 2a | Blowfish (not in mainline glibc; added in some Linux distributions) 5 | SHA-256 (since glibc 2.7) 6 | SHA-512 (since glibc 2.7) 例如:$1就是使用了MD5的算法 $salt 是一个最多16个字符的随机生成的字符串,增加破解难度 $encrypted 就是通过MD5和盐算出来的密文了 sp_lstchg表示最近更改密码的日期(from 1974-1-1) sp_min表示密码不可更改的天数 sp_max表示密码需要重新更改的天数 sp_warn表示密码更改期限前的警告日期 sp_inact表示密码过期的宽限时间 sp_expire表示账号失效时间 sp_flag表示保留
参考文献:http://blog.csdn.net/ouyang_peng/article/details/8732644