Skip to content
Permalink
2ad88bb57b
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
38 lines (25 sloc) 584 Bytes
#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;
}