nuclei/v2/pkg/protocols/http/request_annotations.go

20 lines
540 B
Go
Raw Normal View History

2022-04-04 09:32:41 +02:00
package http
import (
"net/http"
"regexp"
"strings"
)
// @Host:target overrides the input target with the annotated one (similar to self-contained requests)
var reHostAnnotation = regexp.MustCompile(`(?m)^@Host:(.+)$`)
// parseAnnotations and override requests settings
func parseAnnotations(rawRequest string, request *http.Request) {
// parse request for known ovverride annotations
if hosts := reHostAnnotation.FindStringSubmatch(rawRequest); len(hosts) > 0 {
host := strings.TrimSpace(hosts[1])
request.URL.Host = host
}
}