Skip to content

Instantly share code, notes, and snippets.

@Troll338cz
Last active June 1, 2026 19:36
Show Gist options
  • Select an option

  • Save Troll338cz/07f055da4c0d378640d9454b2c21fec0 to your computer and use it in GitHub Desktop.

Select an option

Save Troll338cz/07f055da4c0d378640d9454b2c21fec0 to your computer and use it in GitHub Desktop.
"""UDP proxy server."""
import asyncio, sys, hashlib, random, os
#
# Run in termux or PC with python3 XashID_randomiser.py 41.216.189.173 27015
# Arguments is server ip and port
# from console run connect 127.0.0.1:27015
# Minimal skill to edit values in here is required
#
class ProxyDatagramProtocol(asyncio.DatagramProtocol):
def __init__(self, remote_address):
self.remote_address = remote_address
self.remotes = {}
super().__init__()
def connection_made(self, transport):
self.transport = transport
def datagram_received(self, data, addr):
if addr in self.remotes:
self.remotes[addr].transport.sendto(data)
return
if data.startswith(b"\xFF\xFF\xFF\xFFconnect"):
##
# Find the values you want it to be changed to yourself
##
# ID Spoof
id_off = data.find(b"\\uuid\\")
data = data.replace(data[id_off+6:id_off+6+32], bytes(hashlib.md5(os.urandom(16)).hexdigest(), "utf8") )
# Build spoof
b_off = data.find(b"\\b\\")
data = data.replace(data[b_off:b_off+3+5] ,b"\\b\\3613")
# Device spoof
d_off = data.find(b"\\d\\")
data = data.replace(data[d_off:d_off+5] ,b"\\d\\7")
# OS spoof
o_off = data.find(b"\\o\\")
o_tmp = data[o_off+3:o_off+31]
o_off_end = o_tmp.find(b"\\")+3
data = data.replace(data[o_off:o_off+o_off_end], b"\\o\\android")
# Arch spoof
a_off = data.find(b"\\a\\")
a_tmp = data[a_off+3:a_off+31]
a_off_end = a_tmp.find(b"\\")+3
data = data.replace(data[a_off:a_off+a_off_end], b"\\a\\arm64")
loop = asyncio.get_event_loop()
self.remotes[addr] = RemoteDatagramProtocol(self, addr, data)
coro = loop.create_datagram_endpoint(
lambda: self.remotes[addr], remote_addr=self.remote_address)
asyncio.ensure_future(coro)
class RemoteDatagramProtocol(asyncio.DatagramProtocol):
def __init__(self, proxy, addr, data):
self.proxy = proxy
self.addr = addr
self.data = data
super().__init__()
def connection_made(self, transport):
self.transport = transport
self.transport.sendto(self.data)
def datagram_received(self, data, _):
self.proxy.transport.sendto(data, self.addr)
def connection_lost(self, exc):
self.proxy.remotes.pop(self.attr)
async def start_datagram_proxy(bind, port, remote_host, remote_port):
loop = asyncio.get_event_loop()
protocol = ProxyDatagramProtocol((remote_host, remote_port))
return await loop.create_datagram_endpoint(
lambda: protocol, local_addr=(bind, port))
def main(bind='0.0.0.0', port=27015, remote_host='127.0.0.1', remote_port=9999):
if( len(sys.argv) != 3 ):
print("python3 proxy.py IP Port")
sys.exit(0)
remote_host = sys.argv[1]
remote_port = int(sys.argv[2])
loop = asyncio.get_event_loop()
print("Starting datagram proxy...")
coro = start_datagram_proxy(bind, port, remote_host, remote_port)
transport, _ = loop.run_until_complete(coro)
print("Datagram proxy is running...")
try:
loop.run_forever()
except KeyboardInterrupt:
pass
print("Closing transport...")
transport.close()
loop.close()
if __name__ == '__main__':
main()
@yalnie

yalnie commented May 24, 2026

Copy link
Copy Markdown

wOW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment