Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Xun Zhang
comp30023-2019-project-2
Commits
96e7ec0d
Commit
96e7ec0d
authored
May 25, 2019
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
pure lowercase pwd6 find
parent
fe60ed1f
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
+79
-88
79 additions, 88 deletions
crack.c
found_pwds.txt
+8
-0
8 additions, 0 deletions
found_pwds.txt
with
87 additions
and
88 deletions
crack.c
+
79
−
88
View file @
96e7ec0d
...
...
@@ -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
);
i
f
(
guess_len
==
4
)
{
i
nt
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
)
{
...
...
This diff is collapsed.
Click to expand it.
found_pwds.txt
+
8
−
0
View file @
96e7ec0d
...
...
@@ -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
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