Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from base64 import b64encode
- from random import choices
- from Crypto.Cipher import AES
- from more_itertools import first
- from requests_html import HTMLSession
- url_login = 'https://webvpn.ujs.edu.cn/https/77726476706e69737468656265737421e0f6528f69256243300d8db9d6562d/cas/login'
- username = 'asdf'
- pwd = '123456'
- def pad(m):
- return m+chr(16-len(m)%16)*(16-len(m)%16)
- def unpad(ct):
- return ct[:-ord(ct[-1])]
- def rds(n):
- return ''.join(choices('ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678', k=n))
- # getting initial variable
- s = HTMLSession()
- r = s.get(url_login)
- html = r.html
- salt = first(html.xpath('//input[@id="pwdDefaultEncryptSalt"]/@value'), None)
- lt = first(html.xpath('//input[@name="lt"]/@value'), None)
- dllt = first(html.xpath('//input[@name="dllt"]/@value'), None)
- execution = first(html.xpath('//input[@name="execution"]/@value'), None)
- rmShown = first(html.xpath('//input[@name="rmShown"]/@value'), None)
- # encrypt password
- key = salt.encode()
- cipher = AES.new(key, AES.MODE_CBC, iv=rds(16).encode())
- encrypted_pwd = b64encode(cipher.encrypt((pad(rds(64)+pwd)).encode()))
- d = {
- 'username': username,
- 'password': encrypted_pwd,
- 'lt': lt,
- 'dllt': dllt,
- 'execution': execution,
- '_eventId': 'submit',
- 'rmShown': rmShown,
- }
- r = s.post(url_login, d)
- if __name__ == '__main__':
- pass
Add Comment
Please, Sign In to add comment