From: hackbard Date: Tue, 24 Sep 2002 21:47:10 +0000 (+0000) Subject: first version of cac.c - crypt and compare X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fget-passwd.git;a=commitdiff_plain;h=399075456ccaa76629d7148e439b43ebb7d2406d first version of cac.c - crypt and compare --- 399075456ccaa76629d7148e439b43ebb7d2406d diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..826c81a --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +#!/usr/bin/make + +CC = gcc +CFLAGS = -O2 +CPPFLAGS = -Wall +LDFLAGS = -s -lcrypt + +PREFIX = /usr + +TARGETS = cac + +all: $(TARGETS) + +install: $(TARGETS) + install -m 755 $(TARGETS) $(PREFIX)/bin + +uninstall: + cd $(PREFIX)/bin && rm -f $(TARGETS) + +clean: + rm -f $(TARGETS) *.o *~ + diff --git a/cac.c b/cac.c new file mode 100644 index 0000000..88628bc --- /dev/null +++ b/cac.c @@ -0,0 +1,40 @@ +/* cac.c - crypt and compare + * + * author: hackbard + * + */ + +#include +#include +#include + +int main(int argc, char *argv[]) { + + FILE *file_h; + char temp[256]; + + if(argc!=3) { + printf("usage: %s \n",argv[0]); + return 0; + } + + file_h=fopen(argv[1],"r"); + if(file_h==NULL) { + printf("error: cant open %s for reading\n",argv[1]); + return 0; + } else { + printf("reading %s\n",argv[1]); + } + + while(fgets(temp,256,file_h)) { + if(strstr(temp,"root")) { + /* none md5 way ... */ + if(temp[4]==':') { + if(strncmp(crypt(argv[2],(temp+5)),(temp+5),13)==0) + printf("succes: %s\n",argv[2]); + else printf("wrong\n"); + } + } + } + return 0; +}