Python : Please help me about script python auto login

kimmattic
7 years ago

0

Python : Please help me about script python auto login.

#!/usr/bin/python  

import urllib.request  
from urllib.request import urlopen  


users = ("admin","administrator","root")  
passwords =("admin","password","passw0rd","1234","5678")  

for user in users:  
    for password in passwords:  
       url = ('http://localhost/wp-login.php')  

reg = urllib.request.Request(url)  
reg.add_header("Cookie", "PHPSESSID=enter cookied here;security=low")  
response = urlopen(reg)  
html = response.read()  


#How to coding method print show success user and password or fail login.    

    print("administrator's username and password --- %s : %s" %(user,password))  

How to coding method print show success user and password or fail login. So sorry my grammar and Thank you.

2replies
2voices
215views
Smyler [WHGhost]
7 years ago

0

You need to have your request done inside the for loops if you are trying to make a brute-force attack.
You can then, still in the loops, test the response for a specific string that would only be present on a successful login page, and exit the loop with a break or return statement (Or just print the credentials if you don’t only want to gain access to a single account).

This thread may help you:
https://www.hackthis.co.uk/forum/programming-technology/programming-discussion/23446-need-some-help-on-my-project

It uses the requests module instead of urllib, but the idea is the same. It’s about WordPress brute-force.

kimmattic
7 years ago

0

Thank you very much WHGhost.

You must be logged in to reply to this discussion. Login
1 of 3

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss