Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Forking Version added (#14)
* Forking Version added * Fstrings Version Addd
- Loading branch information
Showing
7 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include <sys/wait.h> | ||
#include <string.h> | ||
|
||
int processData(void){ | ||
printf("Please Enter Data >"); | ||
char data[128]; | ||
gets(data); | ||
printf(data); | ||
return 1; | ||
} | ||
|
||
int main(int argc, char *argv){ | ||
printf("Smash the Forking Stack\n"); | ||
|
||
while(1){ | ||
int pid = fork(); | ||
if(pid == 0){ | ||
//Child Deals with data | ||
processData(); | ||
printf("Child Returns\n"); | ||
return 0; | ||
} | ||
else{ | ||
//Parent gets on with Life | ||
printf("Parent Waits on Child\n"); | ||
wait(NULL); | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CC = gcc | ||
FLAGS = -no-pie -g | ||
|
||
forking: forking.c | ||
$(CC) $(FLAGS) forking.c -o forking | ||
|
||
all: forking |
BIN
+17 KB
Week8_Canaries/Fstrings/forking
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <signal.h> | ||
#include <sys/wait.h> | ||
#include <string.h> | ||
|
||
int processData(void){ | ||
printf("Please Enter Data >"); | ||
char data[32]; | ||
gets(data); | ||
printf(data); | ||
return 1; | ||
} | ||
|
||
int main(int argc, char *argv){ | ||
printf("Smash the Forking Stack\n"); | ||
|
||
while(1){ | ||
int pid = fork(); | ||
if(pid == 0){ | ||
//Child Deals with data | ||
processData(); | ||
printf("Child Returns\n"); | ||
return 0; | ||
} | ||
else{ | ||
//Parent gets on with Life | ||
printf("Parent Waits on Child\n"); | ||
wait(NULL); | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CC = gcc | ||
FLAGS = -no-pie -g | ||
|
||
forking: forking.c | ||
$(CC) $(FLAGS) forking.c -o forking | ||
|
||
all: forking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CC = gcc | ||
FLAGS = -fno-stack-protector -no-pie -g --static | ||
|
||
static: static.c | ||
$(CC) $(FLAGS) static.c -o static | ||
|
||
all: static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
|
||
// We Use a Sruct as it means we can be sure that the memory layout stays the same | ||
|
||
struct staticMemory { | ||
char buffer[20]; | ||
int canary; | ||
}; | ||
|
||
|
||
int win(){ | ||
system("/bin/sh"); | ||
} | ||
|
||
int main(int argc, char *argv){ | ||
|
||
//Initilise our memory | ||
struct staticMemory myMemory; | ||
|
||
//And the Canary | ||
myMemory.canary = 0xDEADBEEF; | ||
|
||
printf("Enter your String\n"); | ||
gets(myMemory.buffer); | ||
|
||
|
||
//And Do our check | ||
if (myMemory.canary != 0xDEADBEEF){ | ||
printf("Stack Smashing Detected!!!\n"); | ||
exit(-1); | ||
} | ||
|
||
return 1; | ||
|
||
} |