-
Notifications
You must be signed in to change notification settings - Fork 1
/
cracker.h
92 lines (73 loc) · 2.35 KB
/
cracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef __CRACKER_H__
#define __CRACKER_H__
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/wait.h>
#include "bounded_buffer.h"
#include "file_reader.h"
#define SEM_FULL "semFull"
#define SEM_EMPTY "semEmpty"
#define BB_KEY 5678
#define PARAMS_KEY 1234
struct params
{
buffer* buf;
char* dictionary;
char* zipfile;
bool found;
sem_t* empty;
sem_t* full;
};
typedef struct params params;
/*
* Fills the buffer with words from dictionary
* @param : arg the struct containing the struct buffer and the filename of the dict.
*/
void* fill_buffer(void* arg);
/*
* Starts cracking the password with words from the bounded buffer
* @param: arg : a struct contining the buffer and the filename to crack
*/
void* crack_password(void* arg);
/*
* Create nb_threads threads and starts the crack routine
* @params nb_threads: the number of threads to be created
* @params p : params containing the buffer and the filename of the file to crakc(see params declaration on top of file)
*/
void create_threads(unsigned int nb_threads, char* file_to_crack, char* dictionary_file);
/*
* Create nb_process process and starts the crack routine
* @params nb_process: the number of process to be created
* @params p : params containing the buffer and the filename of the file to crack (see params declaration on top of file)
*/
void create_process(unsigned int nb_process, char* file_to_crack, char* dictionary_file);
/*
* Starts the crack by creating process or threads (tp=='t' for threads ana 'p' for process)
* @param tp: a character that determine if we use threads (t) or process(p). if other value is entered, threads will be used
* @param nb_pt: the number of threads or process to use, tp must be >0
* @param file_to_crack: the path to the zip file to crack
* @param dictionary_file: the path to the dictionary to use
*/
void start_cracking(char tp, unsigned int nb_pt, char* file_to_crack, char* dictionary_file);
/*
* Create a shared memory segment for Params.
* @return returns a pointer to this memory
*/
params* create_mem_segment(key_t key );
/*
* Returns a pointer to the shared memory of key key
*/
params* get_mem_segment(key_t key );
/*
* Frees the memory of key key
*
*/
void free_mem_segment(key_t key);
#endif