Skip to content

Instantly share code, notes, and snippets.

@GrapeApple0
Last active December 27, 2022 04:09
Show Gist options
  • Select an option

  • Save GrapeApple0/c24f0a00aaaa28584ac6ae4211d47dad to your computer and use it in GitHub Desktop.

Select an option

Save GrapeApple0/c24f0a00aaaa28584ac6ae4211d47dad to your computer and use it in GitHub Desktop.
.ap Whois
.ap Whois example
run: sudo python3 whois.ap.py
command: whois -h $host example.ap
{
"domain":"example.ap",
"status":"Activa",
"register":"ApolenNic",
"registry":"ApolenNic (http://nic.ap/)",
"address":"2-6 MeinStlet Dublik Apolen",
"email":"webmaster@nic.ap"
}
import socket
import json
HOST = "whois.nic.ap"
PORT = 43
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server:
server.bind((HOST, PORT))
server.listen()
print("ApolenNic Whois ver 0.1 beta")
while True:
client, addr = server.accept()
with client:
domain = client.recv(1024).strip().decode()
if domain.endswith(".ap"):
jsonf = open(domain + '.json', 'r')
rec = json.load(jsonf)
statusres = rec["status"]
nameres = rec["register"]
addressres = rec["address"]
registryres = rec["registry"]
emailres = rec["email"]
if (nameres == "Not found."):
res = bytes("ApolenNic Whois ver 0.1 beta\n" + domain + " is not found.","utf-8")
client.sendall(res)
else:
res = bytes(
"ApolenNic Whois ver 0.1\nDomain: " +
domain +
"\nStaus: " +
statusres +
"\nRegistry: " +
registryres +
"\nRegistrant: " +
nameres +
"\nRegistrant Address: " +
addressres +
"\nRegistrant Email: " +
emailres +
"\n\n*STROVECIKA*\nKvejra uza idetjikal canu.\nPestravkani djkar hrevka.","utf-8")
client.sendall(res)
print("Whois request to " + domain)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment