

**Notes:**
1. The questions are always in the same order
2. Sending the wrong answer will move to the next question but provide the correct answer to the previous question
**Goal:**
Write a script that collects every right answer and then sends them in order to complete the challenge
**Script:**
```Python
import requests
import re
url = "http://timesink.be/quizbot/index.php"
answers = []
header = {'User-Agent': 'Mozilla/6.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0'}
s = requests.Session()
i = 0
while i < 1000:
data = {"insert_answer":"wronganser", "submit":"answer"}
r2 = s.post(url, headers=header, cookies=s.cookies, data=data)
answer = re.findall('<div id="answer" align="center">(.*)</div>', r2.text)
answers.append(answer[0])
print(str(i) + ' ' + answer[0])
i += 1
x = 0
while x < len(answers):
data = {"insert_answer":answers[x], "submit":"answer"}
r3 = s.post(url, headers=header, cookies=s.cookies, data=data)
print('Sending answer: ' + answers[x])
if x == 999:
print(r3.text)
x += 1
```

-----
Back to [[_WebSite Publish/CTF/CTF Index|CTF Index]]
Tags: #scripting #web_scraping #ctf #python
Related: