Skip to content

Instantly share code, notes, and snippets.

@vicwomg
Last active September 6, 2024 11:25
Show Gist options
  • Save vicwomg/9b0bc6f1ea22e08379651a36877e0420 to your computer and use it in GitHub Desktop.
Save vicwomg/9b0bc6f1ea22e08379651a36877e0420 to your computer and use it in GitHub Desktop.
@Gerrelt
Copy link

Gerrelt commented Dec 23, 2021

Thanks jrwren, that bash script works like a charm on my TP link Archer C7 v2!

One thing to note: you cannot be logged into the web-interface while running this script.
Apparently only one admin can be logged in at a time.
I thought the script wasn't working, but it was because I was logged in via the browser. After logging out, it worked.

@Gerrelt
Copy link

Gerrelt commented Dec 26, 2021

During testing, sometimes the reboot wasn't working, which meant admin stayed logged in.
I've added this to the end of the script, to logout admin if the reboot didn't work:

# if the reboot didn't work:
LOGOUT_URL="$(dirname $(dirname $SESSION))/userRpm/LogoutRpm.htm"
curl -sif -o /dev/null -b "$COOKIE" -e "$LOGOUT_URL" "$LOGOUT_URL"

@knorr-goose
Copy link

Hi !!! Wonderful info... Does anybody know where is the doc to navigate menus, or get a list of connected MACs... I want to discover unauthorized MACs and log them out? Maybe it is not possible... Thanks in advance for your help !!!

@bit7777
Copy link

bit7777 commented Sep 25, 2022

Here comes a modified version of the script from @jrwren for use on a TP-Link Archer C7 V1 with the latest Firmware 3.15.3 Build 150511 Rel.5581:

#!/bin/bash
IP=192.168.0.1
USER=admin
PASSWD=YOURPASSWORDHERE

LOGIN_URL=http://$IP/userRpm/LoginRpm.htm?Save=Save
REBOOT_PATH=/userRpm/SysRebootRpm.htm

#PASSMD5=$(echo -n $PASSWD | md5sum | cut -f 1 -d ' ')
#COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSMD5" | base64|sed s/=/%3D/)"

COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSWD" | base64|sed s/=/%3D/g)"

SESSION=$(curl -s -b "$COOKIE" "$LOGIN_URL" | grep -o 'http://[^"]*')
REBOOT_URL="$(dirname $(dirname $SESSION))$REBOOT_PATH"
curl -sif -o /dev/null -b "$COOKIE" -e "$REBOOT_URL" "$REBOOT_URL?Reboot=Reboot"

I was also able to write this script in a version running with cmd.exe on Windows XP SP3 (no cygwin etc. required). If someone is interested I can post it here.

@ausfas
Copy link

ausfas commented Sep 6, 2024

Here comes a modified version of the script from @jrwren for use on a TP-Link Archer C7 V1 with the latest Firmware 3.15.3 Build 150511 Rel.5581:

#!/bin/bash
IP=192.168.0.1
USER=admin
PASSWD=YOURPASSWORDHERE

LOGIN_URL=http://$IP/userRpm/LoginRpm.htm?Save=Save
REBOOT_PATH=/userRpm/SysRebootRpm.htm

#PASSMD5=$(echo -n $PASSWD | md5sum | cut -f 1 -d ' ')
#COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSMD5" | base64|sed s/=/%3D/)"

COOKIE="Authorization=Basic%20$(echo -n "$USER:$PASSWD" | base64|sed s/=/%3D/g)"

SESSION=$(curl -s -b "$COOKIE" "$LOGIN_URL" | grep -o 'http://[^"]*')
REBOOT_URL="$(dirname $(dirname $SESSION))$REBOOT_PATH"
curl -sif -o /dev/null -b "$COOKIE" -e "$REBOOT_URL" "$REBOOT_URL?Reboot=Reboot"

I was also able to write this script in a version running with cmd.exe on Windows XP SP3 (no cygwin etc. required). If someone is interested I can post it here.

I'm not an expert in Linux, can you please post the script that I run and test in Windows before testing if it can work in Homeassistant ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment