Skip to content
Snippets Groups Projects
Commit 31ede3fb authored by aneesh's avatar aneesh
Browse files

11
parent 791b46ef
No related branches found
No related tags found
No related merge requests found
...@@ -113,7 +113,7 @@ void variations(char * word_list_file, int hashes[30][32]) { ...@@ -113,7 +113,7 @@ void variations(char * word_list_file, int hashes[30][32]) {
} }
void printRandomString1(int k) { void printRandomString1(int k) {
for (int i = 0; i < k - 1; ++i) { for (int i = 0; i < k ; ++i) {
BYTE res[6]; BYTE res[6];
for (int j = 0; j < 6; j++) for (int j = 0; j < 6; j++)
res[j] = (rand() % 59) + 65;; res[j] = (rand() % 59) + 65;;
...@@ -165,117 +165,7 @@ void bruteforce(int hashes[30][32]) { ...@@ -165,117 +165,7 @@ void bruteforce(int hashes[30][32]) {
} }
} }
} }
// C program to print all permutations with duplicates allowed
/* Function to swap values at two pointers */
void swap(char * x, char * y) {
char temp;
temp = * x;
* x = * y;
* y = temp;
}
/* Function to print permutations of string
This function takes three parameters:
1. String
2. Starting index of the string
3. Ending index of the string. */
void permute(char * a, int l, int r, int hashes[30][32], int status) {
SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE];
bool cracked = true;
int count1 = 0;
char word[30];
int i;
if (l == r) {
if (status != 2) {
BYTE n[6];
for (int k = 0; k < 6; ++k) {
n[k] = a[k];
}
n[6] = '\0';
sha256_init( & ctx);
sha256_update( & ctx, n, sizeof(n));
sha256_final( & ctx, buffer);
for (int j = 10; j < 30; j++) {
cracked = true;
for (int i = 0; i < 32; i++) {
if (buffer[i] != hashes[j][i]) {
cracked = false;
break;
}
}
if (cracked == true && exist[j + 1] != 1) {
ctx.data[6] = '\0';
exist[j + 1] = 1;
printf("%s %d\n", ctx.data, j + 1);
}
}
} else {
BYTE n[6];
int count1 = 0;
for (int k = 0; k < 6; ++k) {
n[k] = a[k];
if (old[k] == n[k]) {
++count1;
}
}
n[6] = '\0';
if (count1 < 6) {
printf("%s\n", n);
for (int k = 0; k < 7; ++k) {
old[k] = n[k];
}
}
}
} else {
for (i = l; i <= r; i++) {
swap((a + l), (a + i));
permute(a, l + 1, r, hashes, status);
swap((a + l), (a + i)); //backtrack
}
}
}
/* Driver program to test above functions */
void permutations1(char * word_list_file, int hashes[30][32], int status) {
SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE];
BYTE password[12];
bool cracked = true;
char word[30];
FILE * word_list;
word_list = fopen(word_list_file, "rb");
while (fgets(password, 7, word_list) != '\0') {
for (int i = 6; i < 12; ++i) {
if (password[i - 6] >= 65 && password[i - 6] < 90) {
password[i] = password[i - 6] + 32;
} else {
password[i] = password[i - 6] - 32;
}
}
password[12] = '\0';
permute(password, 0, 11, hashes, status);
}
fclose(word_list);
}
void crack6(char * word_list_file, int hashes[30][32]) { void crack6(char * word_list_file, int hashes[30][32]) {
SHA256_CTX ctx; SHA256_CTX ctx;
...@@ -361,7 +251,6 @@ int main(int argc, char * argv[]) { ...@@ -361,7 +251,6 @@ int main(int argc, char * argv[]) {
} }
if (argc == 2) { if (argc == 2) {
int k = atoi(argv[1]); int k = atoi(argv[1]);
printf("%d\n", k);
printRandomString1(k); printRandomString1(k);
} }
...@@ -524,6 +413,7 @@ void makeguess(char * word_list, int hashes[][32], int a) { ...@@ -524,6 +413,7 @@ void makeguess(char * word_list, int hashes[][32], int a) {
} }
} }
for (int i = 0; i < 100000000000000000; ++i) { for (int i = 0; i < 100000000000000000; ++i) {
if (count == a) { if (count == a) {
break; break;
...@@ -555,6 +445,10 @@ void makeguess(char * word_list, int hashes[][32], int a) { ...@@ -555,6 +445,10 @@ void makeguess(char * word_list, int hashes[][32], int a) {
} }
} }
len=0; len=0;
} }
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment