Exemple #1
0
	def vk_login(self, cSid=None, cKey = None):
		url = "https://login.vk.com/"
		values = { "act": "login",
				   "utf8": "1",
				   "email": self.number,
				   "pass": self.password 
				   }

		if cSid and cKey:
			values["captcha_sid"] = cSid
			values["captcha_key"] = cKey

		self.http.cookies.clear()
		response = self.http.post(url, values)
		if "remixsid" in self.http.cookies:
			remixsid = self.http.cookies["remixsid"]
			self.settings["remixsid"] = remixsid

			self.settings["forapilogin"] = { "p": self.http.cookies["p"],
											 "l": self.http.cookies["l"] 
											}

			self.sid = remixsid

		elif "sid=" in response.url:
			raise authError("Authorization error (captcha)")
		else:
			raise authError("Authorization error (bad password)")

		if "security_check" in response.url:
			number_hash = webtools.regexp(r"security_check.*?hash: '(.*?)'\};", response.text)[0]

			code = self.number[2:-2]			
			if len(self.number) == 12:
				if not self.number.startswith("+"):
					code = self.number[3:-2]  		# may be +375123456789 
	
			elif len(self.number) == 13:			# so we need 1234567
				if self.number.startswith("+"):
					code = self.number[4:-2] 

			values = { "act": "security_check",
					   "al": "1",
					   "al_page": "3",
					   "code": code,
					   "hash": number_hash,
					   "to": ""
					  }
			response = self.http.post("https://vk.com/login.php", values)
			if response.text.split("<!>")[4] == "4":
				return

			raise authError("Incorrect number")
Exemple #2
0
	def loginByPassword(self):
		url = "https://login.vk.com/"
		values = { "act": "login",
				   "utf8": "1", # check if it needed
				   "email": self.number,
				   "pass": self.password 
				  }

		post = self.RIP.post(url, values)
		body, response = post
		RemixSID = self.RIP.getCookie("remixsid")

		if RemixSID:
			self.sid = RemixSID

		elif "sid=" in response.url:
			raise AuthError("Captcha!")
		else:
			raise AuthError("Invalid password")

		if "security_check" in response.url:
			Hash = webtools.regexp(r"security_check.*?hash: '(.*?)'\};", body)[0]
			code = self.number[2:-2]
			if len(self.number) == 12:
				if not self.number.startswith("+"):
					code = self.number[3:-2]  		# may be +375123456789 
	
			elif len(self.number) == 13:			# so we need 1234567
				if self.number.startswith("+"):
					code = self.number[4:-2]

			values = { "act": "security_check",
					   "al": "1",
					   "al_page": "3",
					   "code": code,
					   "hash": Hash,
					   "to": ""
					  }
			post = self.RIP.post("https://vk.com/login.php", values)
			body, response = post
			if response and not body.split("<!>")[4] == "4":
				raise AuthError("Incorrect number")