📄 getshcrypt.c
字号:
#include <stdio.h> /* For printf stuff */#include <pwd.h> /* For getpwnam and passwd struct */#include <sys/types.h>#include <shadow.h> /* For getspnam and spwd struct */#include <string.h> /* For strcopy and other string stuff */#define _XOPEN_SOURCE /* For crypt */#include <unistd.h>int main( int argc, char **argv ) { if ( argc != 2 ) { fprintf( stderr, "Error: Usage: %s username\n", argv[0] ); return -1; } else { struct spwd *theShadow; char *cryptwd; char *username = strdup( argv[1] );#ifdef DEBUG printf( "Username: %s\n", username );#endif if ( (theShadow = getspnam( username )) == NULL ) { fprintf( stderr, "Error: getspnam() returned NULL\n" ); return -2; }#ifdef DEBUG printf( "Shadow Username: %s\n", theShadow->sp_namp ); printf( "Shadow Password: %s\n", theShadow->sp_pwdp );#endif printf( "%s\n", theShadow->sp_pwdp ); return 0; /* if ( (thePass = getpwnam( username )) == NULL ) { fprintf( stderr, "Error: getpwnam() returned NULL\n" ); return -3; } printf( "Username: %s\n", thePass->pw_name ); printf( "Password: %s\n", thePass->pw_passwd ); printf( "UID: %d\n", thePass->pw_uid ); printf( "GID: %d\n", thePass->pw_gid ); printf( "Gecos: %s\n", thePass->pw_gecos ); printf( "Home: %s\n", thePass->pw_dir ); printf( "Shell: %s\n", thePass->pw_shell );*/ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -