Added statut checking after connection
This commit is contained in:
parent
41bb580c96
commit
814504f23b
57
main.py
57
main.py
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
@ -5,58 +7,37 @@ username = "username"
|
|||
password = "password"
|
||||
|
||||
ses = requests.Session()
|
||||
ses.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0"
|
||||
ses.headers["Connection"] = "keep-alive"
|
||||
ses.headers = {"Origin": "https://alcasar-0320002d.smile-education.fr", "Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
"Sec-Fetch-Mode": "navigate", "Connection": "keep-alive",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
|
||||
"Content-Type": "application/x-www-form-urlencoded", "Sec-Fetch-Site": "same-origin",
|
||||
"Sec-Fetch-Dest": "document", "Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Sec-Fetch-User": "?1"}
|
||||
connection_page = ses.get("http://detectportal.firefox.com/canonical.html")
|
||||
soup = BeautifulSoup(connection_page.text, features="html.parser")
|
||||
input_challenge = soup.find("input", {"name": "challenge"})
|
||||
|
||||
challenge = input_challenge["value"]
|
||||
|
||||
"""
|
||||
POST /intercept.php HTTP/1.1
|
||||
Host: alcasar-0320002d.smile-education.fr
|
||||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
|
||||
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
|
||||
Accept-Encoding: gzip, deflate, br
|
||||
Referer: https://alcasar-0320002d.smile-education.fr/intercept.php?res=failed&reason=reject&uamip=10.124.31.254&uamport=3990&challenge=14ede6ce0f123f55e8ef11310225fa03&called=00-15-5D-FF-2F-01&mac=30-03-C8-0F-F8-76&ip=10.124.26.117&reply=Login%20failed&nasid=alcasar-0320002d.smile-education.fr&sessionid=654a2a5d00000069&ssl=https%3a%2f%2f1.0.0.1%3a3991%2f&redirurl=&userurl=http%3a%2f%2fdetectportal.firefox.com%2fcanonical.html&md=97358BCC59AF443F0454EF5FB5F21635
|
||||
Content-Length: 162
|
||||
Origin: https://alcasar-0320002d.smile-education.fr
|
||||
Connection: keep-alive
|
||||
Upgrade-Insecure-Requests: 1
|
||||
Sec-Fetch-Dest: document
|
||||
Sec-Fetch-Mode: navigate
|
||||
Sec-Fetch-Site: same-origin
|
||||
Sec-Fetch-User: ?1
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Pragma: no-cache
|
||||
Cache-Control: no-cache"""
|
||||
|
||||
data = f"challenge={challenge}&userurl=http%3A%2F%2Fdetectportal.firefox.com%2Fcanonical.html&username={username}&password={password}&button=Authentification"
|
||||
resp = ses.post("https://alcasar-0320002d.smile-education.fr/intercept.php",
|
||||
data=data,
|
||||
allow_redirects=False, headers={"Origin": "https://alcasar-0320002d.smile-education.fr",
|
||||
"Referer": connection_page.url,
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
"Sec-Fetch-Mode": "navigate",
|
||||
"Connection": "keep-alive",
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
"Sec-Fetch-Dest": "document",
|
||||
"Accept-Language": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3",
|
||||
"Sec-Fetch-User": "?1"})
|
||||
"Referer": connection_page.url})
|
||||
|
||||
print(resp.text)
|
||||
#redirect = resp.headers["Location"]
|
||||
redirect = resp.headers["Location"]
|
||||
|
||||
#print(redirect)
|
||||
print(resp.headers)
|
||||
print(redirect)
|
||||
|
||||
#print(ses.get(redirect).text)
|
||||
ses.get(redirect)
|
||||
|
||||
#print(ses.get("http://alcasar-0320002d.smile-education.fr/status.php").text)
|
||||
statut = json.loads(
|
||||
ses.get("http://alcasar-0320002d.smile-education.fr:3990/json/status?callback=chilliJSON.reply").text[17:-1])
|
||||
|
||||
#print(ses.get(redirect).content)
|
||||
if statut["clientState"]:
|
||||
print("Successfully connected!")
|
||||
else:
|
||||
print("An error occured")
|
Loading…
Reference in a new issue