mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 18:26:57 +00:00
Adding auto-PTR IP to FQDN
This commit is contained in:
parent
7b60b31750
commit
bc84fb1109
@ -1,7 +1,6 @@
|
|||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@ -9,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/weppos/publicsuffix-go/publicsuffix"
|
"github.com/weppos/publicsuffix-go/publicsuffix"
|
||||||
|
|
||||||
|
"github.com/projectdiscovery/iputil"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/expressions"
|
||||||
@ -170,11 +170,21 @@ func (request *Request) Requests() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make returns the request to be sent for the protocol
|
// Make returns the request to be sent for the protocol
|
||||||
func (request *Request) Make(domain string) (*dns.Msg, error) {
|
func (request *Request) Make(host string) (*dns.Msg, error) {
|
||||||
if request.question != dns.TypePTR && net.ParseIP(domain) != nil {
|
isIP := iputil.IsIP(host)
|
||||||
return nil, errors.New("cannot use IP address as DNS input")
|
switch {
|
||||||
|
case request.question == dns.TypePTR && isIP:
|
||||||
|
var err error
|
||||||
|
host, err = dns.ReverseAddr(host)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if isIP {
|
||||||
|
return nil, errors.New("cannot use IP address as DNS input")
|
||||||
|
}
|
||||||
|
host = dns.Fqdn(host)
|
||||||
}
|
}
|
||||||
domain = dns.Fqdn(domain)
|
|
||||||
|
|
||||||
// Build a request on the specified URL
|
// Build a request on the specified URL
|
||||||
req := new(dns.Msg)
|
req := new(dns.Msg)
|
||||||
@ -183,7 +193,7 @@ func (request *Request) Make(domain string) (*dns.Msg, error) {
|
|||||||
|
|
||||||
var q dns.Question
|
var q dns.Question
|
||||||
|
|
||||||
final := replacer.Replace(request.Name, generateDNSVariables(domain))
|
final := replacer.Replace(request.Name, generateDNSVariables(host))
|
||||||
|
|
||||||
q.Name = dns.Fqdn(final)
|
q.Name = dns.Fqdn(final)
|
||||||
q.Qclass = request.class
|
q.Qclass = request.class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user