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
Weijie Lin
comp30023_2019_project-2
Commits
b0ea944b
Commit
b0ea944b
authored
May 23, 2019
by
weijiel6
Browse files
Options
Downloads
Patches
Plain Diff
fix 6password code and out.txt
parent
c0e07243
No related branches found
No related tags found
No related merge requests found
Pipeline
#2757
canceled
May 23, 2019
Stage: build
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
crack.c
+83
-10
83 additions, 10 deletions
crack.c
out.txt
+5
-0
5 additions, 0 deletions
out.txt
outcomeone.txt
+0
-0
0 additions, 0 deletions
outcomeone.txt
with
88 additions
and
10 deletions
crack.c
+
83
−
10
View file @
b0ea944b
...
...
@@ -17,7 +17,7 @@
#include
<sys/resource.h>
#include
<sys/time.h>
#include
<sys/stat.h>
int
check_guess
(
BYTE
secrets
[],
BYTE
hash
[]);
int
check_guess
(
BYTE
secrets
[],
BYTE
hash
[]
,
int
size
);
int
get_password
(
char
*
line
,
FILE
*
fp
);
...
...
@@ -36,15 +36,18 @@ get_password(char *line, FILE *fp) {
int
check_guess
(
BYTE
secrets
[],
BYTE
hash
[])
{
int
check_guess
(
BYTE
secrets
[],
BYTE
hash
[]
,
int
size
)
{
//for(int i=0; i<32;i++){
// printf("%02x",hash[i]);
//}
//printf("\n");
int
compare_size
=
32
;
int
flag
;
int
turn
=
(
size
/
32
)
+
1
;
//printf("size is %d, turn is %d\n",size, turn);
//flag = true;
for
(
int
i
=
1
;
i
<
11
;
i
++
)
{
for
(
int
i
=
1
;
i
<
turn
;
i
++
)
{
flag
=
-
1
;
for
(
int
k
=
(
i
-
1
)
*
compare_size
;
k
<
i
*
compare_size
;
k
++
)
{
if
(
secrets
[
k
]
!=
hash
[
k
-
((
i
-
1
)
*
compare_size
)])
{
...
...
@@ -56,7 +59,11 @@ int check_guess(BYTE secrets[], BYTE hash[]) {
}
if
(
flag
==
1
){
//int num;
//num = flag * i;
//printf("this is true for %d\n", i);
//printf("true!!!!\n");
//printf("return value should be %d\n",num);
return
flag
*
i
;
}
}
...
...
@@ -71,12 +78,22 @@ int main( int argc, char **argv )
/* check we have 0 argument, test for guessing password*/
if
(
argc
<
2
)
{
FILE
*
fp
;
FILE
*
fp1
;
int
pwd4_size
;
fp1
=
fopen
(
"out.txt"
,
"w"
);
BYTE
secrets
[
320
];
fp
=
fopen
(
"pwd4sha256"
,
"rb"
);
fread
(
secrets
,
320
,
1
,
fp
);
/*Move file point at the end of file.*/
fseek
(
fp
,
0
,
SEEK_END
);
/*Get the current position of the file pointer.*/
pwd4_size
=
ftell
(
fp
);
fseek
(
fp
,
0
,
SEEK_SET
);
printf
(
"size is %d
\n
"
,
pwd4_size
);
for
(
int
i
=
0
;
i
<
320
;
i
++
){
printf
(
"%02x"
,
secrets
[
i
]);
...
...
@@ -100,8 +117,8 @@ int main( int argc, char **argv )
sha256_init
(
&
ctx
);
sha256_update
(
&
ctx
,
(
BYTE
*
)
guess
,
strlen
(
guess
));
sha256_final
(
&
ctx
,
data
);
if
(
check_guess
(
secrets
,
data
)
>
0
)
{
secret_num
=
check_guess
(
secrets
,
data
);
if
(
check_guess
(
secrets
,
data
,
pwd4_size
)
>
0
)
{
secret_num
=
check_guess
(
secrets
,
data
,
pwd4_size
);
printf
(
"%s %d
\n
"
,
guess
,
secret_num
);
fprintf
(
fp1
,
"%s %d
\n
"
,
guess
,
secret_num
);
}
...
...
@@ -111,7 +128,62 @@ int main( int argc, char **argv )
}
}
}
guess
[
5
]
=
'\0'
;
FILE
*
fp3
;
BYTE
long_secrets
[
640
];
fp3
=
fopen
(
"pwd6sha256"
,
"rb"
);
fread
(
long_secrets
,
640
,
1
,
fp3
);
int
pwd6_size
;
/*Move file point at the end of file.*/
fseek
(
fp3
,
0
,
SEEK_END
);
/*Get the current position of the file pointer.*/
pwd6_size
=
ftell
(
fp3
);
fseek
(
fp3
,
0
,
SEEK_SET
);
printf
(
"size is %d
\n
"
,
pwd6_size
);
for
(
int
i
=
0
;
i
<
640
;
i
++
){
printf
(
"%02x"
,
long_secrets
[
i
]);
if
(((
i
+
1
)
%
32
)
==
0
)
{
printf
(
"
\n
"
);
}
}
printf
(
"
\n
"
);
char
long_guess
[
7
];
int
long_secret_num
;
SHA256_CTX
long_ctx
;
BYTE
long_data
[
SHA256_BLOCK_SIZE
];
for
(
int
i
=
48
;
i
<
58
;
i
++
)
{
for
(
int
j
=
48
;
j
<
58
;
j
++
)
{
for
(
int
l
=
48
;
l
<
58
;
l
++
)
{
for
(
int
k
=
48
;
k
<
58
;
k
++
)
{
for
(
int
n
=
48
;
n
<
58
;
n
++
)
{
for
(
int
m
=
48
;
m
<
58
;
m
++
)
{
sprintf
(
long_guess
,
"%c%c%c%c%c%c"
,
i
,
j
,
l
,
k
,
n
,
m
);
//printf("%s\n",guess);
sha256_init
(
&
long_ctx
);
sha256_update
(
&
long_ctx
,
(
BYTE
*
)
long_guess
,
strlen
(
long_guess
));
sha256_final
(
&
long_ctx
,
long_data
);
if
(
check_guess
(
long_secrets
,
long_data
,
pwd6_size
)
>
0
)
{
long_secret_num
=
check_guess
(
long_secrets
,
long_data
,
pwd6_size
);
long_secret_num
=
long_secret_num
+
10
;
//printf("long secret num should be %d\n", long_secret_num);
printf
(
"%s %d
\n
"
,
long_guess
,
long_secret_num
);
fprintf
(
fp1
,
"%s %d
\n
"
,
long_guess
,
long_secret_num
);
}
}
}
}
}
}
}
long_guess
[
7
]
=
'\0'
;
return
0
;
}
...
...
@@ -125,11 +197,12 @@ int main( int argc, char **argv )
{
FILE
*
fp1
;
fp1
=
fopen
(
argv
[
2
],
"rb"
);
BYTE
secrets
[
320
];
fread
(
secrets
,
320
,
1
,
fp1
);
int
fp1_size
;
fseek
(
fp1
,
0
,
SEEK_END
);
fp1_size
=
ftell
(
fp1
);
fseek
(
fp1
,
0
,
SEEK_SET
);
BYTE
secrets
[
fp1_size
];
fread
(
secrets
,
fp1_size
,
1
,
fp1
);
for
(
int
i
=
0
;
i
<
fp1_size
;
i
++
){
printf
(
"%02x"
,
secrets
[
i
]);
...
...
@@ -148,8 +221,8 @@ int main( int argc, char **argv )
sha256_init
(
&
ctx
);
sha256_update
(
&
ctx
,
(
BYTE
*
)
line
,
strlen
(
line
));
sha256_final
(
&
ctx
,
data
);
if
(
check_guess
(
secrets
,
data
)
>
0
)
{
secret_num
=
check_guess
(
secrets
,
data
);
if
(
check_guess
(
secrets
,
data
,
fp1_size
)
>
0
)
{
secret_num
=
check_guess
(
secrets
,
data
,
fp1_size
);
printf
(
"%s %d
\n
"
,
line
,
secret_num
);
}
}
...
...
This diff is collapsed.
Click to expand it.
out.txt
+
5
−
0
View file @
b0ea944b
...
...
@@ -8,3 +8,8 @@ oca{ 10
reng 2
tuyy 9
weij 7
090909 25
360258 11
369258 13
379258 12
469258 29
This diff is collapsed.
Click to expand it.
outcomeone.txt
0 → 100644
+
0
−
0
View file @
b0ea944b
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