Skip to content

Commit

Permalink
Added a challenge that might actually be impossible
Browse files Browse the repository at this point in the history
  • Loading branch information
ewimberley committed Jan 31, 2014
1 parent 1127a9b commit 21a6fe1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -2,6 +2,7 @@ all:
g++ -I./ -g -o 1.bin -fstack-protector-all 1.cpp
g++ -I./ -g -o 2.bin -fstack-protector-all 2.cpp
g++ -I./ -g -o 3.bin -fstack-protector-all 3.cpp
g++-4.8 -I./ -g -o 4.bin -fsanitize=address 4.cpp
g++-4.8 -I./ -g -ftrapv -o 4.bin -fsanitize=address 4.cpp
g++-4.8 -I./ -g -ftrapv -o impossible.bin -ftrapv -fsanitize=address impossible.cpp
clean:
rm -f *.bin *.o *.so *_expanded.cpp
42 changes: 42 additions & 0 deletions impossible.cpp
@@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void handler(int sig)
{
printf("nice try, must be less than 10...\n");
}

int a(){
long position = 0;
char in;
char buff2[10] = "dir";
char buff[10];
printf("buff position: %p\n", buff);
printf("buff2 position: %p\n", buff2);
scanf("%ld", &position);
printf("position: %ld\n", position);
if(position < 0){
printf("nice try, must be more than 0...\n");
exit(1);
}
position = position*2;
printf("position*2: %ld\n", position);
in = 0;
while(position < 10 && in != '\n'){
scanf("%c", &in);
buff[position] = in;
printf("%d\n", position);
position++;
}
//scanf("%s", buff);
printf("buff: %s\n", buff);
printf("buff2: %s\n", buff2);
system(buff2);
}

int main(){
signal(SIGABRT, &handler);
a();
return 0;
}

0 comments on commit 21a6fe1

Please sign in to comment.