forked from deadbits/InsecureProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
616 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,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]); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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]); | ||
} |
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,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]); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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]); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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); | ||
} |
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,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]); | ||
} |
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,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]); | ||
} |
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,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); | ||
} | ||
|
||
|
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,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); | ||
} |
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,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; | ||
} |
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,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; | ||
} |
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,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); | ||
} | ||
} | ||
|
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,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); | ||
} | ||
} | ||
|
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,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; | ||
} | ||
} | ||
|
Oops, something went wrong.