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

yoooo
parent 9dd391e1
No related branches found
No related tags found
No related merge requests found
...@@ -10,17 +10,16 @@ ...@@ -10,17 +10,16 @@
int exist[30]; int exist[30];
BYTE old[6]; BYTE old[6];
int count = 0; int count = 0;
void makeguess(char * word_list, int hashes[][32],int a);
void printRandomString(int hashes[30][32]) void printRandomString(int hashes[30][32]) {
{ bool cracked = true; bool cracked = true;
SHA256_CTX ctx; SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
for (int i = 0; i < 100000000000000000; ++i) { for (int i = 0; i < 100000000000000000; ++i) {
if (count=30) if (count == 30) {
{
break; break;
} }
BYTE res[6]; BYTE res[6];
...@@ -49,11 +48,9 @@ SHA256_CTX ctx; ...@@ -49,11 +48,9 @@ SHA256_CTX ctx;
} }
} }
} }
} }
void variations(char *word_list_file, int hashes[30][32]) void variations(char * word_list_file, int hashes[30][32]) {
{
SHA256_CTX ctx; SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
BYTE password[6]; BYTE password[6];
...@@ -63,37 +60,28 @@ void variations(char *word_list_file, int hashes[30][32]) ...@@ -63,37 +60,28 @@ void variations(char *word_list_file, int hashes[30][32])
word_list = fopen(word_list_file, "rb"); word_list = fopen(word_list_file, "rb");
while (fgets(password, 7, word_list) != '\0') { while (fgets(password, 7, word_list) != '\0') {
if (count==30) if (count == 30) {
{
break; break;
} }
for (int c = 0; c < 6; ++c) for (int c = 0; c < 6; ++c) {
{ BYTE password1[6]; BYTE password1[6];
for (int i = 0; i < 6; ++i) for (int i = 0; i < 6; ++i) {
{ if (i == c) {
if (i==c)
{
if (password[c]>=65 && password[c]<90) if (password[c] >= 65 && password[c] < 90) {
{
password1[c] = password[c] + 32; password1[c] = password[c] + 32;
} } else if (password[c] >= 97 && password[c] < 123) {
else if (password[c]>=97 && password[c]<123)
{
password1[c] = password[c] - 32; password1[c] = password[c] - 32;
} } else {
else{
password1[c] = password[c]; password1[c] = password[c];
} }
} } else {
else{
password1[i] = password[i]; password1[i] = password[i];
} }
} }
password1[6] = '\0'; password1[6] = '\0';
sha256_init( & ctx); sha256_init( & ctx);
sha256_update( & ctx, password1, sizeof(password1)); sha256_update( & ctx, password1, sizeof(password1));
sha256_final( & ctx, buffer); sha256_final( & ctx, buffer);
...@@ -118,15 +106,12 @@ void variations(char *word_list_file, int hashes[30][32]) ...@@ -118,15 +106,12 @@ void variations(char *word_list_file, int hashes[30][32])
} }
} }
fclose(word_list);
} }
void printRandomString1(int k) void printRandomString1(int k) {
{
for (int i = 0; i < k - 1; ++i) { for (int i = 0; i < k - 1; ++i) {
BYTE res[6]; BYTE res[6];
...@@ -137,14 +122,12 @@ void printRandomString1(int k) ...@@ -137,14 +122,12 @@ void printRandomString1(int k)
} }
} }
void bruteforce(int hashes[30][32]) { void bruteforce(int hashes[30][32]) {
SHA256_CTX ctx; SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
BYTE password[4]; BYTE password[4];
bool cracked = true; bool cracked = true;
for (int c1 = 32; c1 < 127; c1++) { for (int c1 = 32; c1 < 127; c1++) {
password[0] = c1; password[0] = c1;
if (count == 10) break; if (count == 10) break;
...@@ -159,7 +142,6 @@ void bruteforce(int hashes[30][32]){ ...@@ -159,7 +142,6 @@ void bruteforce(int hashes[30][32]){
password[3] = c4; password[3] = c4;
password[4] = '\0'; password[4] = '\0';
sha256_init( & ctx); sha256_init( & ctx);
sha256_update( & ctx, password, sizeof(password)); sha256_update( & ctx, password, sizeof(password));
sha256_final( & ctx, buffer); sha256_final( & ctx, buffer);
...@@ -186,8 +168,7 @@ void bruteforce(int hashes[30][32]){ ...@@ -186,8 +168,7 @@ void bruteforce(int hashes[30][32]){
// C program to print all permutations with duplicates allowed // C program to print all permutations with duplicates allowed
/* Function to swap values at two pointers */ /* Function to swap values at two pointers */
void swap(char *x, char *y) void swap(char * x, char * y) {
{
char temp; char temp;
temp = * x; temp = * x;
* x = * y; * x = * y;
...@@ -199,19 +180,18 @@ This function takes three parameters: ...@@ -199,19 +180,18 @@ This function takes three parameters:
1. String 1. String
2. Starting index of the string 2. Starting index of the string
3. Ending index of the string. */ 3. Ending index of the string. */
void permute(char *a, int l, int r,int hashes[30][32],int status) void permute(char * a, int l, int r, int hashes[30][32], int status) {
{ SHA256_CTX ctx; SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
bool cracked = true; bool cracked = true;
int count1 = 0; int count1 = 0;
char word[30]; char word[30];
int i; int i;
if (l == r) if (l == r) {
{ if(status!=2){ if (status != 2) {
BYTE n[6]; BYTE n[6];
for (int k = 0; k < 6; ++k) for (int k = 0; k < 6; ++k) {
{
n[k] = a[k]; n[k] = a[k];
} }
...@@ -236,34 +216,29 @@ if (l == r) ...@@ -236,34 +216,29 @@ if (l == r)
printf("%s %d\n", ctx.data, j + 1); printf("%s %d\n", ctx.data, j + 1);
} }
} }
}else{BYTE n[6]; } else {
BYTE n[6];
int count1 = 0; int count1 = 0;
for (int k = 0; k < 6; ++k) for (int k = 0; k < 6; ++k) {
{
n[k] = a[k]; n[k] = a[k];
if (old[k]==n[k]) if (old[k] == n[k]) {
{
++count1; ++count1;
} }
} }
n[6] = '\0'; n[6] = '\0';
if(count1<6) if (count1 < 6) {
{
printf("%s\n", n); printf("%s\n", n);
for (int k = 0; k < 7; ++k) for (int k = 0; k < 7; ++k) {
{
old[k] = n[k]; old[k] = n[k];
} }
} }
}} }
else } else {
{ for (i = l; i <= r; i++) {
for (i = l; i <= r; i++)
{
swap((a + l), (a + i)); swap((a + l), (a + i));
permute(a, l + 1, r, hashes, status); permute(a, l + 1, r, hashes, status);
swap((a + l), (a + i)); //backtrack swap((a + l), (a + i)); //backtrack
...@@ -272,8 +247,7 @@ else ...@@ -272,8 +247,7 @@ else
} }
/* Driver program to test above functions */ /* Driver program to test above functions */
void permutations1(char *word_list_file, int hashes[30][32],int status) void permutations1(char * word_list_file, int hashes[30][32], int status) {
{
SHA256_CTX ctx; SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
BYTE password[12]; BYTE password[12];
...@@ -281,22 +255,15 @@ void permutations1(char *word_list_file, int hashes[30][32],int status) ...@@ -281,22 +255,15 @@ void permutations1(char *word_list_file, int hashes[30][32],int status)
char word[30]; char word[30];
FILE * word_list; FILE * word_list;
word_list = fopen(word_list_file, "rb"); word_list = fopen(word_list_file, "rb");
while (fgets(password, 7, word_list) != '\0') { while (fgets(password, 7, word_list) != '\0') {
for (int i = 6; i < 12; ++i) for (int i = 6; i < 12; ++i) {
{ if (password[i - 6] >= 65 && password[i - 6] < 90) {
if (password[i-6]>=65 && password[i-6]<90)
{
password[i] = password[i - 6] + 32; password[i] = password[i - 6] + 32;
} } else {
else
{
password[i] = password[i - 6] - 32; password[i] = password[i - 6] - 32;
} }
...@@ -307,10 +274,10 @@ void permutations1(char *word_list_file, int hashes[30][32],int status) ...@@ -307,10 +274,10 @@ void permutations1(char *word_list_file, int hashes[30][32],int status)
permute(password, 0, 11, hashes, status); 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;
BYTE buffer[SHA256_BLOCK_SIZE]; BYTE buffer[SHA256_BLOCK_SIZE];
BYTE password[6]; BYTE password[6];
...@@ -318,7 +285,6 @@ void crack6(char *word_list_file, int hashes[30][32]) ...@@ -318,7 +285,6 @@ void crack6(char *word_list_file, int hashes[30][32])
char word[30]; char word[30];
FILE * word_list; FILE * word_list;
word_list = fopen(word_list_file, "rb"); word_list = fopen(word_list_file, "rb");
...@@ -346,16 +312,15 @@ void crack6(char *word_list_file, int hashes[30][32]) ...@@ -346,16 +312,15 @@ void crack6(char *word_list_file, int hashes[30][32])
} }
} }
} }
fclose(word_list);
} }
int main(int argc, char * argv[]) { int main(int argc, char * argv[]) {
int status = argc; int status = argc;
int hashes[30][32]; int hashes[30][32];
if(argc==1) if (argc == 1) {
{
unsigned char buff[320]; unsigned char buff[320];
int hashes[30][32]; int hashes[30][32];
FILE * file_4, * file_6; FILE * file_4, * file_6;
...@@ -364,7 +329,6 @@ void crack6(char *word_list_file, int hashes[30][32]) ...@@ -364,7 +329,6 @@ void crack6(char *word_list_file, int hashes[30][32])
fread(buff, sizeof(buff), 1, file_4); fread(buff, sizeof(buff), 1, file_4);
for (i = 0; i < 320; i++) { for (i = 0; i < 320; i++) {
if (i % 32 == 0) { if (i % 32 == 0) {
a++; a++;
...@@ -378,43 +342,34 @@ void crack6(char *word_list_file, int hashes[30][32]) ...@@ -378,43 +342,34 @@ void crack6(char *word_list_file, int hashes[30][32])
unsigned char buff6[640]; unsigned char buff6[640];
file_6 = fopen("pwd6sha256", "rb"); file_6 = fopen("pwd6sha256", "rb");
fread(buff6, sizeof(buff6), 1, file_6); fread(buff6, sizeof(buff6), 1, file_6);
for(i=0,a=9; i<640;++i) for (i = 0, a = 9; i < 640; ++i) {
{
if (i % 32 == 0) { if (i % 32 == 0) {
a++; a++;
b = 0; b = 0;
printf("\n");
} }
hashes[a][b] = buff6[i]; hashes[a][b] = buff6[i];
b++; b++;
} }
crack6("100k_passwords.txt", hashes); crack6("100k_passwords.txt", hashes);
variations("common_passwords1.txt", hashes); variations("common_passwords1.txt", hashes);
printRandomString(hashes); printRandomString(hashes);
fclose(file_4); fclose(file_4);
fclose(file_6); fclose(file_6);
} }
if (argc==2) if (argc == 2) {
{
int k = atoi(argv[1]); int k = atoi(argv[1]);
printf("%d\n", k); printf("%d\n", k);
printRandomString1(k); printRandomString1(k);
} }
if (argc==3) if (argc == 3) {
{ FILE * password_file;
FILE *password_file,*word_list_file;
password_file = fopen(argv[1], "rb"); password_file = fopen(argv[1], "rb");
word_list_file=fopen(argv[2],"rb"); char word[10000];
int i, a = 0, b = 0; int i, a = 0, b = 0;
fseek(password_file, 0L, SEEK_END); fseek(password_file, 0L, SEEK_END);
int sz = ftell(password_file); int sz = ftell(password_file);
...@@ -427,20 +382,160 @@ if (argc==3) ...@@ -427,20 +382,160 @@ if (argc==3)
if (i % 32 == 0) { if (i % 32 == 0) {
a++; a++;
b = 0; b = 0;
printf("\n");
} }
hashes[a][b] = buff[i]; hashes[a][b] = buff[i];
b++; b++;
} }
crack6(argv[2],hashes);
variations("common_passwords1.txt",hashes);
makeguess(argv[2], hashes, a);
} }
return 0; return 0;
}
void makeguess(char * word_list, int hashes[][32], int a) {
SHA256_CTX ctx;
BYTE buffer[SHA256_BLOCK_SIZE];
BYTE word[10000];
FILE * fp;
int j=0;
char c;
fp = fopen(word_list, "rb");
int len=0;
bool cracked=true;
int exist[a];
while((c = fgetc(fp)) != EOF)
{
if(c == '\n')
{
word[len]='\0';
sha256_init( & ctx);
sha256_update( & ctx, word, len);
sha256_final( & ctx, buffer);
for (int j = 0; j < a; 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;
++count;
printf("%s %d\n", ctx.data,j+1);
}
}
for (int k = 0; k < len; ++k) {
BYTE password1[len-1];
for (int l = 0; l < len; ++l) {
if (k == l) {
if (word[k] >= 65 && word[k] < 90) {
password1[k] = word[k] + 32;
} else if (word[k] >= 97 && word[k] < 123) {
password1[k] = word[k] - 32;
} else {
password1[k] = word[k];
}
} else {
password1[l] = word[l];
}
}
password1[len] = '\0';
sha256_init( & ctx);
sha256_update( & ctx, password1, len);
sha256_final( & ctx, buffer);
for (int j = 0; j < a; 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;
count++;
printf("%s %d\n", ctx.data, j + 1);
}
}
}
for (int k = 0; k < len; ++k) {
BYTE password1[len-1];
for (int l = 0; l < len; ++l) {
if (k == l) {
if (word[k] >= 65 && word[k] < 90) {
password1[k] = word[k] + 32;
} else if (word[k] >= 97 && word[k] < 123) {
password1[k] = word[k] - 32;
} else {
password1[k] = word[k];
}
} else {
password1[l] = word[l];
}
}
password1[len] = '\0';
password1[0] = password1[0] - 32;
sha256_init( & ctx);
sha256_update( & ctx, password1, len);
sha256_final( & ctx, buffer);
for (int j = 0; j < a; 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;
count++;
printf("%s %d\n", ctx.data, j + 1);
}
}
}
len=0;
}
else
{
word[len]=c;
++len;
}
}
} }
\ No newline at end of file
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