AUST自助上网-Python

longxin liu 发布于 2024-05-10 372 次阅读


from requests import post
import urllib.request
from urllib.error import URLError
from time import sleep
import threading
url = "http://10.255.0.19/a79.htm" #学校认证地址
print("----------------AUST-认证脚本------------------")
user = input("学号:") #你的学号
password = input("密码:") #你的密码
server = input("\n电信:aust\n联通:unicom\n移动:cmcc\n运营商: ") #电信aust 联通改为 unicom 移动改为 cmcc
#发送的数据包
data = {
"callback": "dr1003",
"DDDDD": "{}@{}".format(user, server),
"upass": "{}".format(password),
"0MKKey": "123456",
"R1": "0",
"R3": "0",
"R6": "0",
"para": "00",
"v6ip": "",
"v": ""
}
# 标志变量用于控制线程的执行
stop_flag = False
#检查是否连接到外部网络
def check_internet_connection():
try:
url = 'https://www.baidu.com'
headers = {'User-Agent': 'Mozilla/5.0', 'Content-Length': '1'} # Modify the Content-Length header value as needed
req = urllib.request.Request(url, headers=headers)
urllib.request.urlopen(req, timeout=1)
return True
except URLError:
return False
#检查用户输入,并判断是否退出程序
def user_input_thread():
while True:
global stop_flag #引入全局变量
user_input = input() # 获取用户输入
if (user_input.lower() == "q"):
stop_flag = True #标志置是
break #退出循环
# 创建一个线程来处理用户输入
input_thread = threading.Thread(target=user_input_thread)
input_thread.start()
#主函数(执行检测,并判断发送数据包)
while not stop_flag:
if check_internet_connection():
print("\r已连接到Internet", end = ' ')
#pass
else:
print("未连接到Internet, 正在尝试重新连接...")
conn = post(url=url, data=data) #发送数据包
sleep(1) # 每隔1秒进行一次检测
import requests
import urllib.request
import time
import threading
url = "http://10.255.0.41/0.htm" #学校认证地址
print("----------------AUST-认证脚本------------------")
# user = input("学号:")   #你的学号
# password = input("密码:")    #你的密码
# server = input("\n电信:aust\n联通:unicom\n移动:cmcc\n运营商: ")  #电信aust 联通改为 unicom 移动改为 cmcc
#发送的数据包
data = {
    "DDDDD":"",
    "upass":"",
    "0MKKey":"%B5%C7%A1%A1%C2%BC",
    "v6ip":""
}
# 标志变量用于控制线程的执行
stop_flag = False
#检查是否连接到外部网络
def check_internet_connection():
    try:
        url = 'https://www.baidu.com'
        headers = {'User-Agent': 'Mozilla/5.0', 'Content-Length': '1'}  # Modify the Content-Length header value as needed
        req = urllib.request.Request(url, headers=headers)
        urllib.request.urlopen(req, timeout=1)
        return True
    except urllib.error.URLError:
        return False
#检查用户输入,并判断是否退出程序
def user_input_thread():
    while True:
        global stop_flag #引入全局变量
        user_input = input()  # 获取用户输入
        if (user_input.lower() == "q"):
            stop_flag = True #标志置是
            break #退出循环
# 创建一个线程来处理用户输入
input_thread = threading.Thread(target=user_input_thread)
input_thread.start()
#主函数(执行检测,并判断发送数据包)
while not stop_flag:
    if check_internet_connection():
        print("已连接到Internet")
        #pass
    else:
        print("未连接到Internet")
        print("正在尝试重新连接...")
        conn = requests.post(url=url, data=data) #发送数据包
    time.sleep(2)  # 每隔2秒进行一次检测
此作者没有提供个人介绍
最后更新于 2024-07-09