Skip to content
Permalink
Browse files
First set of Overflows added
  • Loading branch information
aa9863 committed Nov 18, 2020
0 parents commit cd393ae59af4302c63b2660e43d0018d29b1f2ab
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
@@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int BUFFER=100;

void win(void){
/*Win Condition
We Want to jump here
*/
printf("\n ===== Win ===== \n\n");
system("/bin/sh"); //Tradition to get a shell
}

void lose(void){
/* Lose Condition */
printf("Current Memory Address is %p\n",lose);
printf("Aim for %p\n", win);
printf("Lose :(\n");
}

int main(int argc, char* argv[]){
/* Main Function*/

//Pointer to the lose function
void (*fp)(void) = lose;

char buffer[BUFFER];
printf("Overflow the Buffer\n");

if (argc != 2){
printf("Overflow the buffer\n");
printf("Hint! Try `python -c \"print 'A'*100\"`\n");
return -1;
}

memcpy(buffer, argv[1], strlen(argv[1]));
printf("Off to %p\n",fp);
fp();

return 0;
}
13 hello.c
@@ -0,0 +1,13 @@
#include <stdio.h>

int add(int var1, int var2){
//Add two numbers
int total;
total = var1+var2;
}

void main(int argv, char* argc){
//Function call
int total = add(10, 20);
printf("Total is %d \n", total);
}

0 comments on commit cd393ae

Please sign in to comment.