INCOMPLETE: Login system
This commit is contained in:
commit
a672e0fa23
|
@ -0,0 +1,91 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import time
|
||||
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:74.0)
|
||||
Gecko/20100101 Firefox/74.0'}
|
||||
loginPage = 'https://admin.hostpoint.ch/customer/Auth/Login'
|
||||
loginAction = 'https://admin.hostpoint.ch/customer/Auth/Login?site=%2Fcustomer%2FIndex%3Flang%3Dde%26suppress_errors%3D1'
|
||||
|
||||
def preparePayload(session):
|
||||
|
||||
s = session.get(loginPage)
|
||||
|
||||
soup = BeautifulSoup(s.text, 'html.parser')
|
||||
csrf = soup.find('input', {"name" : "csrf_token"})['value']
|
||||
vscheck = soup.find('input', {"name" : "__vscheck__"})['value']
|
||||
viewstate = soup.find('input', {"name" : "__viewstate__"})['value']
|
||||
dflt_vsid = soup.find('input', {"name" : "_dflt_vsid_"})['value']
|
||||
vsid = soup.find('input', {"name" : "_vsid_"})['value']
|
||||
vsid__vsm_data_vscheck = soup.find('input', {"name" : "_vsid__vsm_data_vscheck_"})['value']
|
||||
vsid__vsm_data_viewstate = soup.find('input', {"name" : "_vsid__vsm_data_viewstate_"})['value']
|
||||
page_uuid = soup.find('input', {"name" : "__page_uuid__"})['value']
|
||||
|
||||
return {"username": "jeanggi90@gmail.com",
|
||||
"password": "`^0oVc2Yd9`tQ&l]&4X04QNV<",
|
||||
"locale": "de_CH",
|
||||
"cloud_office_host": "",
|
||||
"csrf_token": csrf ,
|
||||
"action_login": "",
|
||||
"g_main_locale": "de_CH",
|
||||
"__vscheck__": vscheck ,
|
||||
"__viewstate__": viewstate ,
|
||||
"_dflt_vsid_": dflt_vsid ,
|
||||
"_vsid_": vsid ,
|
||||
"_vsid__vsm_data_vscheck_": vsid__vsm_data_vscheck ,
|
||||
"_vsid__vsm_data_viewstate_": vsid__vsm_data_viewstate ,
|
||||
"__is_dirty__": "False",
|
||||
"__dirty_actions__": "[\"apply\",+\"save\"]",
|
||||
"__page_uuid__": page_uuid ,
|
||||
"__usage_count__": "",
|
||||
"__usage_max_count__": ""
|
||||
}
|
||||
|
||||
def manageCookies(session):
|
||||
|
||||
s = session.get(loginPage)
|
||||
|
||||
cookies = {}
|
||||
|
||||
for e in s.headers['Set-Cookie'].split(';'):
|
||||
cookie = e.split('=')
|
||||
try:
|
||||
cookies[cookie[0].strip()] = cookie[1].strip()
|
||||
except:
|
||||
cookies[cookie[0].strip()] = True
|
||||
|
||||
headers['cookie'] = cookies["secure, _SID_customer"]
|
||||
|
||||
session.headers.update(headers)
|
||||
|
||||
def login(session, payload):
|
||||
|
||||
s = session.post(loginAction, headers=headers, data=payload)
|
||||
|
||||
print(s.status_code)
|
||||
|
||||
def getLoggedIn(session):
|
||||
# Navigate to the next page and scrape the data
|
||||
s = session.get('https://admin.hostpoint.ch/customer/Index')
|
||||
|
||||
print(s.status_code)
|
||||
|
||||
soup = BeautifulSoup(s.text, 'html.parser')
|
||||
print(soup.prettify())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
with requests.Session() as sess:
|
||||
|
||||
sess.headers.update(headers)
|
||||
|
||||
payload = preparePayload(sess) manageCookies(sess)
|
||||
|
||||
login(sess, payload) time.sleep(10)
|
||||
print(sess.cookies)
|
||||
getLoggedIn(sess)
|
||||
|
||||
|
Loading…
Reference in New Issue