1 回答
TA贡献1865条经验 获得超7个赞
希望这会对其他人有所帮助。
有效的代码
func ChangePassword(password string) {
hc := http.Client{}
routerURL := "http://192.168.0.1/goform/form2WlanBasicSetup.cgi"
form := url.Values{}
form.Add("domain", "1")
form.Add("hiddenSSID", "0")
form.Add("ssid", "Linux-PC")
form.Add("band", "9")
form.Add("chan", "0")
form.Add("chanwid", "1")
form.Add("txRate", "0")
form.Add("method_cur", "0")
form.Add("method", "6")
form.Add("authType", "2")
form.Add("length", "1")
form.Add("format", "1")
form.Add("defaultTxKeyId", "1")
form.Add("key1", "")
form.Add("pskFormat", "0")
form.Add("pskValue", password)
form.Add("checkWPS2", "1")
form.Add("save", "Apply")
form.Add("basicrates", "496")
form.Add("operrates", "4080")
req, err := http.NewRequest("POST", routerURL, strings.NewReader(form.Encode()))
if err != nil {
panic(err)
}
req.PostForm = form
req.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0")
req.Header.Add("Referer", "http://192.168.0.1/d_wlan_basic.asp")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
fmt.Println(form)
resp, err := hc.Do(req)
if err != nil {
panic(err)
}
fmt.Println(resp.Status)
fmt.Println(password)
}
- 1 回答
- 0 关注
- 133 浏览
添加回答
举报