"""
CVE-2022-1234: Windows 本地提权
"""
import subprocess
from .._api import regist
from ..localization import fcall

CVE_ID = "CVE-2022-1234"
TAGS = ["privilege_escalation"]
VERSIONS = ["10", "11"]
OS = "windows"


def exploit(cmd="whoami"):
    print(fcall("exploit_start").format(CVE_ID))
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    print(fcall("command_output").format(result.stdout or result.stderr))
    print(fcall("exploit_success"))


regist(CVE_ID, TAGS, VERSIONS, exploit, OS)