Created
November 8, 2023 03:19
-
-
Save stcalica/e8fc4584621768e898baa967775007cb to your computer and use it in GitHub Desktop.
DNS Server That Can Do Emoji URLs, Just Need To Change Chromimum -- CHATGPT Generated
This file contains hidden or 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
from dnslib import DNSRecord, DNSHeader, RR | |
from idna import encode, decode | |
# Define the IP address to be returned for a specific domain | |
custom_ip = '192.168.1.100' | |
def punycode_encode(domain): | |
return encode(domain).decode('utf-8') | |
def punycode_decode(punycode_domain): | |
return decode(punycode_domain).encode('utf-8').decode('utf-8') | |
def custom_dns_server(request): | |
# Parse the DNS query | |
dns_request = DNSRecord.parse(request) | |
# Extract the queried domain name | |
queried_domain = punycode_decode(str(dns_request.q.qname)) | |
# Create a response DNS record with the hardcoded IP address | |
response = DNSRecord(DNSHeader(id=dns_request.header.id, qr=1, aa=1, ra=1), q=dns_request.q) | |
response.add_answer(RR(queried_domain, rdata={'ttl': 60, 'type': 1, 'rclass': 1, 'rdata': custom_ip})) | |
# Return the response as bytes | |
return response.pack() | |
# Example usage: | |
if __name__ == '__main__': | |
from socketserver import UDPServer | |
# Define the listening IP and port (0.0.0.0 means listen on all available interfaces) | |
server_address = ('0.0.0.0', 53) | |
# Create the UDP server | |
udp_server = UDPServer(server_address, custom_dns_server) | |
# Start serving | |
print(f'Starting custom DNS server on {server_address[0]}:{server_address[1]}...') | |
udp_server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I take a branch of Chromium and make changes to the Chromium web browser's address resolution to accept emojis and then add a database(maybe all in memory for speed and a cache) to this DNS and point it to a web server. Then I can have an emoji URL Internet!
This was built from a chat I had with chatGPT about DNS, URL shortening, and etc.