Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DNS Request over SOCKS5 using Python 3

I have to make a DNS request using python 3 over a SOCKS 5 proxy. (consequently NO DNS requests are made from my ip address, the socks5 proxy does it for me and should respond with the according A/AAA records or nothing/something else if it can not resolve it)

I found the following github projects:

rthalley/dnspython: no proxy/socks support

Anorov/PySocks: no ipv6, no possiblity to receive the remote DNS response

I found the following stackoverflow thread: Python - Using socket.gethostbyname through proxy -> It uses pysocks, which has no ipv6 support -> not useable for me

Do you have any idea how to accomplish my task?

like image 934
tr4shitter Avatar asked Jul 09 '18 15:07

tr4shitter


1 Answers

It's surprisingly easy. It works the same way as in curl:

If you need DNS to be resolved client side, use socks5://host:port syntax

If you need DNS to be resolved on the proxy side, use socks5h://host:port syntax

like image 124
disklosr Avatar answered Nov 15 '22 18:11

disklosr