Files
Li4n0 3559894acc feat: complete basic functions
Support http,dns and mysql connection. Support custom http, dns response. Support dns rebinding.
Support mysql load local files and jdbc deserialize exploit.
2021-04-21 18:55:16 +08:00

49 lines
857 B
Go

package newdns
import (
"time"
"github.com/miekg/dns"
)
// Query can be used to query a DNS server over the provided protocol on its
// address for the specified name and type. The supplied function can be set to
// mutate the sent request.
func Query(proto, addr, name, typ string, fn func(*dns.Msg)) (*dns.Msg, error) {
// prepare request
req := &dns.Msg{
MsgHdr: dns.MsgHdr{
Id: dns.Id(),
},
Question: []dns.Question{
{
Name: name,
Qtype: dns.StringToType[typ],
Qclass: dns.ClassINET,
},
},
}
// call function if available
if fn != nil {
fn(req)
}
// prepare client
client := dns.Client{
Net: proto,
Timeout: time.Second,
}
// send request
res, _, err := client.Exchange(req, addr)
if err != nil {
return nil, err
}
// reset id to allow direct comparison
res.Id = 0
return res, nil
}