OverTheWire
-
narnia5OverTheWire 2015. 9. 24. 03:09
#include #include #include int main(int argc, char **argv){int i = 1;char buffer[64]; snprintf(buffer, sizeof buffer, argv[1]);buffer[sizeof (buffer) - 1] = 0;printf("Change i's value from 1 -> 500. "); if(i==500){printf("GOOD\n");system("/bin/sh");} printf("No way...let me give you a hint!\n");printf("buffer : [%s] (%d)\n", buffer, strlen(buffer));printf ("i = %d (%p)\n", i, &i);return 0; } snp..
-
-
narnia 3OverTheWire 2015. 9. 21. 04:02
심볼릭으로 푸는데 어떤경로에 어떤유저가 푼 파일이있어서 그냥 setuid걸린 바이너리로 플래그를봤다..실력이 늘지않으니까 코드설명을 하자면 int main(int argc, char **argv){ int ifd, ofd; char ofile[16] = "/dev/null"; char ifile[32]; char buf[32]; if(argc != 2){ printf("usage, %s file, will send contents of file 2 /dev/null\n",argv[0]); exit(-1); } /* open files */ strcpy(ifile, argv[1]); if((ofd = open(ofile,O_RDWR)) < 0 ){ printf("error opening %s\n", ofi..