From f2902703bec77ffa8a18c5a945ffa19f58761d7b Mon Sep 17 00:00:00 2001 From: skarz <40373461+sinkingfeeling@users.noreply.github.com> Date: Wed, 5 Apr 2023 15:04:00 -0700 Subject: [PATCH] Create validator.py --- validator.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 validator.py diff --git a/validator.py b/validator.py new file mode 100644 index 0000000..7f3e628 --- /dev/null +++ b/validator.py @@ -0,0 +1,24 @@ +import os +import socket + +# specify the domain +domain = "domain.com" + +# specify the output file path +output_file = "output.txt" + +# loop through 100 numbers and generate the output +with open(output_file, "w") as f: + for i in range(1, 101): + # format the number with leading zeros + num = "{:03d}".format(i) + # generate the subdomain + subdomain = f"us-{num}.{domain}" + # run nslookup on the subdomain + try: + socket.gethostbyname(subdomain) + # write the subdomain to the output file if it resolves to an IP address + f.write(subdomain + os.linesep) + except socket.error: + # do nothing if the subdomain does not resolve to an IP address + pass