This commit is contained in:
Mzack9999 2021-05-26 21:18:39 +02:00
parent b6484ca639
commit 13ea138134
2 changed files with 6 additions and 5 deletions

View File

@ -8,11 +8,13 @@ import (
)
// TrimProtocol removes the HTTP scheme from an URI
func TrimProtocol(targetURL string) string {
func TrimProtocol(targetURL string, addDefaultPort bool) string {
URL := strings.TrimSpace(targetURL)
if strings.HasPrefix(strings.ToLower(URL), "http://") || strings.HasPrefix(strings.ToLower(URL), "https://") {
URL = AddURLDefaultPort(URL)
URL = URL[strings.Index(URL, "//")+2:]
if addDefaultPort {
URL = AddURLDefaultPort(URL)
URL = URL[strings.Index(URL, "//")+2:]
}
}
return URL

View File

@ -452,7 +452,7 @@ func (r *Runner) process(t string, wg *sizedwaitgroup.SizedWaitGroup, hp *httpx.
if scanopts.NoFallback {
protocols = []string{httpx.HTTPS, httpx.HTTP}
}
for target := range targets(stringz.TrimProtocol(t)) {
for target := range targets(stringz.TrimProtocol(t, scanopts.NoFallback || scanopts.NoFallbackScheme)) {
// if no custom ports specified then test the default ones
if len(customport.Ports) == 0 {
for _, method := range scanopts.Methods {
@ -554,7 +554,6 @@ retry:
URL, _ := urlutil.Parse(domain)
URL.Scheme = protocol
// if domain doesn't contain port remove it
if !strings.Contains(domain, URL.Port) {
URL.Port = ""
}