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:::

format

<username>:<encrypt_passwd>:....

<encrypt_passwd>:

$(type_code)$salt$<encrypt_read_passwd>

this example the whole password is $6$dgsEcbMj$rjqoKIiLcvY2XZv1hYJieV2a91W0LH0DsctmKjBC2bmWT2u2SLj4eI0g33UMOobjvpp/QJWZHvJwIWgjJm//a/ one can use salt=’$(type_code)$salt$’ salt is $6$dgsEcbMj$ if the real passwd is ‘bigdata’

crypt("bigdata","$6$dgsEcbMj$")

to get encrypt_encrypt_passwd

Clone this wiki locally