Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
deadbits committed Oct 28, 2012
1 parent 0572132 commit 0330bcc
Show file tree
Hide file tree
Showing 40 changed files with 616 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/abo1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* abo1.c *
* specially crafted to feed your brain by gera */

/* Dumb example to let you get introduced... */

int main(int argv,char **argc) {
char buf[256];

strcpy(buf,argc[1]);
}
13 changes: 13 additions & 0 deletions examples/abo10.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* abo10.c *
* specially crafted to feed your brain by [email protected] */

/* Deja-vu */

char buf[256];

int main(int argv,char **argc) {
char *pbuf=(char*)malloc(256);

gets(buf);
free(pbuf);
}
12 changes: 12 additions & 0 deletions examples/abo2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* abo2.c *
* specially crafted to feed your brain by [email protected] */

/* This is a tricky example to make you think *
* and give you some help on the next one */

int main(int argv,char **argc) {
char buf[256];

strcpy(buf,argc[1]);
exit(1);
}
15 changes: 15 additions & 0 deletions examples/abo3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* abo3.c *
* specially crafted to feed your brain by [email protected] */

/* This'll prepare you for The Next Step */

int main(int argv,char **argc) {
extern system,puts;
void (*fn)(char*)=(void(*)(char*))&system;
char buf[256];

fn=(void(*)(char*))&puts;
strcpy(buf,argc[1]);
fn(argc[2]);
exit(1);
}
18 changes: 18 additions & 0 deletions examples/abo4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* abo4.c *
* specially crafted to feed your brain by [email protected] */

/* After this one, the next is just an Eureka! away */

extern system,puts;
void (*fn)(char*)=(void(*)(char*))&system;

int main(int argv,char **argc) {
char *pbuf=malloc(strlen(argc[2])+1);
char buf[256];

fn=(void(*)(char*))&puts;
strcpy(buf,argc[1]);
strcpy(pbuf,argc[2]);
fn(argc[3]);
while(1);
}
16 changes: 16 additions & 0 deletions examples/abo5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* abo5.c *
* specially crafted to feed your brain by [email protected] */

/* You take the blue pill, you wake up in your bed, *
* and you believe what you want to believe *
* You take the red pill, *
* and I'll show you how deep goes the rabbit hole */

int main(int argv,char **argc) {
char *pbuf=malloc(strlen(argc[2])+1);
char buf[256];

strcpy(buf,argc[1]);
for (;*pbuf++=*(argc[2]++););
exit(1);
}
13 changes: 13 additions & 0 deletions examples/abo6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* abo6.c *
* specially crafted to feed your brain by [email protected] */

/* return to me my love */

int main(int argv,char **argc) {
char *pbuf=malloc(strlen(argc[2])+1);
char buf[256];

strcpy(buf,argc[1]);
strcpy(pbuf,argc[2]);
while(1);
}
12 changes: 12 additions & 0 deletions examples/abo7.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* abo7.c *
* specially crafted to feed your brain by [email protected] */

/* sometimes you can, *
* sometimes you don't *
* that's what life's about */

char buf[256]={1};

int main(int argv,char **argc) {
strcpy(buf,argc[1]);
}
12 changes: 12 additions & 0 deletions examples/abo8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* abo8.c *
* specially crafted to feed your brain by [email protected] */

/* spot the difference */



char buf[256];

int main(int argv,char **argc) {
strcpy(buf,argc[1]);
}
14 changes: 14 additions & 0 deletions examples/abo9.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* abo9.c *
* specially crafted to feed your brain by [email protected] */

/* free(your mind) */
/* I'm not sure in what operating systems it can be done */

int main(int argv,char **argc) {
char *pbuf1=(char*)malloc(256);
char *pbuf2=(char*)malloc(256);

gets(pbuf1);
free(pbuf2);
free(pbuf1);
}
10 changes: 10 additions & 0 deletions examples/e1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* specially crafted to feed your brain by [email protected] */

/* jumpy vfprintf, Batman! */

int main(int argv,char **argc) {
/* Can you do it changing the stack? */
/* Can you do it without changing it? */
printf(argc[1]);
while(1);
}
19 changes: 19 additions & 0 deletions examples/e2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* specially crafted to feed your brain by [email protected] */

/* Now, your misson is to make abo1 act like this other program:
*
char buf[100];
while (1) {
scanf("%100s",buf);
system(buf);
}
* But, you cannot execute code in stack.
*/

int main(int argv,char **argc) {
char buf[256];

strcpy(buf,argc[1]);
}
12 changes: 12 additions & 0 deletions examples/e3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* e3.c *
* specially crafted to feed your brain by [email protected] */

/* are you an enviromental threat */

char buf[256];

int main(int argv,char **argc) {
strcpy(buf,argc[1]);
setenv("ABO",argc[2],1);
while(1);
}
12 changes: 12 additions & 0 deletions examples/e4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* <A HRef=e4.c>e4.c</a> *
* specially crafted to feed your brain by [email protected] */

