import socket, os
os.system('cls')
print("#" * 79)
print("Custom Domain to IP Script v: 0.1")
print("#" * 79)
print('\n\n')
file = open('bulk-domains.txt', 'r')
domain_list = []
for x in file.readlines():
domain_list.append(x.rstrip())
for y in domain_list:
print("-" * 79)
print(y + '\t->\t' + socket.gethostbyname(y))
Here is a line-by-line explanation of the Python script:
import socket, os
This line imports the socket
and os
modules, which will be used to perform DNS resolution and clear the console screen.
os.system('cls')
This line uses the os.system()
function to run the "cls" command, which clears the console screen. This ensures that the output of the script is displayed cleanly.
print("#" * 79)
print("Custom Domain to IP Script v: 0.1")
print("#" * 79)
These lines print a banner at the top of the console window. The banner is made up of a row of "#" characters and the name and version number of the script.
file = open('bulk-domains.txt', 'r')
domain_list = []
for x in file.readlines():
domain_list.append(x.rstrip())
These lines open a file called "bulk-domains.txt" in read mode and read its contents line by line. Each line is added to a list called domain_list
, with any trailing newline characters removed using the rstrip()
method.
for y in domain_list:
print("-" * 79)
print(y + '\t->\t' + socket.gethostbyname(y))
These lines loop through each domain in domain_list
and use the socket.gethostbyname()
function to perform a DNS lookup and resolve the domain to an IP address. The domain name and its corresponding IP address are printed to the console, separated by a tab character and an arrow symbol. A row of "-" characters is printed before each domain name to visually separate them.
That's it! This script reads a list of domain names from a file, performs a DNS lookup for each domain, and prints the results to the console. It's a simple but useful tool for anyone who needs to perform bulk DNS lookups.
No comments:
Post a Comment