Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import concurrent.futures
- import socket
- import os
- import shutil
- import threading
- from tqdm import tqdm
- # Clear console based on OS
- if os.name == "nt":
- os.system("cls")
- else:
- os.system("clear")
- class bcolors:
- OKCYAN = '\033[96m'
- OKGREEN = '\033[92m'
- FAIL = '\033[91m'
- ENDC = '\033[0m'
- BOLD = '\033[1m'
- print(bcolors.OKCYAN + """
- [#] Domain to IP
- [#] Coded by @willygoid
- [#] www.haxor.id
- """ + bcolors.ENDC)
- sitelist = input("Sitelist : ")
- threadp = input("Thread (default: 100): ")
- if not threadp.isdigit():
- threadp = 100
- else:
- threadp = int(threadp)
- # Ensure the output file is empty before starting and create a set to track unique IPs
- with open("ips.txt", "w") as f:
- pass
- unique_ips = set()
- lock = threading.Lock()
- def save_to_txt(ip):
- with open("ips.txt", "a") as f:
- f.write(f"{ip}\n")
- def resolveDns(host, pbar, width):
- try:
- checkHost = host.replace("https://", "").replace("http://", "").replace("www.", "")
- ip = socket.gethostbyname(checkHost)
- with lock:
- if ip and ip not in unique_ips:
- unique_ips.add(ip)
- output = f"{bcolors.OKGREEN}{checkHost}{bcolors.ENDC} --> {ip}"
- print_wrapped(output, width)
- save_to_txt(ip)
- except Exception as e:
- output = f"{bcolors.FAIL}{checkHost}{bcolors.ENDC}: Failed, domain inactive!"
- print_wrapped(output, width)
- finally:
- pbar.update(1)
- def print_wrapped(text, width):
- if len(text) > width:
- for i in range(0, len(text), width):
- print(text[i:i+width])
- else:
- print(text)
- def main():
- with open(sitelist) as file:
- hostnames = [line.strip() for line in file if line.strip()]
- total_hostnames = len(hostnames)
- print(bcolors.BOLD + "===[ Start Work ]===" + bcolors.ENDC)
- # Get terminal size
- terminal_size = shutil.get_terminal_size((80, 20))
- width = terminal_size.columns
- # Create the progress bar
- pbar = tqdm(total=total_hostnames, desc="Processing", position=1, leave=True, bar_format="{l_bar}{bar} | {n_fmt}/{total_fmt} [{elapsed}<{remaining}]", colour='cyan')
- with concurrent.futures.ThreadPoolExecutor(max_workers=threadp) as executor:
- futures = [executor.submit(resolveDns, host, pbar, width) for host in hostnames]
- for future in concurrent.futures.as_completed(futures):
- future.result()
- pbar.close()
- print(f'{bcolors.OKCYAN}Finished processing {total_hostnames} links{bcolors.ENDC}')
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement