added more code
This commit is contained in:
15
CPE455/Quiz-Charlie/README.txt
Normal file
15
CPE455/Quiz-Charlie/README.txt
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
capp.c
|
||||
|
||||
sample code uses scanf( )
|
||||
|
||||
|
||||
Correct password is the following fifteen characters: aaaaabbbbbccccc
|
||||
|
||||
|
||||
perl -e 'print "a"x90' | ./vulnerable_capp
|
||||
|
||||
perl -e 'print "a"x90' | ./protected_capp
|
||||
|
||||
|
||||
|
94
CPE455/Quiz-Charlie/after.txt
Normal file
94
CPE455/Quiz-Charlie/after.txt
Normal file
@ -0,0 +1,94 @@
|
||||
Script started on Thu 24 Feb 2022 10:37:55 AM CST
|
||||
[?1034hbash-4.2$ ./vulnerable_capp
|
||||
|
||||
Enter the password now: aaaa
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 4
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./vulnerable_capp
|
||||
|
||||
Enter the password now: aaaaabbbbbccccc
|
||||
|
||||
Login successful
|
||||
|
||||
suppliedPassword: aaaaabbbbbccccc
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 15
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ perl -e 'print "a"x90' | ./vulnerable_capp
|
||||
|
||||
Enter the password now:
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaaaaaaaaaaaaaaaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 19
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./protected_capp
|
||||
|
||||
Enter the password now: aaaa
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 4
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./protected_capp
|
||||
|
||||
Enter the password now: aaaabbbbcccc
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaabbbbcccc
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 12
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./protected_capp
|
||||
|
||||
Enter the password now: aaaaabbbbbccccc
|
||||
|
||||
Login successful
|
||||
|
||||
suppliedPassword: aaaaabbbbbccccc
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 15
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ perl -e 'print "a"x90' | ./protected_capp
|
||||
|
||||
Enter the password now:
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaaaaaaaaaaaaaaaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 19
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ exit
|
||||
exit
|
||||
|
||||
Script done on Thu 24 Feb 2022 10:41:07 AM CST
|
84
CPE455/Quiz-Charlie/before.txt
Normal file
84
CPE455/Quiz-Charlie/before.txt
Normal file
@ -0,0 +1,84 @@
|
||||
Script started on Thu 24 Feb 2022 10:34:10 AM CST
|
||||
[?1034hbash-4.2$ ./vulnerable_capp
|
||||
|
||||
Enter the password now: aaaa
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 4
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./vulnerable_capp
|
||||
|
||||
Enter the password now: aaaaabbbbbccccc
|
||||
|
||||
Login successful
|
||||
|
||||
suppliedPassword: aaaaabbbbbccccc
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 15
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ perl -e 'print "a"x90' | ./vulnerable_capp
|
||||
|
||||
Enter the password now:
|
||||
Login successful
|
||||
|
||||
suppliedPassword: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 90
|
||||
correctPassword: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 58
|
||||
|
||||
Segmentation fault
|
||||
bash-4.2$ ./protected_capp
|
||||
|
||||
Enter the password now: aaaa
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 4
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ ./protected_capp
|
||||
[C[C[C[C[C[C[C[C[C[Cperl -e 'print "a"x90' | ./vulnerable_capp
|
||||
[C[C[C[C[C[C[C[C[C[C[26P./protected_capp
|
||||
|
||||
Enter the password now: aaaaabbbbbccccc
|
||||
|
||||
Login successful
|
||||
|
||||
suppliedPassword: aaaaabbbbbccccc
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 15
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
bash-4.2$ perl -e 'print "a"x90' | ./protected_capp
|
||||
|
||||
Enter the password now:
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 90
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
|
||||
*** stack smashing detected ***: ./protected_capp terminated
|
||||
Segmentation fault
|
||||
bash-4.2$ exit
|
||||
exit
|
51
CPE455/Quiz-Charlie/capp.c
Normal file
51
CPE455/Quiz-Charlie/capp.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* capp.c
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define BUFFER_SIZE 20
|
||||
|
||||
int main()
|
||||
{
|
||||
char correctPassword[BUFFER_SIZE];
|
||||
char suppliedPassword[BUFFER_SIZE];
|
||||
|
||||
printf("\nEnter the password now: ");
|
||||
strncpy(correctPassword, "aaaaabbbbbccccc", BUFFER_SIZE);
|
||||
scanf("%19s", suppliedPassword);
|
||||
printf("\n");
|
||||
|
||||
if (strncmp(suppliedPassword, correctPassword, BUFFER_SIZE) == 0)
|
||||
{
|
||||
printf("Login successful\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Login failure\n\n");
|
||||
}
|
||||
|
||||
printf("suppliedPassword: %s\n", suppliedPassword);
|
||||
printf("sizeof(suppliedPassword) = %d\n", sizeof(suppliedPassword));
|
||||
printf("strlen(suppliedPassword) = %d\n", strlen(suppliedPassword));
|
||||
|
||||
printf("correctPassword: %s\n", correctPassword);
|
||||
printf("sizeof(correctPassword) = %d\n", sizeof(correctPassword));
|
||||
printf("strlen(correctPassword) = %d\n", strlen(correctPassword));
|
||||
|
||||
char myArray[BUFFER_SIZE];
|
||||
scanf("%s", myArray);
|
||||
printf("myArray: %s\n", myArray);
|
||||
printf("sizeof(myArray) = %d\n", sizeof(myArray));
|
||||
printf("strlen(myArray) = %d\n", strlen(myArray));
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
18
CPE455/Quiz-Charlie/makefile
Normal file
18
CPE455/Quiz-Charlie/makefile
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# capp.c makefile
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -g
|
||||
|
||||
vulnerable_capp: capp.c
|
||||
$(CC) $(CFLAGS) -fno-stack-protector -z execstack capp.c -o vulnerable_capp
|
||||
|
||||
protected_capp: capp.c
|
||||
$(CC) $(CFLAGS) -fstack-protector -z noexecstack capp.c -o protected_capp
|
||||
|
||||
clean:
|
||||
rm vulnerable_capp protected_capp
|
||||
|
||||
|
||||
|
BIN
CPE455/Quiz-Charlie/myarray
Executable file
BIN
CPE455/Quiz-Charlie/myarray
Executable file
Binary file not shown.
BIN
CPE455/Quiz-Charlie/protected_capp
Executable file
BIN
CPE455/Quiz-Charlie/protected_capp
Executable file
Binary file not shown.
44
CPE455/Quiz-Charlie/result.txt
Normal file
44
CPE455/Quiz-Charlie/result.txt
Normal file
@ -0,0 +1,44 @@
|
||||
Script started on Thu 24 Feb 2022 10:42:50 AM CST
|
||||
[?1034hbash-4.2$ exitperl -e 'print "a"x90' | ./myarray
|
||||
[C[C[C[C[C[C[C[C[C[C./myarray [Kgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[Cscript after.txt[K
|
||||
[C[C[C[C[C[C[C[C[C[Cgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
gcc: error: capp.c: No such file or directory
|
||||
gcc: fatal error: no input files
|
||||
compilation terminated.
|
||||
bash-4.2$ cd CPE[K[K[KQuiz-C
|
||||
bash: cd: Quiz-C: No such file or directory
|
||||
bash-4.2$ cd Quiz-Charlie/
|
||||
bash-4.2$ cd Quiz-Charlie/[Kgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
bash-4.2$ gcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[Ccd Quiz-Charlie/[K[Kgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[Cexit[Kperl -e 'print "a"x90' | ./myarray
|
||||
[C[C[C[C[C[C[C[C[C[C./myarray [K
|
||||
|
||||
Enter the password now: aaaaabbbbbcccccdddddeeeee
|
||||
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaaabbbbbcccccdddd
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 19
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
||||
strlen(correctPassword) = 15
|
||||
myArray: deeeee
|
||||
sizeof(myArray) = 20
|
||||
strlen(myArray) = 6
|
||||
|
||||
bash-4.2$ ./myarray gcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[C./myarray [Kgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[Ccd Quiz-Charlie/[K[Kgcc -g -fno-stack-protector -z execstack capp.c -o myarray
|
||||
[C[C[C[C[C[C[C[C[C[Cexit[Kperl -e 'print "a"x90' | ./myarray
|
||||
|
||||
Enter the password now:
|
||||
Login failure
|
||||
|
||||
suppliedPassword: aaaaaaaaaaaaaaaaaaa
|
||||
sizeof(suppliedPassword) = 20
|
||||
strlen(suppliedPassword) = 19
|
||||
correctPassword: aaaaabbbbbccccc
|
||||
sizeof(correctPassword) = 20
|
BIN
CPE455/Quiz-Charlie/vulnerable_capp
Executable file
BIN
CPE455/Quiz-Charlie/vulnerable_capp
Executable file
Binary file not shown.
Reference in New Issue
Block a user