A powerful and user-friendly PowerShell script for managing University of Tehran (UT) network authentication. This script simplifies the login process with features like credential management, session control, and traffic monitoring.
- 🔐 Secure Credential Management: Save your credentials securely for future use
- 🔄 Smart Session Detection: Automatically detects if you're already logged in
- 👥 Multi-Account Support: Add and manage multiple UT accounts
- 🚪 Session Management: Log out from active sessions with ease
- 📊 Traffic Monitoring: View your remaining internet traffic quota
- 🔌 Multi-Session Handling: Disconnect other active sessions when needed
- 🤖 Automatic CAPTCHA Solving: Uses Tesseract OCR to automatically solve CAPTCHAs
- 🔔 Automatic Update Check: Notifies you when a new version is available on GitHub
- 🎨 Colorful Interface: Beautiful, color-coded output for better readability
- ⚙️ Flexible Options: Multiple command-line flags for customized behavior
- Requirements
- Installation
- Usage
- Features in Detail
- How It Works
- Troubleshooting
- Security
- Contributing
- License
- Author
- Operating System: Windows
- PowerShell: Version 5.1 or higher
- Network: Connected to the University of Tehran network
- Permissions: Ability to make HTTPS requests
- Tesseract OCR: Optional but recommended - Required for automatic CAPTCHA solving (traffic monitoring and session management)
To check your PowerShell version:
$PSVersionTable.PSVersionTesseract is required for automatic CAPTCHA solving when checking traffic or disconnecting other sessions.
Official Repository: tesseract-ocr/tesseract
Installation Guide: Tesseract Installation Documentation
Quick Install Options:
Option 1: Using Chocolatey (Recommended)
choco install tesseractOption 2: Manual Installation
- Download from UB Mannheim Tesseract (Windows installers)
- Install and add to PATH
- Verify installation:
tesseract --version
For other platforms and detailed instructions, see the official installation guide.
Download the latest version from the Releases page:
- Download
login-to-internet.cmd - Double-click to run
- Perfect for users unfamiliar with PowerShell
# Clone the repository
git clone https://github.com/yourusername/UT-Internet.git
# Navigate to the directory
cd UT-Internet
# Run the script
.\login-to-internet.ps1Simply run the script in PowerShell:
.\login-to-internet.ps1On first run, you'll be prompted to enter your username and password. By default, credentials are saved securely for future use.
| Flag | Description |
|---|---|
-reset |
Reset saved credentials and prompt for new ones |
-noSave |
Don't save credentials (prompt every time) |
-addAccount |
Add a new account to saved credentials |
-chooseDefault |
Set or unset the default account |
-chooseAccount |
Select an account for this session (keeps default unchanged) |
-noRemainingTraffic |
Skip displaying remaining traffic quota |
-noUpdateCheck |
Skip checking for updates on GitHub |
-help |
Display help message with usage information |
-version |
Display script version |
Your credentials are encrypted using PowerShell's built-in ConvertFrom-SecureString
cmdlet and stored in a hidden system file. The credentials are encrypted with your
Windows user account, making them inaccessible to other users.
Security measures:
- Credentials encrypted with user-specific key
- Hidden system file
The script intelligently detects if you're already logged in to the UT network by parsing the portal response. If you're logged in, it offers to:
- Show your current session status
- Display remaining traffic
- Log you out if desired
If login fails due to too many active sessions, the script can:
- Detect the conflict automatically
- Offer to disconnect other sessions
- Retry login after disconnecting
View your remaining internet quota in human-readable format:
- Automatically converts UNITS to MB/GB/TB
- Color-coded output for easy reading
- Automatic CAPTCHA solving using Tesseract OCR
After successful login, the script automatically checks GitHub for new releases:
- Compares your version with the latest release on GitHub
- Displays a notification box if an update is available
- Shows current version, latest version, and download link
- Includes brief release notes preview
- Can be disabled with the
-noUpdateCheckflag
Example output when an update is available:
===========================================================================
| UPDATE AVAILABLE! |
===========================================================================
| Current Version: 1.2.0 |
| Latest Version: 1.2.1 |
============================================================================
| Download: https://github.com/MPCodeWriter21/UT-Internet/releases/latest |
============================================================================
| What's Changed: |
| #### Commits since v1.2.0: |
| - fix: Removed unnecessary empty lines for better readability (3e9cc70) |
===========================================================================
[i] Use '-noUpdateCheck' flag to disable update notifications.
The script uses multiple DNS servers to resolve the login portal:
- Primary DNS:
192.168.20.14 - Secondary DNS:
192.168.20.15 - Fallback: System default DNS
This ensures reliable connection even if one DNS server is down.
graph TD
A[Start Script] --> B{Saved Credentials?}
B -->|Yes| C[Load Credentials]
B -->|No| D[Prompt for Credentials]
C --> E[Resolve DNS]
D --> E
E --> F{DNS Resolved?}
F -->|No| G[Error: Check Connection]
F -->|Yes| H[Get Magic Token]
H --> I{Already Logged In?}
I -->|Yes| J[Offer Logout]
I -->|No| K[Send Login Request]
K --> L{Login Success?}
L -->|Yes| M[Show Traffic]
L -->|No| N{Too Many Sessions?}
M --> R[Check for Update]
N -->|Yes| O[Disconnect Other Sessions]
N -->|No| P[Show Error]
O --> K
R --> Q[End]
J --> Q
P --> Q
G --> Q
Cause: Not connected to UT network or DNS issues
Solutions:
- Verify you're connected to the UT network (WiFi or LAN)
- Disable VPN clients and clear proxies
- Check firewall settings
Cause: Portal connectivity issues
Solutions:
- Verify your internet connection stability
- Try again in a few moments
Cause: Incorrect credentials or issue with UT login system
Solutions:
- Use the
-resetflag to enter credentials again - Verify your username and password are correct
- Check if your account is active
- Try again later
Cause: Tesseract OCR is missing or not accessible
Solutions:
- Install Tesseract OCR (see Requirements section)
- Verify Tesseract is in your system PATH:
tesseract --version - Restart PowerShell after installation
- Note: This only affects traffic monitoring and session disconnection features
Error: cannot be loaded because running scripts is disabled
Solution:
# Run PowerShell as Administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- Credentials are encrypted using Windows Data Protection API (DPAPI)
- Only your Windows user account can decrypt the stored credentials
- Credentials file is hidden and marked as system file
To remove saved credentials:
.\login-to-internet.ps1 -reset- ✅ Use strong, unique passwords
- ✅ Only save credentials on your personal computer
- ✅ Use
-noSaveflag on shared/public computers - ✅ Keep your Windows account password protected
- ❌ Don't run the script on untrusted systems
Contributions are welcome! Here's how you can help:
Open an issue with:
- Script version
- PowerShell version
- Error messages
- Steps to reproduce
Open an issue describing:
- The feature you'd like to see
- Why it would be useful
- How it should work
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Copyright (C) 2024-2025 CodeWriter21 - Mehrad Pooryoussof
This project is licensed under the MIT License - see the LICENSE file for details.
Mehrad Pooryoussof (CodeWriter21)
- GitHub: @MPCodeWriter21
- Email: CodeWriter21@gmail.com
Future enhancements planned:
- Multiple account support (Added in v1.1.0)
- Automatic update notifications (Added in v1.3.0)
- Bypass acct captcha (Added in v1.4.0 - Tesseract OCR integration)
- Automatic login on network connection
- Traffic usage statistics and history
- Scheduled auto-login
- Add additional methods of solving captcha (Use ocr.space API, manual input from the user)
- Cross-platform support (Linux/macOS)
If this script helped you, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting new features
- 📢 Sharing with others
Bug Fixes and Code Improvements
- Enhanced DNS resolution - Added proper error handling for unexpected IP address types
- Improved type checking - Better handling of different DNS response formats (array vs string)
- Better diagnostics - Clear error messages when DNS resolution returns unexpected data types
Technical Details:
- Fixed type checking in
Get-Ipfunction for IPAddress objects - Added exception handling with descriptive messages for unexpected types
- Improved fallback DNS resolution with proper type detection
- Ensures script fails gracefully with informative errors instead of silent failures
Automatic CAPTCHA Solving Release
- Tesseract OCR integration - Automatically solves CAPTCHAs using Tesseract OCR engine
- Traffic monitoring restored - Re-enabled automatic traffic display with CAPTCHA bypass
- Session management restored - Re-enabled automatic session disconnection with CAPTCHA bypass
- Smart username handling - Automatically removes @ut.ac.ir suffix from usernames
- Graceful fallback - Clear error messages if Tesseract is not installed
- Temporary file cleanup - Automatically removes downloaded CAPTCHA images
Technical Details:
- Downloads CAPTCHA image from acct.ut.ac.ir
- Uses Tesseract OCR with optimal settings (--oem 3 --psm 6)
- Stores temporary CAPTCHA in system temp folder
- Cleans up after processing
- Maintains session cookies for authenticated requests
Requirements:
- Tesseract OCR must be installed and in PATH
- See Requirements section for installation instructions
User Experience Improvements
- Clear error messages - Added understandable error messages explaining captcha protection on the account server
- Traffic monitoring - Temporarily disabled automatic traffic display due to captcha protection
- Session disconnection - Temporarily disabled automatic session disconnection due to captcha protection
- User guidance - Directs users to web portal for traffic checking and session management while working on a solution
Note: The account server now has captcha protection. Traffic monitoring and automatic session disconnection features are temporarily unavailable through the script. Users are advised to use the web portal for these functions.
Bug Fixes and Improvements
- Make sure to use -UseBasicParsing flag with Invoke-WebRequest to avoid executing scripts and suppress security warning message.
Automatic Update Check Release
- GitHub update notifications - Automatically checks for new releases after login
- Release notes preview - Shows brief release notes from the latest version
- Configurable - Use
-noUpdateCheckflag to disable update notifications
New Flag:
-noUpdateCheck- Skip checking for updates on GitHub
Behavior:
- After successful login and traffic display, queries GitHub API for latest release
- Compares current version (1.3.0) with latest available version
- Displays formatted notification box if update is available
- Shows download link and first few lines of release notes
- Never interrupts workflow if update check fails
UI/UX Polish Release
- Cleaner interface - Removed unnecessary empty lines for better readability
- GitHub link added - Added repository link to header banner
- Minor spacing improvements - Improved visual flow throughout the script
Changes:
- Added GitHub repository URL to copyright banner
- Removed redundant
Write-Hostcalls that created excessive blank lines - Improved output spacing in
-chooseDefaultand-chooseAccountflags - Cleaner output when displaying remaining traffic
Flexible Default Account Release
- Null default option - Set default to "None" to be prompted on each login
- Auto-select single account - Single account users never prompted
- Smart migration - Automatically migrates v1.1.0 multi-account users to null default
- Improved UX - Helpful tips and prompts for multi-account management
Enhanced Flags:
-chooseDefaultnow supports "None" option (option 0)
Behavior:
- Multi-account users with null default: Prompted to choose account each time
- Single account users: Automatically selected without prompting
- Multi-account users with set default: Use default account automatically
Multi-Account Support Release
- Multi-account management - Add and manage multiple UT accounts
- Default account selection - Set your preferred default account
- Per-session account choice - Use different accounts without changing default
- Automatic migration - Seamlessly updates old credential format
- Account password updates - Update passwords for existing accounts
New Flags:
-addAccount- Add a new account-chooseDefault- Set default account-chooseAccount- Choose account for current session
Initial Public Release
- Basic login functionality
- Credential management
- Session detection and management
- Traffic monitoring
- Multi-session handling
- Colorful user interface
- Command-line options
Made with ❤️ for University of Tehran Students
If you find this useful, don't forget to star the repo! ⭐