终端登录校园网的小程序


校园网登录认证采用的是GET请求,并且是明文,所以直接使用GET请求就可以完成校园网认证。

#!/usr/bin/env python
# coding=utf-8
import requests
import os

if __name__ == '__main__':
    # 校园网的ip地址是10开头的
    line = os.popen('ip a | grep "inet 10"').readline()
    base = line.find('10.')
    ip = line[base:base + 14]
    username = '你的学号'
    passwd = '你的密码'
    url = f"http://202.113.18.106:801/eportal/?c=ACSetting&a=Login&loginMethod=1&protocol=http%3A&hostname=202.113.18.106&port=&iTermType=1&wlanuserip={ip}&wlanacip=null&wlanacname=jn1_&redirect=null&session=null&vlanid=0&mac=00-00-00-00-00-00&ip={ip}&enAdvert=0&jsVersion=2.4.3&DDDDD={username}&upass={passwd}&R1=0&R2=0&R3=0&R6=0&para=00&0MKKey=123456&buttonClicked=&redirect_url=&err_flag=&username=&password=&user=&cmd=&Login="
    print(url)
    requests.get(url=url)

Author: 蒋璋
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source 蒋璋 !