Exemplo n.º 1
0
 def create_new_user(datas):
     return DarkNet_User.create(**datas)
Exemplo n.º 2
0
 def Reg(self):
     self.warn("Start Regging")
     headers = {
         "Accept":
         "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
         "Accept-Encoding":
         "gzip, deflate",
         "Accept-Language":
         "zh-CN,zh;q=0.9,en;q=0.8",
         "Cache-Control":
         "no-cache",
         "Connection":
         "keep-alive",
         "Content-Type":
         "application/x-www-form-urlencoded",
         "Origin":
         f"http://{self.domain}",
         "Pragma":
         "no-cache",
         "Referer":
         f"http://{self.domain}/ucp.php?mode=register&sid={self.sid}",
         "Upgrade-Insecure-Requests":
         "1",
         "User-Agent":
         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
     }
     step1resp = self.session.get(
         f"http://{self.domain}/ucp.php?mode=register").text
     step1 = jq(step1resp)
     self.info(f'RegPage Confirmed. {"sid" in step1resp}')
     token = step1('input[name="form_token"]').attr("value")
     self.report(f"Got Token: {token}")
     creation_time = step1('input[name="creation_time"]').attr("value")
     self.report(f"Got Create_time: {creation_time}")
     url = f"http://{self.domain}/ucp.php?mode=register"
     step2resp = self.session.post(
         url,
         data={
             "agreed": "===好的,我已明白,请跳转到下一页继续注册====",
             "change_lang": "",
             "creation_time": creation_time,
             "form_token": token,
         },
         headers=headers,
     )
     self.SaveError("step2.html", step2resp)
     step2 = jq(step2resp.text)
     token = step2('input[name="form_token"]').attr("value")
     creation_time = step2('input[name="creation_time"]').attr("value")
     qa_answer = re.findall("请在右边框中输入: (.*?):</label>", step2resp.text)[0]
     self.report(f"Got answer: {qa_answer}")
     qa_confirm_id = step2("#qa_confirm_id").attr("value")
     self.usr = self.RandomKey(12)
     self.pwd = self.RandomKey()
     self.info(f"set Usr: {self.usr} ,Pwd: {self.pwd}")
     data = {
         "username":
         self.usr,
         "new_password":
         self.pwd,
         "password_confirm":
         self.pwd,
         "email":
         "*****@*****.**",
         "lang":
         "zh_cmn_hans",
         "tz_date":
         "UTC+08:00+-+Asia/Brunei+-+" +
         moment.now().format("DD+MM月+YYYY,+HH:mm"),
         "tz":
         "Asia/Hong_Kong",
         "agreed":
         "true",
         "change_lang":
         "0",
         "qa_answer":
         qa_answer,
         "qa_confirm_id":
         qa_confirm_id,
         "submit":
         " 用户名与密码已填好,+点此提交 ",
         "creation_time":
         creation_time,
         "form_token":
         token,
     }
     resp = self.session.post(url, data=data, headers=headers)
     try:
         assert "感谢注册" in resp.text
         self.report("Reg success!")
         DarkNet_User.create(**{"user": self.usr, "pwd": self.pwd})
     except AssertionError:
         self.error(jq(resp.text).text())
         self.SaveError("reg.html", resp)