Exploit database

GH-f8585cd58dc6419ada5a0bc051d6fbfc

rickgeex/cve-2025-5777-citrixbleed

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-5777

16 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files3
rickgeex/cve-2025-5777-citrixbleedRevision 746d6477921b

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

ns_log_scanner.py

Python · 3,018 bytes
#!/usr/bin/env python3
"""
ns_log_scanner.py — detects non-text (binary) bytes in Citrix NetScaler ns.log files

Author  : Mischa Rick van Geelen (@rickgeex)
Company : Anovum B.V.
Contact : [email protected]

This edition treats **valid UTF-8** (e.g. €, emoji, accented letters) as text
while still flagging
  • invalid UTF-8 byte sequences, and
  • control characters other than TAB (0x09), LF (0x0A) and CR (0x0D).

Exit status
-----------
    0 – no binary found
    1 – at least one offending line printed to stdout
    2 – wrong CLI usage / file not found
"""

from __future__ import annotations

import sys
from pathlib import Path
from typing import Final

# Printable ASCII range 0x20-0x7E
ASCII_PRINTABLE: Final = set(range(0x20, 0x7F))
# Allowed control characters: TAB, LF, CR
CTRL_OK: Final = {0x09, 0x0A, 0x0D}

def is_plain(line: bytes) -> bool:
    """
    A line is 'plain' when:
      • it decodes as UTF-8 without errors, AND
      • every byte < 0x80 is either printable ASCII or an allowed control.
        (Bytes ≥ 0x80 have already been validated as part of UTF-8.)
    """
    try:
        line.decode("utf-8")
    except UnicodeDecodeError:
        return False

    return all(
        (b in ASCII_PRINTABLE or b in CTRL_OK) if b < 0x80 else True
        for b in line
    )

def first_bad_span(line: bytes) -> bytes:
    """
    Return the offending byte span that made the line 'bad':
      • if UTF-8 decode failed → bytes reported by the decoder
      • else                  → all disallowed ASCII control bytes
    """
    try:
        line.decode("utf-8")
    except UnicodeDecodeError as exc:
        return line[exc.start : exc.end]          # invalid UTF-8 segment

    return bytes(
        b for b in line if (b < 0x80 and b not in ASCII_PRINTABLE | CTRL_OK)
    )

def scan(path: str) -> int:
    bad_lines = 0
    with (sys.stdin.buffer if path == "-" else open(path, "rb")) as fh:
        for lineno, raw in enumerate(fh, 1):
            if not is_plain(raw):
                bad_lines += 1
                bad = [f"{b:02x}" for b in first_bad_span(raw)][:10]
                print(
                    f"[binary] line {lineno}: first {len(bad)} bad byte(s) → "
                    f"{' '.join(bad)}"
                )
    return bad_lines

def main() -> None:
    if len(sys.argv) != 2:
        print("Provide one filename (or '-' to read from stdin).", file=sys.stderr)
        sys.exit(2)

    target = sys.argv[1]
    if target != "-" and not Path(target).is_file():
        print(f"No such file: {target}", file=sys.stderr)
        sys.exit(2)

    hits = scan(target)
    if hits:
        print(
            f"\n{hits} line(s) with non-text bytes detected — investigate further "
            "(printable UTF-8 is accepted; stray control bytes may still be benign, "
            "but always verify)"
        )
        sys.exit(1)

    print("✓ ns.log is pure ASCII/UTF-8 text.")
    sys.exit(0)


if __name__ == "__main__":
    main()