-
-
Save moloch--/1bf9cb6cd05bb0e705904ea7b965efb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func dnsTCPLookup(resolverIP string, domain string) (string, error) { | |
tcpResolver := net.Resolver{ | |
PreferGo: true, | |
Dial: func(ctx context.Context, network, address string) (net.Conn, error) { | |
dialer := net.Dialer{} | |
return dialer.DialContext(ctx, "tcp", fmt.Sprintf("%s:53", resolverIP)) | |
}, | |
} | |
log.Printf("[dns] lookup -> %s", domain) | |
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | |
defer cancel() | |
txts, err := tcpResolver.LookupTXT(ctx, domain) | |
if err != nil || len(txts) == 0 { | |
log.Printf("[!] failure -> %s", domain) | |
return "", err | |
} | |
return strings.Join(txts, ""), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment