A simple Python script that detects network disconnections and automatically re-login to NCUT network.
Tested to work in all NCUT network environments including dorm ethernet, lab networks, school WiFi, and multi-NAT conditions.
Compatible with Windows 11, Ubuntu, and Android.
一個簡單的 Python 腳本,透過檢測網路斷線,自動重新登入勤益網路。
已在所有勤益網路環境中測試可用,包括養浩學舍有線網路、實驗室網路、學校WiFi以及多層NAT環境。
相容 Windows 11、Ubuntu 和 Android。
- ✅ Universal Compatibility - Works in all NCUT network environments
全域相容 - 在所有勤益網路環境中均可使用 - ✅ Multi-NAT Support - Functions correctly even behind multiple routers
多層NAT支援 - 即使在多層路由器環境下也能正常運作 - ✅ Cross-Platform - Tested on Windows 11, Ubuntu, and Android 跨平台 - 已在 Windows 11、Ubuntu 和 Android 上測試
- ✅ No IP Dependency - No longer requires device IP address detection
無IP依賴 - 不再需要檢測裝置 IP 位址 - ✅ Auto-Detection - Automatically detects network status and performs login
自動檢測 - 自動檢測網路狀態並執行登入 - ✅ Secure - No collection or transmission of user credentials
安全 - 不會蒐集或傳輸使用者憑證 - ✅ Lightweight - Low resource consumption, suitable for running in background
輕量 - 資源消耗低,適合背景執行
- Download Windows-One-Click-Installer.bat (right click, save link as)
下載 Windows-One-Click-Installer.bat(右鍵,另存連結為) - Right click - Run as administrator
右鍵點擊 - 以系統管理員身份執行 - Enjoy :)
享受自動登入 :)
wget 'https://raw.githubusercontent.com/apple050620312/NCUT-Internet-Auto-Login/refs/heads/main/Linux-One-Click-Installer.sh'chmod +x Linux-One-Click-Installer.sh./Linux-One-Click-Installer.sh
- 於 ailife8881/ncut-internet-auto-login-android 下載 APK
- 安裝並給予所需的權限
- 啟動自動登入的服務並連線至 Wi-Fi
-
Install Python
安裝 Python
-
Win + RtypecmdpressEnterWin + R輸入cmd按Enter -
In cmd type
pip install requests在 cmd 中輸入
pip install requests -
Download
NCUT_Internet_Auto_Login.pyfile下載
NCUT_Internet_Auto_Login.py這個檔案 -
Double-click to run the script
點兩下開啟腳本即可
apt-get install python3pip3 install requestswget 'https://raw.githubusercontent.com/apple050620312/NCUT-Internet-Auto-Login/refs/heads/main/NCUT_Internet_Auto_Login.py'python3 NCUT_Internet_Auto_Login.py
- Install Termux from F-Droid or Google Play
從 F-Droid 或 Google Play 安裝 Termux
(I don't really like Termux but, it is really lightweight though, but if Termux failed, use UserLAnd instead)
(我其實不太喜歡 Termux,但它真的很輕量。如果 Termux 失敗,可以改用 UserLAnd。) - Open Termux and type:
打開 Termux 並輸入:pkg update pkg install python pip install requests wget 'https://raw.githubusercontent.com/apple050620312/NCUT-Internet-Auto-Login/refs/heads/main/NCUT_Internet_Auto_Login.py' python NCUT_Internet_Auto_Login.py
-
Win + Rtypeshell:common startuppressEnterWin + R輸入shell:common startup按Enter -
Place
NCUT_Internet_Auto_Login.pyin the opened folder將
NCUT_Internet_Auto_Login.py放到開啟的資料夾內 -
Double-click to ensure the script can run without errors, then reboot to test
點兩下確定腳本可以直接開啟並且沒有報錯,重新開機測試腳本會不會自動執行
-
Open terminal and type
crontab -e打開終端機並輸入
crontab -e -
Add the following line:
@reboot python3 /path/to/NCUT_Internet_Auto_Login.py新增以下行:
@reboot python3 /path/to/NCUT_Internet_Auto_Login.py -
Save and exit
儲存並退出
- Enhanced Compatibility - Now works in all NCUT network environments including labs and WiFi 增強相容性 - 現在可在所有勤益網路環境中使用,包括實驗室和WiFi
- Multi-NAT Support - Functions correctly even behind multiple routers (common in dorm environments) 多層NAT支援 - 即使在多層路由器環境下也能正常運作(常見於宿舍環境)
- Cross-Platform - Tested on Windows 11, Ubuntu, and Termux (Android) 跨平台 - 已在 Windows 11、Ubuntu 和 Termux (Android) 上測試
- No IP Dependency - No longer requires device IP address detection 無IP依賴 - 不再需要檢測裝置IP位址
- Improved Detection - Extracts gateway from redirect URL instead of local IP 改進檢測 - 從重新導向URL提取閘道資訊,而不是本機IP位址
- Security Verification - Added captive portal title verification to ensure connecting to correct network 安全驗證 - 新增認證頁面標題驗證,確保連線到正確的網路
- Discord: @sangege
- Email: apple050620312@gmail.com
Welcome NCUT IT experts to submit PRs to improve this script together 歡迎廣大勤益資訊大佬發 PR 一起改進這個腳本
This script does not record user information 這個腳本不會記錄使用者的資訊
- ✅ Windows 10 (24H2)
- ✅ Ubuntu 20.04 LTS
- ✅ Termux 0.118.0
- ✅ 養浩學舍有線網路
- ✅ 實驗室網路環境
- ✅ 學校WiFi (TANetRoaming)
- ✅ 多層NAT環境 (宿舍路由器後)
MIT License - Feel free to use and modify MIT 授權條款 - 可自由使用和修改

