Cracking ZIP File S Password
Cracking ZIP File S Password
64.2 CrackIt
64.2.1 Logic
The following code is very popular among crackers. Let’s call it as CrackIt utility.
CrackIt uses dictionary attack technique. So you need to provide a Words list file that is
preloaded with all the passwords you suspect. For example, if you suspect that the password
would be any one of the words “KING”, ”QUEEN”, “JACK”, you have to load the Words list
file as:
KING
QUEEN
JACK
The CrackIt would first take the “KING” and it would check whether it is the right
password or not. If not, it would check “QUEEN” and if it is the right password, it would print it.
The validation of password is done with dictionary attack.
The encryption algorithm uses case sensitive passwords. So you have to load the Words
list file with enough words list. A clever idea is to use brute force for preparing words list that are
to be used in Words list file.
CrackIt has few drawbacks:
1. Success of the cracking depends upon the Words list file
2. Dictionary attack won’t be faster if you use large Word list
A to Z of C 611
#include <stdio.h>
int extra_field_length;
char file_name[1024];
int file_name_length;
int file_num;
int flags;
unsigned char header[3][12];
unsigned long key[3];
int num_enciphered;
char password[255];
char *password_ptr;
long signature;
unsigned char target[3];
int tem;
if ( argc < 3 )
{
printf( "Syntax: CRACKIT <zipfile> <wordslistfile> \a\n " );
exit(1);
}
/* Check for file errors....*/
if ( (zip_fp=fopen(argv[1], "rb")) == NULL )
{
printf( "Error: Couldn't open %s \a\n", argv[1] );
exit(1);
}
if ( (wordlist_fp=fopen(argv[2], "r") ) == NULL )
{
printf( "Error: Couldn't open %s \a\n", argv[2] );
exit(1);
}
/* <- checked ok */
if (num_enciphered == 0)
printf( "Nothing is enciphered in %s \n", argv[1] );
else if (num_enciphered < 3)
{
printf( "Less than 3 files are enciphered in %s \a\n",
argv[1] );
printf( "CRACKIT requires atleast 3 enciphered files \n" );
}
else /* Crack using wordlist....*/
{
found = FALSE;
byte_num = 0;
while (fgets(&password[0],255,wordlist_fp) != NULL)
{
password[strlen(&password[0])-1] = '\0';
tried_all = TRUE;
file_num = 0;
while (tried_all && (file_num<num_enciphered))
{
key[0] = 305419896L;
A to Z of C 615
key[1] = 591751049L;
key[2] = 878082192L;
password_ptr = &password[0];
while (*password_ptr != '\0')
{
byte = *(password_ptr++);
key[0] = CRC32( key[0], byte );
key[1] += key[0] & 0xff;
key[1] = key[1]*134775813L + 1;
key[2] = CRC32( key[2], key[1] >> 24);
}
for ( byte_num=0; byte_num < 12; ++byte_num )
{
tem = key[2] | 2;
byte = header[file_num][byte_num]
^(((tem*(tem^1)) >> 8) & 0xff);
key[0] = CRC32( key[0], byte );
key[1] += key[0] & 0xff;
key[1] = key[1]*134775813L + 1;
key[2] = CRC32( key[2], key[1] >> 24 );
}
if ( byte == target[file_num] )
++file_num;
else
tried_all = FALSE;
}
if ( tried_all )
{
if (!found)
{
found = TRUE;
printf( "Passwords migh be: \n" );
}
printf( "\t %s \n", &password[0] );
}
}
if (!found)
printf( "%s don't hold the right Password \a\n",
argv[2] );
fclose(wordlist_fp);
}
return(0);
} /*--main( )------*/