/* %what the hell? */

char buf[256];

int main(int argv,char **argc) {
strcpy(buf,argc[1]);
printf("live at 100%!");
while(1);
}
12 changes: 12 additions & 0 deletions examples/e5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* e5.c *
* specially crafted to feed your brain by [email protected] */

/* is this possible? */

char buf[256];

int main(int argv,char **argc) {
strcpy(buf,argc[1]);
perror(argc[2]);
while(1);
}
16 changes: 16 additions & 0 deletions examples/fs1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* fs1.c *
* specially crafted to feed your brain by [email protected] */

/* Don't forget, *
* more is less, *
* here's a proof */

int main(int argv,char **argc) {
short int zero=0;
int *plen=(int*)malloc(sizeof(int));
char buf[256];

strcpy(buf,argc[1]);
printf("%s%hn\n",buf,plen);
while(zero);
}
10 changes: 10 additions & 0 deletions examples/fs2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* fs2.c *
* specially crafted to feed your brain by [email protected] */

/* Can you tell me what's above the edge? */
int main(int argv,char **argc) {
char buf[256];

snprintf(buf,sizeof buf,"%s%c%c%hn",argc[1]);
snprintf(buf,sizeof buf,"%s%c%c%hn",argc[2]);
}
10 changes: 10 additions & 0 deletions examples/fs3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* fs3.c *
* specially crafted to feed your brain by [email protected] */

/* Not enough resources? */

int main(int argv,char **argc) {
char buf[256];

snprintf(buf,sizeof buf,"%s%c%c%hn",argc[1]);
}
13 changes: 13 additions & 0 deletions examples/fs4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* fs4.c *
* specially crafted to feed your brain by [email protected] */

/* Have you ever heard about code reusability? */

int main(int argv,char **argc) {
char buf[256];

snprintf(buf,sizeof buf,"%s%6$hn",argc[1]);
printf(buf);
}


11 changes: 11 additions & 0 deletions examples/fs5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* fs5.c *
* specially crafted to feed your brain by [email protected] */

/* go, go, go! */
int main(int argv,char **argc) {
char buf[256];
snprintf(buf,sizeof buf,argc[1]);

/* this line'll make your life easier */
// printf("%s\n",buf);
}
25 changes: 25 additions & 0 deletions examples/n1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* n1.c *
* specially crafted to feed your brain by [email protected] */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX_SIZE 80

unsigned int atoul(char *str) {
unsigned int answer=0;
for (;*str && isdigit(*str);
answer *= 10, answer += *str++-'0');
return answer;
}

int main(int argv, char **argc) {
char buf[MAX_SIZE],*pbuf=buf;
int count = atoul(argc[1]);

if (count >= MAX_SIZE) count = MAX_SIZE-1;

while (count--) *pbuf++=getchar();
*pbuf=0;
}
26 changes: 26 additions & 0 deletions examples/n2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* n2.c *
* specially crafted to feed your brain by [email protected] */

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX_SIZE 80

unsigned int atoul(char *str) {
unsigned int answer=0;
for (;*str && isdigit(*str);
answer *= 10, answer += *str++-'0');
return answer;
}

int main(int argv, char **argc) {
char *pbuf,buf[MAX_SIZE];
int count = atoul(argc[1]);

if (count >= MAX_SIZE) count = MAX_SIZE-1;

pbuf=buf;
while (count--) *pbuf++=getchar();
*pbuf=0;
}
21 changes: 21 additions & 0 deletions examples/n3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* n3.c *
* specially crafted to feed your brain by [email protected] */

#include <stdio.h>
#include <string.h>

unsigned int count;
char **args;

int main(int argv, char **argc) {
char buf[80];

fscanf(stdin, "%u", &count);

args = alloca(count*sizeof(char*));
while (count--) {
if (!fgets(buf,sizeof buf,stdin)) break;
*args++=strdup(buf);
}
}

20 changes: 20 additions & 0 deletions examples/n4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* n4.c *
* specially crafted to feed your brain by [email protected] */

#include <stdio.h>
#include <string.h>

unsigned int count;

int main(int argv, char **argc) {
char buf[80],**args;

fscanf(stdin, "%u", &count);

args = alloca(count*sizeof(char*));
while (count--) {
if (!fgets(buf,sizeof buf,stdin)) break;
*args++=strdup(buf);
}
}

19 changes: 19 additions & 0 deletions examples/n5.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* n5.c *
* specially crafted to feed your brain by [email protected] */

#include <stdio.h>

int main(int argv, char **argc) {
char **args,buf[80];
unsigned int index,count;

fscanf(stdin, "%u", &count);
args = malloc(count*sizeof(char*));

while (1) {
fscanf(stdin,"%u %80s", &index, buf);
if (index<count) args[index] = strdup(buf);
else break;
}
}

Loading

0 comments on commit 0330bcc

Please sign in to comment.