#!/bin/sh

# 提示用户输入 WiFi SSID 和密码
echo "请输入 WiFi SSID 名称:"
read ssid
echo "请输入 WiFi 密码:"
read passphrase

# 将密码转换为 Base64 编码
encoded_passphrase=$(echo -n "$passphrase" | base64)

# 发送请求配置 WiFi
curl -X POST 'http://m.home/reqproc/proc_post' \
  -H 'User-Agent: Mozilla/5.0 (Linux; Android 14; MEIZU 20 Pro Build/UKQ1.230917.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/129.0.6668.102 Mobile Safari/537.36 Html5Plus/1.0' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
  -H 'X-Requested-With: plus.fuckzxw' \
  -H 'Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7' \
  --data-urlencode 'goformId=SET_WIFI_SSID1_SETTINGS' \
  --data-urlencode 'MAX_Access_num=10' \
  --data-urlencode 'security_mode=WPA2PSK' \
  --data-urlencode 'cipher=1' \
  --data-urlencode 'NoForwarding=0' \
  --data-urlencode 'security_shared_mode=0' \
  --data-urlencode "ssid=$ssid" \
  --data-urlencode "passphrase=$encoded_passphrase"

echo "WiFi 已配置完成。"
