Skip to content
Snippets Groups Projects
Commit 96e7ec0d authored by ChouTatsumi's avatar ChouTatsumi
Browse files

pure lowercase pwd6 find

parent fe60ed1f
Branches
No related tags found
No related merge requests found
......@@ -26,10 +26,12 @@
#define ASCII_LOWERCASE_TO 122
// methods reference
void check_guess(char guess[], BYTE pwd[PWD_NUMBERS][SHA256_BLOCK_SIZE],
int checked[]);
void check_n_guess(char guess[], BYTE pwd[][SHA256_BLOCK_SIZE], int n,
int checked[]);
int check_pwd4_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int checked[]);
int check_pwd6_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int checked[]);
int check_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int pwdn, int checked[]);
void int_array_init(int array[], int n);
int main(int argc, char** argv) {
......@@ -74,7 +76,7 @@ int main(int argc, char** argv) {
// create guess and check it
SHA256_CTX ctx;
BYTE buf[SHA256_BLOCK_SIZE];
BYTE hash[SHA256_BLOCK_SIZE];
int checked[PWD_NUMBERS];
int_array_init(checked, PWD4_NUMBERS);
......@@ -84,6 +86,7 @@ int main(int argc, char** argv) {
// violent crack PWD4
char pw4guess[PWD4_LEN + 1];
pw4guess[PWD4_LEN] = '\0';
int find;
int first, second, third, fourth;
for (first = ASCII_FROM; first <= ASCII_TO; first++) {
......@@ -96,16 +99,10 @@ int main(int argc, char** argv) {
pw4guess[3] = fourth;
// generate hash and check
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)pw4guess, PWD4_LEN);
sha256_final(&ctx, buf);
for (i = 0; i < PWD4_NUMBERS; i++) {
if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", pw4guess, i + 1);
fprintf(fp, "%s %d\n", pw4guess, i + 1);
}
find = check_pwd4_guess(&ctx, hash, pw4guess, pwd, checked);
if (find){
printf("%s %d\n", pw4guess, find);
fprintf(fp, "%s %d\n", pw4guess, find);
}
}}}}
......@@ -132,18 +129,10 @@ int main(int argc, char** argv) {
pw6guess[5] = sixth;
// generate hash and check
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN);
sha256_final(&ctx, buf);
for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) {
if (!checked[i] &&
!memcmp(pwd[i], buf,
SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", pw6guess, i + 1);
fprintf(fp, "%s %d\n", pw6guess, i + 1);
}
find = check_pwd6_guess(&ctx, hash, pw6guess, pwd, checked);
if (find) {
printf("%s %d\n", pw6guess, find);
fprintf(fp, "%s %d\n", pw6guess, find);
}
}}}}}}
......@@ -165,32 +154,19 @@ int main(int argc, char** argv) {
pw6guess[5] = sixth;
// generate hash and check
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN);
sha256_final(&ctx, buf);
for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) {
if (!checked[i] &&
!memcmp(pwd[i], buf,
SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", pw6guess, i + 1);
fprintf(fp, "%s %d\n", pw6guess, i + 1);
}
}
find = check_pwd6_guess(&ctx, hash, pw6guess, pwd, checked);
if (find) {
printf("%s %d\n", pw6guess, find);
fprintf(fp, "%s %d\n", pw6guess, find);
// continue find similar password
// first lettle capitalize
pw6guess[0] = first - ASCII_LOWERCASE_FROM + ASCII_UPPERCASE_FROM;
// generate hash and check
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN);
sha256_final(&ctx, buf);
for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) {
if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", pw6guess, i + 1);
fprintf(fp, "%s %d\n", pw6guess, i + 1);
find = check_pwd6_guess(&ctx, hash, pw6guess, pwd, checked);
if (find) {
printf("%s %d\n", pw6guess, find);
fprintf(fp, "%s %d\n", pw6guess, find);
}
}
}}}}}}
......@@ -242,27 +218,23 @@ int main(int argc, char** argv) {
wfp = fopen(OUTPUT_FILENAME, "w");
char input[INPUTSIZE];
SHA256_CTX ctx;
BYTE buf[SHA256_BLOCK_SIZE];
BYTE hash[SHA256_BLOCK_SIZE];
// create flag arrays to avoid repeat check
int checked[pwdcount];
int_array_init(checked, pwdcount);
int find;
while (fgets(input, INPUTSIZE, fp) != NULL) {
// get rid of \n for buffer
buffer[strlen(input) - 1] = '\0';
input[strlen(input) - 1] = '\0';
// generate hash and check
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)input, 4);
sha256_final(&ctx, buf);
find = check_guess(&ctx, hash, input, pwd, pwdcount, checked);
for (int i = 0; i < pwdcount; i++) {
if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", input, i + 1);
fprintf(wfp, "%s %d\n", input, i + 1);
}
if (find) {
printf("%s %d\n", input, find);
fprintf(wfp, "%s %d\n", input, find);
}
}
......@@ -273,35 +245,54 @@ int main(int argc, char** argv) {
return 0;
}
void check_guess(char guess[], BYTE pwd[PWD_NUMBERS][SHA256_BLOCK_SIZE],
int checked[]) {
SHA256_CTX ctx;
BYTE buf[SHA256_BLOCK_SIZE];
size_t guess_len = strlen(guess);
int i;
sha256_init(&ctx);
sha256_update(&ctx, (BYTE*)guess, guess_len);
sha256_final(&ctx, buf);
int check_pwd4_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int checked[]) {
sha256_init(ctx);
sha256_update(ctx, (BYTE*)guess, PWD4_LEN);
sha256_final(ctx, hash);
if (guess_len == 4) {
int i;
for (i = 0; i < PWD4_NUMBERS; i++) {
if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) {
if (!checked[i] && !memcmp(pwd[i], hash, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", guess, i + 1);
return i + 1;
}
}
} else if (guess_len == 6) {
return 0;
}
int check_pwd6_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int checked[]) {
sha256_init(ctx);
sha256_update(ctx, (BYTE*)guess, PWD6_LEN);
sha256_final(ctx, hash);
int i;
for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) {
if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) {
if (!checked[i] && !memcmp(pwd[i], hash, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
printf("%s %d\n", guess, i + 1);
return i + 1;
}
}
} else {
fprintf(stderr, "ERROR, undefine guess length\n");
exit(0);
return 0;
}
int check_guess(SHA256_CTX* ctx, BYTE hash[], char guess[],
BYTE pwd[][SHA256_BLOCK_SIZE], int pwdn, int checked[]) {
sha256_init(ctx);
sha256_update(ctx, (BYTE*)guess, PWD6_LEN);
sha256_final(ctx, hash);
int i;
for (i = 0; i < pwdn; i++) {
if (!checked[i] && !memcmp(pwd[i], hash, SHA256_BLOCK_SIZE)) {
checked[i] = 1;
return i + 1;
}
}
return 0;
}
void int_array_init(int array[], int n) {
......
......@@ -8,4 +8,12 @@ sp*t 1
spOt 4
spot 5
xunz 8
aeaiig 11
eunodz 15
gabrie 22
howhmr 14
millie 27
sangre 13
terenc 16
Terenc 25
waterf 30
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment