Skip to content

Forking Version added #14

Merged
merged 2 commits into from Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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);

}
}
}

@@ -0,0 +1,7 @@
CC = gcc
FLAGS = -no-pie -g

forking: forking.c
$(CC) $(FLAGS) forking.c -o forking

all: forking
Binary file not shown.
@@ -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);

}
}
}

@@ -0,0 +1,7 @@
CC = gcc
FLAGS = -no-pie -g

forking: forking.c
$(CC) $(FLAGS) forking.c -o forking

all: forking
@@ -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
@@ -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;

}