Rating:

We're told to:
`nc secretarray.fword.wtf 1337`

**###### Secret Array Challenge Prompt:**
> I have a 1337 long array of secret positive integers. The only information I can provide is the sum of two elements. You can ask for that sum up to 1337 times by specifing two different indices in the array.
>
> [!] - Your request should be in this format : "i j". In this case, I'll respond by arr[i]+arr[j]
>
> [!] - Once you figure out my secret array, you should send a request in this format: "DONE arr[0] arr[1] ... arr[1336]"
>
> [ ] - Note 1: If you guessed my array before 1337 requests, you can directly send your DONE request.
>
> [ ] - Note 2: The DONE request doesn't count in the 1337 requests you are permitted to do.
>
> [ ] - Note 3: Once you submit a DONE request, the program will verify your array, give you the flag if it's a correct guess, then automatically exit.
>
> START:

So an example input we could provide:
0 1

Which could give us back the sum:
731986113164683230602132487650

Let it be known the array and its values change per netcat session, so it's time to program

```
#!/usr/bin/env python3

import socket

host = "secretarray.fword.wtf"
port = 1337

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
send = lambda x: s.send("{}\n".format(x).encode())
def get_response():
resp = s.recv(1024)
if not resp:
raise ConnectionError("Could not connect properly..")
try:
return int(resp.decode())
except:
return resp.decode()

get_response()

#Initial setup, we'll do indices (0 + 1), (1 + 2), and (0 + 2) for a linear equation set:
values = []
index = 0
a = index
b = index + 1
c = index + 2
row1 = "{} {}".format(a, b) #a + b = x
row2 = "{} {}".format(b, c) #b + c = y
row3 = "{} {}".format(a, c) #a + c = z
send(row1) #0 1
x = get_response()
get_response()
send(row2) #1 2
y = get_response()
get_response()
send(row3) #0 2
z = get_response()
get_response()

#Just gonna wolfram it (linear system of equations) :l
print("Plug this into wolfram's linear system of equations:")
print("a + b = {}".format(x))
print("b + c = {}".format(y))
print("a + c = {}".format(z))
a = input("What does wolfram say A is?\n")
values.append(int(a))
b = input("What does wolfram say B is?\n")
values.append(int(b))
c = input("What does wolfram say C is?\n")
values.append(int(c))

index = 3
#I know that was fun but hey now that we have the value of a,
#n = sum - a, right? I'd have iterated for B and C but 1337 attempts
print("Iterating..")
while index < 1337:
if index % 100 == 0:
percentage = round((index / 1337) * 100, 2)
print("{}% complete..".format(percentage))
row = "0 {}".format(index)
send(row)
x = get_response()
get_response()
n = int(x - values[0])
values.append(n)
index += 1

done_string = "DONE {}".format(' '.join(map(str, values)))
send(done_string)
result = get_response()
print(result)
res2 = get_response()
print(res2)
s.close()
```

![](https://cdn.discordapp.com/attachments/746682756607770675/749512294269976606/unknown.png)