Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
achattaraj_comp30023_2019_project-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aneesh Chattaraj
achattaraj_comp30023_2019_project-2
Commits
d13912cc
Commit
d13912cc
authored
May 24, 2019
by
aneesh
Browse files
Options
Downloads
Patches
Plain Diff
yoooo
parent
9dd391e1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
crack.c
+459
-364
459 additions, 364 deletions
crack.c
crack.exe
+0
-0
0 additions, 0 deletions
crack.exe
with
459 additions
and
364 deletions
crack.c
+
459
−
364
View file @
d13912cc
...
@@ -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
This diff is collapsed.
Click to expand it.
crack.exe
+
0
−
0
View file @
d13912cc
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment