global security disclosure

lincrack.c

lincrack.c
Posted Apr 20, 2000
Authored by w0rm

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.

tags | cracker
systems | linux, unix
MD5 | 4988dce5e71a1b4fae889ae0c7acce77

lincrack.c

Change Mirror Download
/*      
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);
}
}
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close