mirror of https://github.com/daffainfo/nuclei.git
Added gbk decoder
parent
ec814ca0e2
commit
1976651890
|
@ -61,6 +61,7 @@ require (
|
|||
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
|
||||
golang.org/x/oauth2 v0.0.0-20210817223510-7df4dd6e12ab
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
|
||||
golang.org/x/text v0.3.6
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
@ -116,7 +117,6 @@ require (
|
|||
github.com/ysmood/goob v0.3.0 // indirect
|
||||
github.com/zclconf/go-cty v1.8.4 // indirect
|
||||
go.etcd.io/bbolt v1.3.5 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
gopkg.in/corvus-ch/zbase32.v1 v1.0.0 // indirect
|
||||
|
|
|
@ -433,6 +433,14 @@ func (r *Request) executeRequest(reqURL string, request *generatedRequest, previ
|
|||
}
|
||||
finalEvent := make(output.InternalEvent)
|
||||
|
||||
// Decode gbk response content-types
|
||||
if contentTypes, ok := resp.Header["Content-Type"]; ok && len(contentTypes) > 0 && strings.Contains(contentTypes[0], "gbk") && strings.Contains(contentTypes[0], "gb2312") {
|
||||
dumpedResponse, err = decodegbk(dumpedResponse)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not store in project file")
|
||||
}
|
||||
}
|
||||
|
||||
outputEvent := r.responseToDSLMap(resp, reqURL, matchedURL, tostring.UnsafeToString(dumpedRequest), tostring.UnsafeToString(dumpedResponse), tostring.UnsafeToString(data), headersToString(resp.Header), duration, request.meta)
|
||||
if i := strings.LastIndex(hostname, ":"); i != -1 {
|
||||
hostname = hostname[:i]
|
||||
|
|
|
@ -13,6 +13,8 @@ import (
|
|||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/tostring"
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
|
||||
// dumpResponseWithRedirectChain dumps a http response with the
|
||||
|
@ -122,3 +124,14 @@ func handleDecompression(resp *http.Response, bodyOrig []byte) (bodyDec []byte,
|
|||
}
|
||||
return bodyDec, nil
|
||||
}
|
||||
|
||||
// decodegbk converts GBK to UTF-8
|
||||
func decodegbk(s []byte) ([]byte, error) {
|
||||
I := bytes.NewReader(s)
|
||||
O := transform.NewReader(I, simplifiedchinese.GBK.NewDecoder())
|
||||
d, e := ioutil.ReadAll(O)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue