request refusal checking, usage changes, cleanup
This commit is contained in:
parent
82f49eb78e
commit
aea4670c9c
@ -27,9 +27,9 @@ func (m *multiflag) Set(value string) error {
|
||||
}
|
||||
|
||||
var (
|
||||
domain = flag.String("t", "", "domain to query")
|
||||
workers = flag.Int("c", 100, "number of workers")
|
||||
delay = flag.Int("s", 100, "delay (sleep) between queries in milliseconds")
|
||||
domain = flag.String("t", "", "")
|
||||
workers = flag.Int("c", 100, "")
|
||||
delay = flag.Int("s", 100, "")
|
||||
nameserver multiflag
|
||||
)
|
||||
|
||||
@ -45,7 +45,6 @@ func message(domain string, reqtype uint16, ra bool) *dns.Msg {
|
||||
func query(q <-chan Pair, tracker chan<- interface{}) {
|
||||
for pair := range q {
|
||||
msg := message(pair.Domain, dns.TypeA, false)
|
||||
// fmt.Println("Querying ", pair.Domain, " on ", pair.Nameserver)
|
||||
in, err := dns.Exchange(msg, pair.Nameserver+":53")
|
||||
if err != nil {
|
||||
common.Error(err.Error())
|
||||
@ -69,6 +68,18 @@ func testns(ns string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func testreq() bool {
|
||||
msg := message("cloudflare.com", dns.TypeA, false)
|
||||
in, err := dns.Exchange(msg, "1.1.1.1:53")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if len(in.Answer) > 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Var(&nameserver, "n", "nameserver to query")
|
||||
flag.Usage = common.Usage
|
||||
@ -95,13 +106,18 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(nameservers)
|
||||
} else if len(nameserver) > 0 {
|
||||
for _, ns := range nameserver {
|
||||
nameservers = append(nameservers, ns)
|
||||
}
|
||||
} else {
|
||||
// print usage
|
||||
common.Usage()
|
||||
return
|
||||
}
|
||||
|
||||
if !testreq() {
|
||||
common.Fatal("non-recursive queries are being refused, are you on a very dirty box or VPN?")
|
||||
}
|
||||
|
||||
common.Info("aggregating nameservers...")
|
||||
@ -113,7 +129,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
common.Info(fmt.Sprintf("snooping EDR domains from %d resolvers...", len(nameservers)))
|
||||
common.Info(fmt.Sprintf("snooping caches on %d resolvers...", len(nameservers)))
|
||||
|
||||
go func() {
|
||||
for i := 0; i < *workers; i++ {
|
||||
|
@ -19,17 +19,35 @@ var (
|
||||
|
||||
func Banner() {
|
||||
fmt.Printf(`%s
|
||||
_ __________=__
|
||||
\\@([____]_____()
|
||||
_/\|-[____]
|
||||
/ /(( ) ___ __ _____ ___ ___ _ _ _ _
|
||||
/____|'----' | |_) / /\ | | | | \ / / \ \ \ / | |\ |
|
||||
\____/ |_| /_/--\ |_| |_|_/ \_\_/ \_\/\/ |_| \|
|
||||
%s%s
|
||||
sincerely,
|
||||
.------..------..------..------..------..------..------.
|
||||
|%s%sP%s%s.--. ||%s%sA%s%s.--. ||%s%sT%s%s.--. ||%s%sD%s%s.--. ||%s%sO%s%s.--. ||%s%sW%s%s.--. ||%s%sN%s%s.--. |
|
||||
| :/\: || (\/) || :/\: || :/\: || :/\: || :/\: || :(): |
|
||||
| (__) || :\/: || (__) || (__) || :\/: || :\/: || ()() |
|
||||
| '--'P|| '--'A|| '--'T|| '--'D|| '--'O|| '--'W|| '--'N|
|
||||
'------''------''------''------''------''------''------'
|
||||
|
||||
%s%s sincerely,
|
||||
~ delorean%s
|
||||
|
||||
`, ColorRed, ColorReset, ColorGray, ColorReset)
|
||||
`, ColorRed, ColorReset, ColorGray, ColorReset, ColorRed, ColorReset, ColorGray, ColorReset,
|
||||
ColorRed, ColorReset, ColorGray, ColorReset, ColorRed, ColorReset, ColorGray, ColorReset,
|
||||
ColorRed, ColorReset, ColorGray, ColorReset, ColorRed, ColorReset, ColorGray, ColorReset,
|
||||
ColorRed, ColorReset, ColorGray, ColorReset, ColorRed, ColorReset, ColorGray, ColorReset)
|
||||
}
|
||||
|
||||
func Usage() {
|
||||
fmt.Fprintf(os.Stderr, `patdown usage:
|
||||
(%s-t%s) - target domain
|
||||
(%s-n%s) - specific nameserver to snoop, can be multiple
|
||||
(%s-c%s) - concurrent threads [%s100%s]
|
||||
(%s-s%s) - delay between queries, per thread, in milliseconds [%s100%s]
|
||||
|
||||
%se.g.%s
|
||||
patdown -t supernets.org
|
||||
patdown -n ns1.supernets.org -n ns2.supernets.org
|
||||
patdown -t supernets.org -c 50 -s 500
|
||||
|
||||
`, ColorCyan, ColorReset, ColorCyan, ColorReset, ColorCyan, ColorReset, ColorGray, ColorReset, ColorCyan, ColorReset, ColorGray, ColorReset, ColorCyan, ColorReset)
|
||||
}
|
||||
|
||||
var Vendors = map[string]string{
|
||||
@ -67,7 +85,3 @@ func Fatal(msg string) {
|
||||
fmt.Printf(" %s~f~%s %s\n", ColorRed, ColorReset, msg)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
func Usage() {
|
||||
fmt.Printf(" %s~u~%s usage:\npatdown -t <domain>\npatdown -n ns1.target.com -n ns2.target.com", ColorOrange, ColorReset)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user