[Python3] Script to check SOCKS5 proxies for UDP support
[Python3] Script to check SOCKS5 proxies for UDP support
# Target server for testing
TARGET_HOST = "ip"
TARGET_PORT = port
# UDP message
UDP_MESSAGE = 'Hello world!'def test_udp(self) -> bool:
"""Send Source Engine query and wait for response"""
try:
# Build and send UDP packet
udp_packet = self.build_udp_packet(UDP_MESSAGE)
self.udp_sock.sendto(udp_packet, (self.udp_relay_ip, self.udp_relay_port))
# Wait for response
try:
data, addr = self.udp_sock.recvfrom(4096)
return True
except socket.timeout:
return False
except Exception:
return FalseWorking on a project that required to communicate via UDP and have proxied connections (via UDP too) I asked Claude AI to write me a python3 script that would parse a list of SOCKS5 proxies and would check + save into a file all the proxies that support UDP (UDP association for SOCKS5).
The script was made only for SOCKS5 protocol and worked very well in finding proxies that support UDP.
Also, one thing that I came across, UDP proxies are pretty rare and after parsing a list of over 500000 IPs, only a few had UDP support enabled (a list of the proxies found is here: https://github.com/Deiow/SOCKS5-Proxy-Ch...roxies.txt).
The script can be found on Github -> https://github.com/Deiow/SOCKS5-Proxy-Ch...ks5_udp.py
One more thing regarding this script, in order to validate that the UDP support is really working the script also sends a packet via the proxy to a destination address that must communicate via UDP.
# Target server for testing
TARGET_HOST = "ip"
TARGET_PORT = port
# UDP message
UDP_MESSAGE = 'Hello world!'def test_udp(self) -> bool:
"""Send Source Engine query and wait for response"""
try:
# Build and send UDP packet
udp_packet = self.build_udp_packet(UDP_MESSAGE)
self.udp_sock.sendto(udp_packet, (self.udp_relay_ip, self.udp_relay_port))
# Wait for response
try:
data, addr = self.udp_sock.recvfrom(4096)
return True
except socket.timeout:
return False
except Exception:
return False