-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel_omp.cpp
More file actions
64 lines (53 loc) · 2.1 KB
/
kernel_omp.cpp
File metadata and controls
64 lines (53 loc) · 2.1 KB
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <openssl/sha.h>
#include <time.h>
#include <math.h>
#include <omp.h>
#include "sequenziale.h"
#include "UTILS/utils.h"
int main(int argc, char** argv)
{
/* Invocazione: ./kernel_omp <password_in_chiaro> <min_len> <max_len> <file_charset> */
char* charSet, * secret_password;
int min_test_len, max_test_len;
/* --- CONTROLLO ARGOMENTI DI INVOCAZIONE --- */
if (argc != 5) {
printf("Usage: %s <password_in_chiaro> <min_len> <max_len> <file_charset> \n", argv[0]);
return 1;
}
secret_password = argv[1];
if (!safe_atoi(argv[2], &min_test_len))
{
perror("Errore nella conversione di min_test_len");
exit(1);
}
if (!safe_atoi(argv[3], &max_test_len))
{
perror("Errore nella conversione di max_test_len");
exit(1);
}
// Caricamento del charset dal file
charSet = leggiCharSet(argv[4]);
if (charSet == NULL) {
fprintf(stderr, "Errore nella lettura del CharSet.\n");
exit(1);
}
int charSetLen = strlen(charSet);
// Calcolo dell'hash target
unsigned char target_hash[SHA256_DIGEST_LENGTH];
SHA256((const unsigned char*)secret_password, strlen(secret_password), target_hash);
printf("========================================\n");
printf("%s Starting OpenMP Brute Force...\n", argv[0]);
printf("Target Password: %s\n", secret_password);
printf("Range lunghezza: %d - %d\n", min_test_len, max_test_len);
printf("Charset len: %d\n", charSetLen);
printf("========================================\n\n");
/*-----------------------------------------------------------------------------------------------------------------------------------------*/
/* TEST VERSIONE PARALLELA (OpenMP) */
/*-----------------------------------------------------------------------------------------------------------------------------------------*/
testSequenziale(target_hash, min_test_len, max_test_len, charSet);
free(charSet);
return 0;
}