IceCTF2018-Anticaptcha

Solution

比左個網 , 入面有百尻幾條問題 , 自動解啦咁

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
from bs4 import BeautifulSoup
from math import sqrt; from itertools import count, islice
import gmpy2

def solveQuestion(s):
if "word in the following line" in s:
s = s.replace("\n"," ").replace("."," ").replace(" "," ")
num = int(s.split(" ")[3].replace("th","").replace("st","").replace("nd","").replace("rd",""))
return s.split(": ")[1].split(" ")[num-1]
elif "a prime number" in s:
num = int(s.split(" ")[1])
return str(gmpy2.is_prime(num)).lower()
elif "What is the greatest common divisor" in s:
num1 = int(s.split(" ")[7])
num2 = int(s.split(" ")[9].replace("?", ""))
return gmpy2.gcd(num1, num2)
elif "Which planet is closest to the sun" in s:
return "Mercury"
elif "What is the capital of Germany" in s:
return "Berlin"
elif "How many planets are between Earth and the Sun?" in s:
return "2"
elif "How many strings does a violin have?" in s:
return "4"
elif "What is the tallest mountain on Earth?" in s:
return "Mount Everest"
elif "What year is it?" in s:
return "2018"
elif "What color is the sky?" in s:
return "Blue"
elif "Who directed the movie Jaws?" in s:
return "Steven Spielberg"
elif "What is the capital of Hawaii?" in s:
return "Honolulu"
else:
print s

s = requests.Session()
content = s.get("https://43xa7xhkaj0cd8c-anticaptcha.labs.icec.tf/").text
soup = BeautifulSoup(content, 'html.parser')

td_tags = soup.find_all("td")
answer = []

for i in range(0, len(td_tags), 2):
answer.append(str(solveQuestion(td_tags[i].string)))

print s.post("https://43xa7xhkaj0cd8c-anticaptcha.labs.icec.tf/", data={'answer':answer}).text[:2000]