global security disclosure

apc.c

apc.c
Posted Aug 17, 1999
Authored by BiffSocko

apc.c (Another Password Cracker) - Designed to brute force UNIX passwords with standard dictionary-based attack; coded in C.

tags | cracker
systems | unix
MD5 | 8c021192a77bcfbce2a3f5e838bc6402

apc.c

Change Mirror Download
/*
* BiffSocko apc.c (Another Password Cracker) 9/26/98
*
* usage: apc <passwd file> <wordlist> [outfile]
* the password file MUST be in the form of a /etc/password
* or /etc/shadow file where ":" is the delimeter and the
* password is in the second field.
* the wordlist must be one word per line.
*
* (c) 1998 BiffSocko
*
* Redistribution and use in source and binary forms, with or without
* modification, for NON COMMERCIAL USE are permitted provided that:
* (1) source code distributions retain the above copyright notice and this
* paragraph in its entirety, and (2) distributions including binary code
* include the above copyright notice and this paragraph in its entirety in
* the documentation or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include <stdio.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>

#define MAX 1024

int main (int argc, char *argv[])
{
/* define some variables */
FILE *WordList=NULL; /* wordlist file descriptor */
FILE *PassFile=NULL; /* passwd file file descriptor */
FILE *Outfile=NULL; /* Output file descriptor */
char Salt[3]; /* salt string */
char Word[ MAX]; /* the unencrypted word */
char *encrypted; /* the encrypted word */
char PassString[ MAX]; /* String from the passwd file */
char Password[ MAX]; /* the Password String */
int i=0; /* counter */
int j=0; /* counter */
int len=0; /* the lenth of word */

system("clear");
printf("\t\t apc (Another Password Cracker)\n");
printf("UNIX Password Cracker (C) All rights reserved. Copyright BiffSocko 1998\n\n");
/*
* check for usage and open the files
*/
if((argc < 3) || (argc > 4)){
fprintf(stderr, "usage: %s <passwd file> <wordlist> [output file]\n",
argv[0]);
exit( -1); /* bye looser*/
}


if(argc == 4){
if(!(Outfile=fopen(argv[3], "w+"))){
fprintf(stderr, "error opening %s to write\n", argv[3]);
exit( -1);
}
}
else
Outfile = stdout;


if(!(PassFile=fopen(argv[1], "r"))){
fprintf(stderr, "error opening %s for reading\n",argv[1]);
fclose(Outfile);
exit( -1); /* bye looser */
}

if(!(WordList=fopen(argv[2], "r"))){
fprintf(stderr, "error opening %s for reading\n");
fclose(Outfile);
fclose(PassFile);
exit( -1); /* bye looser */
}

/*
* start traversing through the passwd file
*/
while(fgets(PassString, MAX, PassFile)){
printf("working on %s", PassString);
/*
* set up variables
*/
Salt[0] = '\0';
Password[0] = '\0';
Word[0] = '\0';
i = 0;
j = 0;

/*
* get to the second field in the pass string
*/
while(PassString[i] != ':')
i++;

i++;

/*
* in case of no passwrd in the password field
* yes i know that this means users like "lp"
* but .. they got no passwds in the file anyway
*/
if((PassString[i] == ':') || (PassString[i] == '*')){
fprintf(Outfile, "%s\thas NO PASSWORD\n",PassString);
fflush(Outfile);
continue;
}

/*
* get the users password in a string
*/
while(PassString[i] != ':'){
Password[j]=PassString[i];
i++;
j++;
}

Password[j] = '\0';

Salt[0] = Password[0];
Salt[1] = Password[1];
Salt[2] = '\0';

/*
* ok, now start traversing through the
* word list and comparing
* depending on the size of your word list
* this is gonna take a while
*/
while(fgets(Word, MAX, WordList)){
len=strlen(Word);
Word[len -1] = '\0';
encrypted = (char *) crypt(Word, Salt);
if((strcmp(Password, encrypted)) == 0){
/* woo hoo got one */
fprintf(Outfile, "%s \thas %s as a password\n\n"
,PassString, Word);
fflush(Outfile);
break;
}
}

/* reset for next traversial */
rewind(WordList);
PassString[0] = '\0';
}

/* clean up & exit */
if(argc == 4)
fclose(Outfile);
fclose(WordList);
fclose(PassFile);
exit( 0);
}

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