Question

Background

In C, it's very important to be careful when allocating memory, copying data between buffers, and

working with files. In this lab, we will explore how to manage data in files, and also how to use

struct to group relevant data.

In project01, the C program tried to find a plaintext password for the given hash. However, hashing

30,000 different passwords for every input is highly redundant and inefficient. Most password crackers

hash the passwords once and store the pair (hash, password) in a Dictionary file and use it for future

cracking, thus called Dictionary Attack.

In lab03, you will develop a C program: lab03.c that creates a dictionary file from 10,000 given

passwords, their leet versions, and the trailing-1 versions, and uses this dictionary file to find a

password that matches a given hash.

Requirements

1. You will develop a C program named lab03 which

1. check if dictionary file exists. if not,

1. create a struct that stores (password, hash) pair.

2. for each password among 10,000 given passwords, create three pairs of information

(password, its hash), (the leet version of the password, its hash), and (the trailing-1 version

of the password, its hash).

3. writes all pairs out to a file named "dictionary".

2. for the hash given as a command-line argument, find the corresponding password in the

dictionary.

2. Each entry in dictionary will have a password (at most 64 chars and a NULL) and hash (at most 64

chars and a NULL), and you will keep those in one or more C struct. These entries will be written

as a struct and read as a struct.

3. You will use the C file management functions to open, write, and close a file

4. You will handle error conditions exactly as shown in the example output

5. You will provide a Makefile and test your project with the grade script

Given

1. C file management functions demo in lecture

2. Any code from project01

Example Output

$ ./lab03

dictionary built

Question image 1