From: hackbard Date: Sat, 26 Oct 2002 13:13:09 +0000 (+0000) Subject: added support for dos files X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a38a2a82de4b94551a7f55a6d68e2c778713d4a;p=my-code%2Fget-passwd.git added support for dos files --- diff --git a/cac.c b/cac.c index 88628bc..80ee0e4 100644 --- a/cac.c +++ b/cac.c @@ -10,29 +10,52 @@ int main(int argc, char *argv[]) { - FILE *file_h; + FILE *shadow_h, *passwd_h; char temp[256]; + char temp2[30]; if(argc!=3) { - printf("usage: %s \n",argv[0]); + printf("usage: %s \n",argv[0]); return 0; } - file_h=fopen(argv[1],"r"); - if(file_h==NULL) { + shadow_h=fopen(argv[1],"r"); + if(shadow_h==NULL) { printf("error: cant open %s for reading\n",argv[1]); return 0; } else { printf("reading %s\n",argv[1]); } + passwd_h=fopen(argv[2],"r"); + if(passwd_h==NULL) { + printf("error: cant open %s for reading\n",argv[2]); + return 0; + } else { + printf("using %s as passwd library\n",argv[2]); + } - while(fgets(temp,256,file_h)) { + while(fgets(temp,256,shadow_h)) { if(strstr(temp,"root")) { /* none md5 way ... */ if(temp[4]==':') { - if(strncmp(crypt(argv[2],(temp+5)),(temp+5),13)==0) + while(fgets(temp2,30,passwd_h)) { + int mylen=strlen(temp2); + if((mylen>=1) && (temp2[mylen-1]=='\n')) { + if((mylen>=2) && (temp2[mylen-2]==0x0d)) { + mylen-=2; + temp2[mylen]=0; + printf("dosfile!\n"); + } + else + temp2[--mylen]=0; + } + if(mylen>=1) { + if(strncmp(crypt(temp2,(temp+5)),(temp+5),13)==0) { printf("succes: %s\n",argv[2]); - else printf("wrong\n"); + return 0; + } + } + } } } }