Skip to content

Linux auth method

source edited this page Oct 24, 2016 · 2 revisions

access to the /etc/shadow

struct spwd * p=getspnam("username");
printf("passwd=%s\n",p->sp_spwd);

struct of the /etc/shadow

bigdata:$6$dgsEcbMj$rjqoKIiLcvY2XZv1hYJieV2a91W0LH0DsctmKjBC2bmWT2u2SLj4eI0g33UMOobjvpp/QJWZHvJwIWgjJm//a/:17008:0:99999:7::: <username>:<encrypt_passwd>:.... <encrypt_passwd>: $(type_code)$salt$<encrypt_read_passwd>

one can use salt=’$(type_code)$salt$’

crypt(input_passwd,salt)

to get encrypt_encrypt_passwd

Clone this wiki locally