Advanced Solution using python (GL-SFT1200 Opal Firmware 4.x tested)
2. Install python3 opkg update && opkg install python3
3. Modify the python script to match your creds and wifi (at the bottom of this comment)
4. Upload the python script (you can copy and paste it with vim vim ~/scripts/repeater-reconnect.py
). (I uploaded as~/scripts/repeater-reconnect.py
) You might need to create the folder first mkdir -p ~/scripts
5. Assign exec permissions chmod +x ~/scripts/repeater-reconnect.py
6. Configure a cron tab via http://192.168.8.1/cgi-bin/luci/admin/system/crontab (mine runs every 10 mins) */10 * * * * /usr/bin/python3 ~/scripts/repeater-reconnect.py
7. Restart the cron service via http://192.168.8.1/cgi-bin/luci/admin/system/startup
8. Enjoy
import http.client
import hashlib
import json
import subprocess
#CONFIG VARIABLES (CONFIGURE HERE!!!!!)
router_password = 'xxxxxx'
username = 'root'
wifi_password = 'xxxxxxx'
wifi_ssid = 'xxxxxxx'
def generate_hash(password, salt, nonce, username):
# Generate the password hash using openssl
pwd_process = subprocess.run(
["openssl", "passwd", "-1", "-salt", salt, password],
capture_output=True,
text=True
)
pwd = pwd_process.stdout.strip()
# Create the combined string and generate its MD5 hash
combined_string = f"{username}:{pwd}:{nonce}"
hash_object = hashlib.md5(combined_string.encode())
hash_value = hash_object.hexdigest()
return hash_value
conn = http.client.HTTPConnection("192.168.8.1")
payload = "{\"jsonrpc\":\"2.0\",\"id\":63,\"method\":\"challenge\",\"params\":{\"username\":\"root\"}}"
headers = {
'Accept': "application/json, text/plain, */*",
'Accept-Language': "en-US,en;q=0.9,pt-BR;q=0.8,pt;q=0.7,es-US;q=0.6,es;q=0.5",
'Cache-Control': "no-cache",
'Connection': "keep-alive",
'Content-Type': "application/json",
'Origin': "http://192.168.8.1",
'Pragma': "no-cache",
'Referer': "http://192.168.8.1/",
}
conn.request("POST", "/rpc", payload, headers)
res = conn.getresponse()
data = res.read()
# # first request
result_nonce = json.loads(data.decode("utf-8"))
salt = result_nonce['result']['salt']
nonce = result_nonce['result']['nonce']
hash = generate_hash(router_password, salt, nonce, 'root')
# Second query for authentication
conn2 = http.client.HTTPConnection("192.168.8.1")
payload2 = f'{{"jsonrpc":"2.0","id":64,"method":"login","params":{{"username":"{username}","hash":"{hash}"}}}}'
headers2 = {
'Accept': "application/json, text/plain, */*",
'Accept-Language': "en-US,en;q=0.9,pt-BR;q=0.8,pt;q=0.7,es-US;q=0.6,es;q=0.5",
'Cache-Control': "no-cache",
'Connection': "keep-alive",
'Content-Type': "application/json",
'Origin': "http://192.168.8.1",
'Pragma': "no-cache",
'Referer': "http://192.168.8.1/",
}
conn2.request("POST", "/rpc", payload2, headers2)
res2 = conn2.getresponse()
data2 = res2.read()
result_login = json.loads(data2.decode("utf-8"))
sid = result_login['result']['sid']
# Connect Wifi
conn3 = http.client.HTTPConnection("192.168.8.1")
payload3 = f'{{"jsonrpc":"2.0","id":828,"method":"call","params":["{sid}","repeater","connect",{{"protocol":"dhcp", "ssid":"{wifi_ssid}", "key":"{wifi_password}", "remember":true, "manual":false}}]}}'
headers3 = {
'Accept': "application/json, text/plain, */*",
'Accept-Language': "en-US,en;q=0.9,pt-BR;q=0.8,pt;q=0.7,es-US;q=0.6,es;q=0.5",
'Cache-Control': "no-cache",
'Connection': "keep-alive",
'Content-Type': "application/json",
'Origin': "http://192.168.8.1",
'Pragma': "no-cache",
'Referer': "http://192.168.8.1/",
}
conn3.request("POST", "/rpc", payload3, headers)
res3 = conn3.getresponse()
data3 = res3.read()
print(data3.decode("utf-8"))