Files
42_1/QUICKSTART.md
Timmy cc14122190 Add RTF8207W router (192.168.42.1) exploration and API docs
Probe and document the CHT/ASKEY RTF8207W GPON router including
system info, GPON optical status, WAN/LAN config, WiFi settings,
and full API endpoint reference for CLI management.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 15:08:03 +08:00

128 lines
3.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 快速上手
## 前置條件
- 需在 Tailscale 網路中192.168.42.x subnet route 可達)
- 帳號 `cht`,密碼請參考機器底部貼紙
## 透過瀏覽器登入
1. 開啟 https://192.168.42.1/(需接受自簽憑證)
2. 輸入帳號、密碼、圖形驗證碼
3. 登入後進入 `/avanzada.asp` 管理頁面
## 透過 curl API 登入
### 1. 建立 Session
```bash
COOKIEJAR=/tmp/router_cookies.txt
curl -sk -c "$COOKIEJAR" https://192.168.42.1/ -o /dev/null
```
### 2. 取得驗證碼值
```bash
CAPTCHA_VAL=$(curl -sk -b "$COOKIEJAR" -c "$COOKIEJAR" \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Referer: https://192.168.42.1/" \
-d '' \
'https://192.168.42.1/cgi-bin/cbGetSummary.xml?Captcha=1')
```
### 3. 下載驗證碼圖片4 張,各一個字元)
```bash
for i in 1 2 3 4; do
curl -sk -b "$COOKIEJAR" \
"https://192.168.42.1/img/captcha${i}.png?m=0.$(date +%s)" \
-o "/tmp/captcha${i}.png"
done
```
### 4. 編碼帳密XOR 0x1f
```bash
encode_userpass() {
local input="$1" output=""
for (( i=0; i<${#input}; i++ )); do
local c="${input:$i:1}"
local ord=$(printf '%d' "'$c")
local xored=$((ord ^ 0x1f))
output+=$(printf "\\$(printf '%03o' $xored)")
done
echo -n "$output"
}
USERNAME_ENC=$(encode_userpass "cht")
PASSWORD_ENC=$(encode_userpass "你的密碼")
```
### 5. 送出登入
```bash
RESULT=$(curl -sk -b "$COOKIEJAR" -c "$COOKIEJAR" \
-X POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Referer: https://192.168.42.1/" \
--data-urlencode "rqcaptchaValue=${CAPTCHA_VAL}" \
--data-urlencode "rqCaptchaText=看到的驗證碼" \
--data-urlencode "rqUsername=${USERNAME_ENC}" \
--data-urlencode "rqPasswd=${PASSWORD_ENC}" \
-d "rqTimeout=1198&rqLanguage=TW" \
'https://192.168.42.1/cgi-bin/cbCheckLogin.xml')
```
Result=0 表示登入成功。
### 6. 查詢 API
登入後即可存取各 API endpoint
```bash
# 系統摘要
curl -sk -b "$COOKIEJAR" -X POST -d '' \
'https://192.168.42.1/cgi-bin/cbGetSummary.xml'
# GPON 資訊
curl -sk -b "$COOKIEJAR" -X POST -d '' \
'https://192.168.42.1/cgi-bin/cbGetGPONInfo.xml'
# WAN 連線
curl -sk -b "$COOKIEJAR" -X POST -d '' \
'https://192.168.42.1/cgi-bin/cbGetWanIPIntf.xml'
# WiFi 2.4G
curl -sk -b "$COOKIEJAR" -X POST -d '' \
'https://192.168.42.1/cgi-bin/cbGetWifiAccPt.xml'
# WiFi 5G指定 radio index 1
curl -sk -b "$COOKIEJAR" -X POST -d 'dpm_cfg_wifi_0i=1' \
'https://192.168.42.1/cgi-bin/cbGetWifi.xml'
# LAN IPv4
curl -sk -b "$COOKIEJAR" -X POST -d '' \
'https://192.168.42.1/cgi-bin/cbGetLanIPv4Addr.xml'
```
## 已知 API Endpoint 列表
| Endpoint | 說明 |
|----------|------|
| cbGetSummary | 系統摘要CPU、RAM、韌體版本、開機時間 |
| cbGetGPONInfo | GPON 光纖狀態(序號、光功率、溫度) |
| cbGetCustomConfig | WAN 模式設定 |
| cbGetWanIPIntf | WAN 介面詳細資訊IP、DNS、PPPoE |
| cbGetLanIPv4Addr | LAN IPv4 位址 |
| cbGetLanIPv4Intf | LAN 介面設定 |
| cbGetIPv6Info | IPv6 狀態 |
| cbGetDhcpv4ServerPool | DHCP Server Pool |
| cbDhcpV4SvrPoolGetClt | DHCP 租借客戶端 |
| cbGetWifi | WiFi Radio 設定0=2.4G, 1=5G |
| cbGetWifiAccPt | WiFi AP 設定0=2.4G, 1=5G |
| cbGetWifiSsid | WiFi SSID 設定 |
| cbListWifiAccPtAssociation | WiFi 已連線客戶端 |
| cbGetStatistic | 封包統計 |
| cbCheckLogin | 登入 |