Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import codecs
- import urllib.parse
- import urllib.request
- import configparser
- import os.path
- import http
- import zlib
- import json
- import re
- import base64
- import time
- import random
- url = "www.vocabulary.com"
- cookie = ""
- secret = ""
- config = configparser.ConfigParser()
- mchoice = re.compile(r"nonce\=\"([^\"]+)(.|\n)+?word=\"([^\"]+).+?")
- lastTime = time.time()
- def rpost(path, body = None, method = "POST"):
- global cookie
- client = http.client.HTTPSConnection(url, 443)
- client.request(method, path, body = body, headers = {
- "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0",
- "Accept-Language": "en-US,en;q=0.5",
- "Accept": "application/json, text/javascript, */*; q=0.01",
- "Accept-Encoding": "gzip, deflate, br",
- "DNT": "1",
- "Cookie": cookie,
- "Referer": "https://www.vocabulary.com/lists/1329479/practice",
- "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
- "Connection": "keep-alive"
- })
- res = client.getresponse()
- data = res.read()
- if res.getheader("Content-Encoding") == "gzip":
- data = zlib.decompress(data, zlib.MAX_WBITS + 16)
- return data
- def answer(a):
- global secret
- time.sleep(random.randint(1, 6))
- params = "a=" + a + "&t=" + "{:.0f}".format(time.time() * 1000) + "&rt=" + "{:.0f}".format((time.time() - lastTime) * 1000) + "&secret=" + urllib.parse.quote(secret, safe = "")
- res = rpost("/challenge/saveanswer.json", params)
- data = json.loads(res.decode("utf-8"))
- secret = data["secret"]
- def start():
- global secret
- res = rpost("/challenge/start.json", "secret=" + urllib.parse.quote(secret, safe = "")
- data = json.loads(res.decode("utf-8"))
- secret = data["secret"]
- def handleText(data):
- adata = base64.b64decode(data["adata"].encode("utf-8")).decode("utf-8")
- adata = codecs.encode(adata, "rot_13")
- adata = json.loads(adata)
- print("answering with word " + adata["acceptedAnswers"][0])
- answer(adata["acceptedAnswers"][0])
- def handleP(data):
- adata = base64.b64decode(data["adata"].encode("utf-8")).decode("utf-8")
- adata = codecs.encode(adata, "rot_13")
- adata = json.loads(adata)
- ans = adata["nonces"][0]
- print("answering with word " + ans)
- answer(ans)
- def reset():
- rpost("/lists/" + config["Main"]["wordlistid"] + "/reset", method = "GET")
- print("RESET")
- def next():
- global secret
- res = rpost("/challenge/nextquestion.json", "secret=" + urllib.parse.quote(secret, safe = ""))
- print(res.decode("utf-8"))
- data = json.loads(res.decode("utf-8"))
- secret = data["secret"]
- # code = base64.b64decode(data["code"].encode("utf-8")).decode("utf-8")
- qtype = data["qtype"]
- print(qtype)
- if qtype == "T": # text box
- handleText(data)
- elif qtype == "S" or qtype == "P" or qtype == "F" or qtype == "A" or qtype == "D" or qtype == "L" or qtype == "H" or qtype == "I":
- handleP(data)
- elif qtype == "activityComplete":
- reset()
- else:
- print("COULD NOT ANSWER")
- def main():
- global cookie
- config["Main"] = {"AWSELB": "blank", "JSESSIONID": "blank", "_asid": "blank", "autologin": "1", "guid": "blank", "tz": "America/New_York", "wordlistid": "1329479"}
- if not os.path.isfile("config.ini"):
- with open("config.ini", "w") as configfile:
- config.write(configfile)
- config.read("config.ini")
- cookie = "tz=" + config["Main"]["tz"] + "; _asid=" + config["Main"]["_asid"] + "; AWSELB=" + config["Main"]["AWSELB"] + "; JSESSIONID=" + config["Main"]["JSESSIONID"] + "; guid=" + config["Main"]["guid"] + "; autologin=" + config["Main"]["autologin"]
- print(cookie)
- start()
- while (True):
- next()
- print("ANSWERED")
- time.sleep(random.randint(1, 2))
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement