first version of cac.c - crypt and compare
authorhackbard <hackbard>
Tue, 24 Sep 2002 21:47:10 +0000 (21:47 +0000)
committerhackbard <hackbard>
Tue, 24 Sep 2002 21:47:10 +0000 (21:47 +0000)
Makefile [new file with mode: 0644]
cac.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0000000..88628bc
--- /dev/null
+++ b/cac.c
@@ -0,0 +1,40 @@
+/* cac.c - crypt and compare 
+ *
+ * author: hackbard
+ *
+ */
+
+#include <stdio.h>
+#include <crypt.h>
+#include <string.h>
+
+int main(int argc, char *argv[]) {
+       
+       FILE *file_h;
+       char temp[256];
+
+       if(argc!=3) {
+               printf("usage: %s <shadow-file> <password>\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;
+}