mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2026-02-07 11:03:09 +08:00
fix missing port in javascript result (#5023)
* add ip support in js output * js: if dialed ip is missing resolve and get first ip * ssl: fix incorrect port in output
This commit is contained in:
@@ -27,11 +27,13 @@ import (
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/generators"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/helpers/eventcreator"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/interactsh"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/utils/vardump"
|
||||
protocolutils "github.com/projectdiscovery/nuclei/v3/pkg/protocols/utils"
|
||||
templateTypes "github.com/projectdiscovery/nuclei/v3/pkg/templates/types"
|
||||
"github.com/projectdiscovery/nuclei/v3/pkg/types"
|
||||
errorutil "github.com/projectdiscovery/utils/errors"
|
||||
iputil "github.com/projectdiscovery/utils/ip"
|
||||
urlutil "github.com/projectdiscovery/utils/url"
|
||||
"github.com/remeh/sizedwaitgroup"
|
||||
)
|
||||
@@ -520,6 +522,46 @@ func (request *Request) executeRequestWithPayloads(hostPort string, input *conte
|
||||
data["stop-at-first-match"] = true
|
||||
}
|
||||
|
||||
// add ip address to data
|
||||
if input.MetaInput.CustomIP != "" {
|
||||
data["ip"] = input.MetaInput.CustomIP
|
||||
} else {
|
||||
// context: https://github.com/projectdiscovery/nuclei/issues/5021
|
||||
hostname := input.MetaInput.Input
|
||||
if strings.Contains(hostname, ":") {
|
||||
host, _, err := net.SplitHostPort(hostname)
|
||||
if err == nil {
|
||||
hostname = host
|
||||
} else {
|
||||
// naive way
|
||||
if !strings.Contains(hostname, "]") {
|
||||
hostname = hostname[:strings.LastIndex(hostname, ":")]
|
||||
}
|
||||
}
|
||||
}
|
||||
data["ip"] = protocolstate.Dialer.GetDialedIP(hostname)
|
||||
// if input itself was an ip, use it
|
||||
if iputil.IsIP(hostname) {
|
||||
data["ip"] = hostname
|
||||
}
|
||||
|
||||
// if ip is not found,this is because ssh and other protocols do not use fastdialer
|
||||
// although its not perfect due to its use case dial and get ip
|
||||
dnsData, err := protocolstate.Dialer.GetDNSData(hostname)
|
||||
if err == nil {
|
||||
for _, v := range dnsData.A {
|
||||
data["ip"] = v
|
||||
break
|
||||
}
|
||||
if data["ip"] == "" {
|
||||
for _, v := range dnsData.AAAA {
|
||||
data["ip"] = v
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add and get values from templatectx
|
||||
request.options.AddTemplateVars(input.MetaInput, request.Type(), request.GetID(), data)
|
||||
data = generators.MergeMaps(data, request.options.GetTemplateCtx(input.MetaInput).GetAll())
|
||||
|
||||
Reference in New Issue
Block a user