From bafd4d886a01e4ebb5a1a8588c000399316a4cfdcd0b1b5d6cc33fcab4534818 Mon Sep 17 00:00:00 2001 From: Late Night Defender Date: Mon, 9 Dec 2024 12:21:23 +0700 Subject: [PATCH] Add captiveportal-autologin --- .../login-captive-portal.service | 13 +++++++++++++ captiveportal-autologin/login-captive-portal.sh | 15 +++++++++++++++ .../login-captive-portal.timer | 8 ++++++++ 3 files changed, 36 insertions(+) create mode 100644 captiveportal-autologin/login-captive-portal.service create mode 100755 captiveportal-autologin/login-captive-portal.sh create mode 100644 captiveportal-autologin/login-captive-portal.timer diff --git a/captiveportal-autologin/login-captive-portal.service b/captiveportal-autologin/login-captive-portal.service new file mode 100644 index 0000000..99c804d --- /dev/null +++ b/captiveportal-autologin/login-captive-portal.service @@ -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 diff --git a/captiveportal-autologin/login-captive-portal.sh b/captiveportal-autologin/login-captive-portal.sh new file mode 100755 index 0000000..442d317 --- /dev/null +++ b/captiveportal-autologin/login-captive-portal.sh @@ -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" + diff --git a/captiveportal-autologin/login-captive-portal.timer b/captiveportal-autologin/login-captive-portal.timer new file mode 100644 index 0000000..465cb05 --- /dev/null +++ b/captiveportal-autologin/login-captive-portal.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Connect to captive portal + +[Timer] +OnCalendar=hourly + +[Install] +WantedBy=default.target