Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问可以不依赖Selenium吗? #7

Open
forest0 opened this issue Jan 26, 2021 · 3 comments
Open

请问可以不依赖Selenium吗? #7

forest0 opened this issue Jan 26, 2021 · 3 comments

Comments

@forest0
Copy link

forest0 commented Jan 26, 2021

感觉应该可以先登录获取认证后的授权字段(应该在cookie里吧),
然后带上这个授权字段直接上报数据就行了?

@wangxinzhi0
Copy link

你申请入校时,可以上传健康码?这个图片我实在不会上传,呜呜呜

@StephenHoo
Copy link
Owner

应该是可以的,如果有时间的话我来研究一下

@forest0
Copy link
Author

forest0 commented Jan 27, 2021

看了下统一身份认证处的用户密码加密逻辑,可能用得上
依赖pycryptodome==3.9.9

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import base64
import random

def random_string(length):
    CHARS = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
    ret = ''
    for _ in range(length):
        ret += CHARS[random.randrange(0, len(CHARS))]
    return ret

def encrypt_password(password, key):
    def encrypt_by_AES(data, key, iv):
        key = bytes(key.strip(' ') , encoding='utf8')
        assert(len(key) == AES.block_size)
        iv = bytes(iv, encoding='utf8')
        assert(len(iv) == AES.block_size)
        data = bytes(data, encoding='utf8')
        cipher = AES.new(key, AES.MODE_CBC, iv)
        return cipher.encrypt(pad(data, AES.block_size, style='pkcs7'))

    enc = encrypt_by_AES(random_string(64)+password, key, random_string(16))
    return base64.b64encode(enc)

def test():
    password = 'user_input_password'
    # this variable is from the login page
    pwdDefaultEncryptSalt = 'xxxxxxxxxxxxxxxx'
    password_send_to_server = encrypt_password(password, pwdDefaultEncryptSalt)
    print(password_send_to_server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants