T03 · Remote Payload Retrieval and Execution
- Location
docx_engine.py:209- Finding
Automatic Retrieval and Execution of an Unpinned Remote .NET Installer
- Content
View full analysis
Optional[Path]: """Download and install .NET SDK automatically. Returns: Path to the installed binary, or None on failure. """ os_type = platform.system() channel = required_dotnet_channel() print(" Acquiring .NET SDK...") try: if os_type == "Windows": installer_url = "https://dot.net/v1/dotnet-install.ps1" target_dir = Path.home() / ".dotnet" powershell_script = f""" $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $installer = Invoke-WebRequest -Uri '{installer_url}' -UseBasicParsing $execution = [scriptblock]::Create($installer.Content) & $execution -Channel {channel} -InstallDir '{target_dir}' """ subprocess.run( ["powershell", "-Command", powershell_script], capture_output=True, text=True, timeout=300 ) binary = target_dir / "dotnet.exe" else: installer_url = "https://dot.net/v1/dotnet-install.sh" target_dir = Path.home() / ".dotnet" installer_path = Path(tempfile.gettempdir()) / "dotnet-bootstrap.sh" subprocess.run( ["curl", "-sSL", installer_url, "-o", str(installer_path)], check=True, timeout=60 ) installer_path.chmod(0o755) subprocess.run( [str(installer_path), "--channel", channel, "--install-dir", str(target_dir)], check=True, timeout=300 ) binary = target_dir / "dotnet" if binary.exists(): verify = subprocess.run([str(binary), "--version"] ...[truncated 3247 chars]- Remediation
View remediation
