adding final url support

This commit is contained in:
Mzack9999 2021-05-08 20:38:06 +02:00
parent dbd75f4daa
commit d18cfcc1ae
4 changed files with 28 additions and 1 deletions

View File

@ -30,6 +30,8 @@ type ChainItem struct {
Request string `json:"request,omitempty"`
Response string `json:"response,omitempty"`
StatusCode int `json:"status_code,omitempty"`
Location string `json:"location,omitempty"`
RequestURL string `json:"request-url,omitempty"`
}
// GetHeader value
@ -79,6 +81,8 @@ func (r *Response) GetChainAsSlice() (chain []ChainItem) {
Request: string(chainItem.Request),
Response: string(chainItem.Response),
StatusCode: chainItem.StatusCode,
Location: chainItem.Location,
RequestURL: chainItem.RequestURL,
})
}
return
@ -88,3 +92,12 @@ func (r *Response) GetChainAsSlice() (chain []ChainItem) {
func (r *Response) HasChain() bool {
return len(r.Chain) > 1
}
// HasChain redirects
func (r *Response) GetChainLastURL() string {
if r.HasChain() {
lastitem := r.Chain[len(r.Chain)-1]
return lastitem.RequestURL
}
return ""
}

2
go.mod
View File

@ -15,7 +15,7 @@ require (
github.com/projectdiscovery/fdmax v0.0.3
github.com/projectdiscovery/gologger v1.1.4
github.com/projectdiscovery/hmap v0.0.1
github.com/projectdiscovery/httputil v0.0.0-20210506091701-9ad2e8818e49
github.com/projectdiscovery/httputil v0.0.0-20210508183653-2e37c34b438d
github.com/projectdiscovery/iputil v0.0.0-20210429152401-c18a5408ca46
github.com/projectdiscovery/mapcidr v0.0.6
github.com/projectdiscovery/rawhttp v0.0.6

2
go.sum
View File

@ -108,6 +108,8 @@ github.com/projectdiscovery/hmap v0.0.1 h1:VAONbJw5jP+syI5smhsfkrq9XPGn4aiYy5pR6
github.com/projectdiscovery/hmap v0.0.1/go.mod h1:VDEfgzkKQdq7iGTKz8Ooul0NuYHQ8qiDs6r8bPD1Sb0=
github.com/projectdiscovery/httputil v0.0.0-20210506091701-9ad2e8818e49 h1:hzMhw71p7+a5oyd3si9D/PMtqomvdsrd782+9Y1tUVo=
github.com/projectdiscovery/httputil v0.0.0-20210506091701-9ad2e8818e49/go.mod h1:Vm2DY4NwUV5yA6TNzJOOjTYGjTcVfuEN8m9Y5dAksLQ=
github.com/projectdiscovery/httputil v0.0.0-20210508183653-2e37c34b438d h1:IdBTOSGaPrZ8+FK0uYMQIva9dYIR5F55PLFWYtBBKc0=
github.com/projectdiscovery/httputil v0.0.0-20210508183653-2e37c34b438d/go.mod h1:Vm2DY4NwUV5yA6TNzJOOjTYGjTcVfuEN8m9Y5dAksLQ=
github.com/projectdiscovery/ipranger v0.0.2/go.mod h1:kcAIk/lo5rW+IzUrFkeYyXnFJ+dKwYooEOHGVPP/RWE=
github.com/projectdiscovery/iputil v0.0.0-20210414194613-4b4d2517acf0/go.mod h1:PQAqn5h5NXsQTF4ZA00ZTYLRzGCjOtcCq8llAqrsd1A=
github.com/projectdiscovery/iputil v0.0.0-20210429152401-c18a5408ca46 h1:veDjJpC3q2PLyuYPS3jNeoYgbHvHPWQhwqRPoCe6YTA=

View File

@ -799,6 +799,16 @@ retry:
}
}
var finalURL string
if resp.HasChain() {
finalURL = resp.GetChainLastURL()
}
if resp.HasChain() {
builder.WriteString(" [" + finalURL + "]")
}
// store responses or chain in directory
if scanopts.StoreResponse || scanopts.StoreChain {
domainFile := fmt.Sprintf("%s%s", domain, scanopts.RequestURI)
@ -902,6 +912,7 @@ retry:
CDN: isCDN,
ResponseTime: resp.Duration.String(),
Technologies: technologies,
FinalURL: finalURL,
}
}
@ -941,6 +952,7 @@ type Result struct {
ResponseTime string `json:"response-time,omitempty"`
Technologies []string `json:"technologies,omitempty"`
Chain []httpx.ChainItem `json:"chain,omitempty"`
FinalURL string `json:"final-url,omitempty"`
}
// JSON the result