Add captiveportal-autologin

This commit is contained in:
Late Night Defender 2024-12-09 12:21:23 +07:00
parent 93df53ab69
commit bafd4d886a
3 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,13 @@
[Unit]
Description=Autologin to captive portal
[Service]
Type=oneshot
# Only run when connected to wifiSSID which "nmcli | grep wifiSSID" will return 0
ExecCondition=sh -c "nmcli | grep wifiSSID"
ExecStart=/var/home/user/.local/bin/login-captive-portal.sh
[Install]
WantedBy=multi-user.target default.target

View file

@ -0,0 +1,15 @@
#!/bin/bash
USERNAME=
PASSWORD=
URL="captive-portal-url"
# Use browser devtools to see what is being sent when the login button is pressed when logging in via web browser
PAYLOAD="Login=${USERNAME}&Passwd=${PASSWORD}&chkRemember=1&btnLogin=Login&reqUrl=http%3A%2F%2Fwww.google.co.th&reqCheck=false"
# Spoof a normal-looking user agent
USER_AGENT="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
curl -X POST "$URL" -d "$PAYLOAD" -H "$USER_AGENT"

View file

@ -0,0 +1,8 @@
[Unit]
Description=Connect to captive portal
[Timer]
OnCalendar=hourly
[Install]
WantedBy=default.target