From d5e4f29963f83091d087fa6eae26a1fa04118d48 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Tue, 6 Aug 2024 18:26:08 +0100 Subject: [PATCH] Download file remotely and then download requirements remotely --- OS/init.cmd | 12 ++++++++---- payload/{setuppe.ps1 => run.ps1} | 17 ++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) rename payload/{setuppe.ps1 => run.ps1} (89%) diff --git a/OS/init.cmd b/OS/init.cmd index 212b990..c1705d1 100644 --- a/OS/init.cmd +++ b/OS/init.cmd @@ -1,5 +1,9 @@ @echo off -xcopy "%~dp0\Boot" "C:\boot\" /s /e /h /q /y -xcopy "%~dp0\boot.wim" "C:\sources\" /h /q /y -cd "%~dp0" -powershell -executionpolicy bypass -file "setuppe.ps1" \ No newline at end of file +set StagingDir=%TEMP%\SRBW +set RemoteURL="https://git.mrmeeb.stream/MrMeeb/sure-recover-boot-wiper/raw/branch/main/payload" + +mkdir %StagingDir% + +powershell -Command Invoke-WebRequest %RemoteURL%/run.ps1 -OutFile %StagingDir%\run.ps1 + +powershell -ExecutionPolicy bypass -File %StagingDir%\run.ps1 %RemoteURL% \ No newline at end of file diff --git a/payload/setuppe.ps1 b/payload/run.ps1 similarity index 89% rename from payload/setuppe.ps1 rename to payload/run.ps1 index a5687da..c28937a 100644 --- a/payload/setuppe.ps1 +++ b/payload/run.ps1 @@ -1,18 +1,19 @@ -$RemoteURL = "https://git.mrmeeb.stream/MrMeeb/sure-recover-boot-wiper/raw/branch/main/payload" -$StagingDir = "$TEMP\SRBW" +$RemoteURL = $args[0] +$StagingDir = $PSScriptRoot +Write-Host $RemoteURL -# Make staging directory -mkdir -Path $StagingDir +#Disable progress bars to make Invoke-WebRequest actually fast +$ProgressPreference = 'SilentlyContinue' # Download compressed boot dir to Staging Dir Invoke-WebRequest -Uri $RemoteURL/boot.zip -OutFile $StagingDir\boot.zip # Expand boot.zip to C:\Boot -Expand-Archive -Path $StagingDir\boot.zip -DestinationPath C:\boot +Expand-Archive -Path $StagingDir\boot.zip -DestinationPath C:\boot -Force # Download WinPE wim to C:\Sources\boot.wim -mkdir -Path C:\Sources +New-Item -ItemType "Directory" -Path C:\Sources -Force Invoke-WebRequest -Uri $RemoteURL/boot.wim -OutFile C:\Sources\boot.wim @@ -74,4 +75,6 @@ function BootToPE { bcdedit /bootsequence $LTGUID shutdown /r /f /t 0 -} \ No newline at end of file +} + +Remove-Item -Path $StagingDir -Recurse \ No newline at end of file