Giter Club home page Giter Club logo

ncov-csu-edu's Introduction

CSU-COVID19-SIGN

项目已删除

ncov-csu-edu's People

Contributors

kongmoumou avatar wolfbolin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ncov-csu-edu's Issues

新的网站认证获取令牌

你好前辈我这里已经把新的认证弄好了,贴一下代码希望能帮上忙?

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()

另外我这边的脚本也大概确定可用了

Old login page has been deprecated

CSU has deprecated the old login page (old page ) and has banned the access to this page formally today.

IMG_20210518_102030

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:

  1. New login page uses AES algorithm to encrypt the user password (with a fixed salt and some random string). Maybe we can take the same encryption to login and get the cookies again.
  2. New login page still retain the HTTP page although it has HTTPS page. To ban some js files may be able to bypass the encryption.
    Once cookies have obtained, it will work again.

I am working for this as well. Since the limited ability and time I have, I still hope u can fix this issue.

Thanks!

另一种形式?(GitHub action)

用过一个项目bilibili task,使用的是GitHub action的方法,具体的形式是用户将项目fork到自己的仓库,在secrets中填写参数,然后启动action即可每天定期完成签到工作,我觉得是可以迁移到本项目的,同时可以将服务器的负担转移给GitHub,而且用户也相对不用担心个人数据泄露的问题

提一些建议,关于隐私和推送

腾讯云函数

腾讯云函数已经支持完整的node.js运行环境,函数可以运行在用户的腾讯云函数上,从而保证不会泄露账号和密码

Sever酱等免费推送服务

推送服务支持将打卡日志推送到微信。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.