# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ctf.zeyu2001.com/2021/dawgctf-2021/two-truths-and-a-fib.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
