Skip to content
Snippets Groups Projects
Commit 9125f42b authored by ChouTatsumi's avatar ChouTatsumi
Browse files

crack complete

parent 806f6f80
No related branches found
No related tags found
No related merge requests found
**/.vscode
**/test.*
**/test*.*
**/*.exe
**/*.o
**/cheat
......
......@@ -10,8 +10,8 @@ sha256.o: sha256.c sha256.h
$(EXE): crack.c sha256.o
$(CC) $(CFLAGS) -o $(EXE) crack.c sha256.o
test: test.c
$(CC) $(CFLAGS) -o test test.c
# test: test.c
# $(CC) $(CFLAGS) -o test test.c
clean:
rm $(EXE) sha256.o
......@@ -7,11 +7,13 @@
// constants
#define INPUTSIZE 10000
#define BUFFERSIZE 256
#define PWD4_FILENAME "pwd4sha256"
#define PWD6_FILENAME "pwd6sha256"
#define OUTPUT_FILENAME "found_pwds.txt"
#define DICT_FILENAME "common_passwords.txt"
#define DICT_FILENAME "passwords_dict.txt"
#define DICT_NUMBERS 10000
#define PWD4_DICT_FILENAME "common_pwd4.txt"
#define PWD6_DICT_FILENAME "common_pwd6.txt"
#define PWD4_NUMBERS 10
......@@ -180,9 +182,9 @@ int main(int argc, char** argv) {
// guess common pwd6
FILE* dict_fp;
dict_fp = fopen(PWD6_DICT_FILENAME, "r");
char input[INPUTSIZE];
char input[BUFFERSIZE];
while(fgets(input, INPUTSIZE, dict_fp) != NULL) {
while(fgets(input, BUFFERSIZE, dict_fp) != NULL) {
input[PWD6_LEN] = '\0';
find = check_pwd6_guess(&ctx, hash, input, pwd, checked);
if (find) {
......@@ -194,7 +196,7 @@ int main(int argc, char** argv) {
// guess common pwd4 plus 2 digits
dict_fp = fopen(PWD4_DICT_FILENAME, "r");
while (fgets(input, INPUTSIZE, dict_fp) != NULL) {
while (fgets(input, BUFFERSIZE, dict_fp) != NULL) {
for (fifth = ASCII_NUM_FROM; fifth <= ASCII_NUM_TO; fifth++) {
input[4] = fifth;
for (sixth = ASCII_NUM_FROM; sixth <= ASCII_NUM_TO; sixth++) {
......@@ -249,10 +251,28 @@ int main(int argc, char** argv) {
fclose(fp);
} else if (argc == 2) {
// This part for good guess
// get the number of passwords to produce
FILE* fp;
char input[BUFFERSIZE];
int n = atoi(argv[1]);
fp = fopen(PWD6_DICT_FILENAME, "r");
int i = 0;
if (n <= DICT_NUMBERS) {
while (++i <= n && fgets(input, BUFFERSIZE, fp) != NULL) {
printf("%s", input);
}
} else {
fprintf(stderr, "ERROR, too large n\n");
exit(0);
}
fclose(fp);
} else if (argc == 3) {
FILE* fp;
FILE* wfp;
BYTE buffer[SHA256_BLOCK_SIZE];
// read password file and store hashes passwords
......@@ -291,7 +311,6 @@ int main(int argc, char** argv) {
// read guess from file and check guess
fp = fopen(argv[1], "r");
wfp = fopen(OUTPUT_FILENAME, "w");
char input[INPUTSIZE];
SHA256_CTX ctx;
BYTE hash[SHA256_BLOCK_SIZE];
......@@ -310,12 +329,13 @@ int main(int argc, char** argv) {
if (find) {
printf("%s %d\n", input, find);
fprintf(wfp, "%s %d\n", input, find);
}
}
fclose(fp);
fclose(wfp);
} else {
fprintf(stderr, "ERROR, undefined usage of crack\n");
exit(0);
}
return 0;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment