> For the complete documentation index, see [llms.txt](https://ctf.zeyu2001.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ctf.zeyu2001.com/2021/dawgctf-2021/two-truths-and-a-fib.md).

# Two Truths and a Fib

## Problem

Can you catch the fibber?

nc umbccd.io 6000

Author: Trashcanna

## Solution

![](/files/-M_EPF3aOnbtJvwNeSf-)

```python
import math
from pwn import *

# A utility function that returns true if x is perfect square
def isPerfectSquare(x):
    s = int(math.sqrt(x))
    return s*s == x

# Returns true if n is a Fibinacci Number, else false
def isFibonacci(n):

    # n is Fibinacci if one of 5*n*n + 4 or 5*n*n - 4 or both
    # is a perferct square
    return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4)

conn = remote('umbccd.io', 6000)

done = False
while not done:
    print(conn.recvuntil('['))
    arr = eval('[' + conn.recvline().decode())

    print(arr)
    print(conn.recv())

    for num in arr:
        if isFibonacci(num):
            print(num)
            conn.send(str(num) + '\r\n')
            break

    print(conn.recv())

conn.close()
```

Eventually we get the flag:

![](/files/-M_EPIi9uAWKSOaatFbT)
