Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, random
- from colorama import Fore
- os.system('clear')
- print(Fore.RED + '''
- ___ ___ _ _ ___ _
- |_ _| _ \__ _| | | / __|___ _ _ ___ _ _ __ _| |_ ___ _ _
- | || _/\ V /_ _| | (_ / -_) ' \/ -_) '_/ _` | _/ _ \ '_|
- |___|_| \_/ |_| \___\___|_||_\___|_| \__,_|\__\___/_|
- ''')
- try:
- num = int(input(Fore.WHITE + ' Number of IP address/s to generate: '))
- txt = input(' Name of output file (ex hosts.txt): ')
- except KeyboardInterrupt:
- sys.exit(Fore.YELLOW + ' \r\nAborted by user.\r\n')
- except:
- sys.exit(Fore.RED + ' \r\nInput error detected!\r\n')
- print('\r\n')
- try:
- with open(txt, 'w') as file:
- for _ in range(num):
- _ip = ".".join(str(random.randint(0, 255)) for _ in range(4))
- print(Fore.WHITE + ' Writing IP ' + Fore.GREEN + _ip + Fore.WHITE + ' to file.')
- file.write(_ip + '\n')
- except KeyboardInterrupt:
- sys.exit(Fore.YELLOW + ' \r\nAborted by user.\r\n')
- print(Fore.WHITE + '\r\n Done!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement