项目已删除
wolfbolin / ncov-csu-edu Goto Github PK
View Code? Open in Web Editor NEWA tool to help users check in automatically
A tool to help users check in automatically
你好前辈我这里已经把新的认证弄好了,贴一下代码希望能帮上忙?
from Cryptodome.Cipher import AES
from binascii import b2a_hex, a2b_hex
import base64
import random
from bs4 import BeautifulSoup
import requests
from requests import session
# ses = session()
saltStorage = None
exeStorage = None
def randomaesstring(x: int):
return ''.join(random.choices("ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678", k=x))
class prpcrypt():
@staticmethod
def pad(s):
return s + (AES.block_size - len(s) % AES.block_size) * chr(AES.block_size - len(s) % AES.block_size)
#定义 padding 即 填充 为PKCS7
@staticmethod
def unpad(s):
return s[0:-ord(s[-1])]
def __init__(self, key):
self.key = key
self.mode = AES.MODE_CBC
# AES的加密模式为CBC
def encrypt(self, text, iv):
text = prpcrypt.pad(text)
cryptor = AES.new(self.key.encode('utf-8'), self.mode, iv.encode('utf-8'))
#第二个self.key 为 IV 即偏移量
x = len(text) % 8
if x != 0:
text = text + '\0' * (8 - x) # 不满16,32,64位补0
# print(text)
self.ciphertext = cryptor.encrypt(text.encode('utf-8'))
return base64.standard_b64encode(self.ciphertext).decode("utf-8")
def decrypt(self, text):
cryptor = AES.new(self.key, self.mode, self.key)
de_text = base64.standard_b64decode(text)
plain_text = cryptor.decrypt(de_text)
st = str(plain_text.decode("utf-8")).rstrip('\0')
out = prpcrypt.unpad(st)
return out
def generate_auth(pw: str, key: str):
iv = randomaesstring(16)
word = randomaesstring(64) + pw
pr = prpcrypt(key)
return pr.encrypt(word, iv)
def get_aes_salt(ses: session):
# headers = {
# "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
# "Accept-Encoding":"gzip, deflate, br",
# "Accept-Language":"zh-CN,zh;q=0.9",
# "Cache-Control":"no-cache",
# "Connection":"keep-alive",
# "DNT":"1",
# "Host":"ca.csu.edu.cn",
# "Pragma":"no-cache",
# "Sec-Fetch-Dest":"document",
# "Sec-Fetch-Mode":"navigate",
# "Sec-Fetch-Site":"none",
# "Sec-Fetch-User":"?1",
# "Upgrade-Insecure-Requests":"1",
# "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
# }
req = ses.get('https://ca.csu.edu.cn/authserver/login?service=https%3A%2F%2Fwxxy.csu.edu.cn%2Fa_csu%2Fapi%2Fcas%2Findex%3Fredirect%3Dhttps%253A%252F%252Fwxxy.csu.edu.cn%252Fncov%252Fwap%252Fdefault%252Findex%253Ffrom%253Dhistory%26from%3Dwap')
B = BeautifulSoup(req.text, "html.parser")
saltobj = B.find('input', attrs={'id':'pwdEncryptSalt'})
exeobj = B.find('input', attrs={'id':'execution'})
global saltStorage, exeStorage
if saltobj:
saltStorage = saltobj
else:
saltobj = saltStorage
if exeobj:
exeStorage = exeobj
else:
exeobj = exeStorage
# print(saltobj['value'])
# print(exeobj['value'])
return saltobj['value'], exeobj['value']
def r2(ses: session, user: str, pw: str):
salt, exe = get_aes_salt(ses)
form = {
"username":user, #
"password":generate_auth(pw, salt), #
"captcha":None,
"rememberMe":True,
"_eventId":"submit",
"cllt":"userNameLogin",
"dllt":"generalLogin",
"lt":None,
"execution": exe
}
lnk = 'https://ca.csu.edu.cn/authserver/login?service=https%3A%2F%2Fwxxy.csu.edu.cn%2Fa_csu%2Fapi%2Fcas%2Findex%3Fredirect%3Dhttps%253A%252F%252Fwxxy.csu.edu.cn%252Fncov%252Fwap%252Fdefault%252Findex%253Ffrom%253Dhistory%26from%3Dwap'
req = ses.post(lnk, data=form)
print(req.history)
print(req)
# print(req.text)
if __name__ == "__main__":
r2()
另外我这边的脚本也大概确定可用了
CSU has deprecated the old login page (old page ) and has banned the access to this page formally today.
Now all the login requests will be redirected to the new login page. (new page ) Since the script takes the old page as the entrance to get the user infomation and cookies, it may cause the issue that new user cannot enjoy the service.
Possible solutions:
I am working for this as well. Since the limited ability and time I have, I still hope u can fix this issue.
Thanks!
用过一个项目bilibili task,使用的是GitHub action的方法,具体的形式是用户将项目fork到自己的仓库,在secrets中填写参数,然后启动action即可每天定期完成签到工作,我觉得是可以迁移到本项目的,同时可以将服务器的负担转移给GitHub,而且用户也相对不用担心个人数据泄露的问题
The check-in function cannot be used today
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.