mirror of
https://github.com/projectdiscovery/httpx
synced 2026-06-08 16:50:17 +00:00
adding port optimization
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
"github.com/projectdiscovery/httpx/common/httpx"
|
||||
sliceutil "github.com/projectdiscovery/utils/slice"
|
||||
)
|
||||
|
||||
var commonHttpPorts = []string{
|
||||
"80",
|
||||
"8080",
|
||||
}
|
||||
|
||||
// determineMostLikelySchemeOrder for the input
|
||||
func determineMostLikelySchemeOrder(input string) string {
|
||||
if _, port, err := net.SplitHostPort(input); err == nil {
|
||||
// if input has port that is commonly used for HTTP, return http then https
|
||||
if sliceutil.Contains(commonHttpPorts, port) {
|
||||
return httpx.HTTP
|
||||
}
|
||||
|
||||
// As of 10/2025 shodan shows that ports > 1024 are more likely to expose HTTP
|
||||
// hence we test first http then https on higher ports
|
||||
// if input has port > 1024, return http then https
|
||||
if port, err := strconv.Atoi(port); err == nil && port > 1024 {
|
||||
return httpx.HTTP
|
||||
}
|
||||
}
|
||||
|
||||
return httpx.HTTPS
|
||||
}
|
||||
+1
-1
@@ -1579,7 +1579,7 @@ func (r *Runner) targets(hp *httpx.HTTPX, target string) chan httpx.Target {
|
||||
func (r *Runner) analyze(hp *httpx.HTTPX, protocol string, target httpx.Target, method, origInput string, scanopts *ScanOptions) Result {
|
||||
origProtocol := protocol
|
||||
if protocol == httpx.HTTPorHTTPS || protocol == httpx.HTTPandHTTPS {
|
||||
protocol = httpx.HTTPS
|
||||
protocol = determineMostLikelySchemeOrder(target.Host)
|
||||
}
|
||||
retried := false
|
||||
retry:
|
||||
|
||||
Reference in New Issue
Block a user