Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function to allow http follow meta redirects, http.GetFollowClientRedirects() #21

Open
brenocss opened this issue Jun 7, 2022 · 0 comments

Comments

@brenocss
Copy link

brenocss commented Jun 7, 2022

Please describe your feature request:

Often, we see responses with status code 200 and with the meta tag defining the redirect, if we implement a follow redirect we would increase the number of vulnerabilities found in nuclei. I think we need to override func (c *Client) do(req *Request) (retres *Response, reterr error) and add getMetaRedirect as a fallback method to determine the redirect,

func getMetaRedirect(body string) (redirect_url string, err error) {
	// <meta http-equiv="refresh" content="4; URL='https://google.com/'" />
	doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
	if err != nil {
		return "", err
	}
	meta := doc.Find("meta[http-equiv='refresh']")
	if meta.Length() == 0 {
		return "", nil
	}
	content := meta.AttrOr("content", "")
	if content == "" {
		return "", nil
	}

	parts := strings.Split(content, ";")
	if len(parts) < 2 {
		return "", nil
	}
	// get url
	for _, part := range parts {
		// use regex case insensitve to search for url part
		if strings.Contains(strings.ToLower(part), "url=") {
			// trim url part with regex
			url := part[6 : len(part)-1]
			return url, nil
		}
	}
	return "", nil
}

Describe the use case of this feature:

Follow meta redirects like burp suite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant