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
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@ -9,6 +8,7 @@ import (
|
||||
|
||||
"github.com/weppos/publicsuffix-go/publicsuffix"
|
||||
|
||||
"github.com/projectdiscovery/iputil"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||
"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
|
||||
func (request *Request) Make(domain string) (*dns.Msg, error) {
|
||||
if request.question != dns.TypePTR && net.ParseIP(domain) != nil {
|
||||
func (request *Request) Make(host string) (*dns.Msg, error) {
|
||||
isIP := iputil.IsIP(host)
|
||||
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")
|
||||
}
|
||||
domain = dns.Fqdn(domain)
|
||||
host = dns.Fqdn(host)
|
||||
}
|
||||
|
||||
// Build a request on the specified URL
|
||||
req := new(dns.Msg)
|
||||
@ -183,7 +193,7 @@ func (request *Request) Make(domain string) (*dns.Msg, error) {
|
||||
|
||||
var q dns.Question
|
||||
|
||||
final := replacer.Replace(request.Name, generateDNSVariables(domain))
|
||||
final := replacer.Replace(request.Name, generateDNSVariables(host))
|
||||
|
||||
q.Name = dns.Fqdn(final)
|
||||
q.Qclass = request.class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user