This project provides an automated solution for logging into Sangfor aTrust, enabling VPN connectivity without manual intervention. The main features of the project are:
- Automatically opens the aTrust Web login page
- Auto-fills username and password
- Automatically derives and inputs TOTP two-factor authentication codes
- Bypasses CAPTCHA using cookie state
- KeepAlive connection for session persistence and auto-reconnection on logout or disconnection
- Supports Windows, Linux, x86-64, and ARM64
The project provides two methods: Docker and General.
The Docker method is Linux-specific and requires no dependency installation or configuration, making it ideal for headless environments like soft routers or industrial PCs.
The General method works on all platforms but requires manual installation of Python 3.8+ and Selenium. If possible, use the Docker method.
- Windows: Uses the default Microsoft Edge browser for Windows 10 1903+ and Windows 11. No additional browser or driver installation is typically required. For other browsers, refer to the Selenium Documentation for driver installation.
- Linux: Requires Chromium. Install it on Debian/Ubuntu using:
apt-get install -y chromium chromium-driver chromium-l10n
Download the project and install dependencies. Both domestic and international download options are provided. If international downloads are slow, use the domestic option.
International Option:
git clone --depth=1 https://github.com/kenvix/aTrustLogin.git aTrustLogin
cd aTrustLogin/src
pip install -r requirements.txtRun the program with the parameters outlined in the "Program Parameters" section.
The following parameters are supported:
--portal_address: VPN portal address (URL), e.g.,https://atrust.moe.edu.cn/--username: VPN username--password: VPN password--totp_key: TOTP secret for two-factor authentication (optional)--cookie_tid: Cookie ID for session tracking (optional, to bypass CAPTCHA)--cookie_sig: Cookie signature for session tracking (optional, to bypass CAPTCHA)--keepalive: Optional. Session keep-alive interval in seconds.0disables it.--data_dir: Optional. Path to store cookies and session data.--driver_type: Optional. WebDriver type (e.g., "chrome", "edge").--driver_path: Optional. Path to the WebDriver executable.--browser_path: Optional. Path to the browser executable.--interactive: Optional. Enables interactive mode.--wait_atrust: Optional. Waits for aTrust to listen on the specified port.
Example Command:
python main.py --portal_address "https://example.com" --username "your_username" --password "your_password" --totp_key "your_totp_key" --cookie_tid "your_cookie_tid" --cookie_sig "your_cookie_sig" --keepalive 300 --interactive True --wait_atrust TruePull the Docker image using:
docker pull kenvix/atrust-autologin:latestIf downloads are slow, use the domestic address:
wget https://modelscope.cn/models/kenvix/aTrustLoginRepo/resolve/master/docker-atrust-autologin-amd64.tar.xz -O - | xz -dc | docker load
docker tag kenvix/docker-atrust-autologin:amd64 kenvix/docker-atrust-autologin:latestSet program parameters in the ATRUST_OPTS environment variable and run the Docker container:
docker run -it --rm -e ATRUST_OPTS='--portal_address="your_portal" --username="your_username" --password="your_password"' kenvix/atrust-autologin:latestTo avoid CAPTCHA during the first login:
- Log in via the aTrust webpage and input the CAPTCHA manually.
- Save
tidandtid.sigcookies from your browser's developer tools. - Add these values to
--cookie_tidand--cookie_sig.
Note: By default, containers are temporary. For persistent data and auto-start on boot, replace --rm with --restart unless-stopped.
To bypass the CAPTCHA:
- Open the aTrust login webpage, log in, and input the CAPTCHA manually.
- Open browser developer tools (F12) and go to the Application tab.
- Find the
tidandtid.sigcookies, copy their values, and use them in--cookie_tidand--cookie_sig.
FRP (Fast Reverse Proxy) is an intranet penetration tool. You can use FRP to map local aTrust services to a public server.
- Edit the
run.shscript in thefrpcdirectory. - Download the FRP binary and place it in the
frpc/frpdirectory. - Run
run.shto automatically create and start the Docker image with port mapping. - Use
run.shfor future starts, notdocker start.
For further options and environment variables (e.g., PING_ADDR, PING_INTERVAL), refer to the docker-easyconnect documentation.
