-
Notifications
You must be signed in to change notification settings - Fork 1
/
stager.ps1
59 lines (51 loc) · 2.01 KB
/
stager.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
[CmdletBinding()]
param (
[Parameter(ValueFromPipelineByPropertyName=$true)]
[string]$scriptUrl,
[switch]$Azure,
[switch]$Cloud,
[switch]$CloudBig,
[switch]$RepeatOffender
)
$urlMapping = @{
Azure = "https://raw.githubusercontent.com/MelloSec/RepeatOffender/main/Azure.ps1"
Cloud = "https://example.com/cloud-script.ps1"
CloudBig = "https://raw.githubusercontent.com/MelloSec/RepeatOffender/main/CloudBig.ps1"
RepeatOffender = "https://raw.githubusercontent.com/MelloSec/RepeatOffender/main/RepeatOffender.ps1"
}
if ($scriptUrl) {
$selectedUrl = $scriptUrl
} elseif ($Azure) {
$selectedUrl = $urlMapping.Azure
} elseif ($Cloud) {
$selectedUrl = $urlMapping.Cloud
} elseif ($CloudBig) {
$selectedUrl = $urlMapping.CloudBig
} elseif ($RepeatOffender) {
$selectedUrl = $urlMapping.RepeatOffender
} else {
$selectedUrl = $urlMapping.Azure
}
# Install Script
$chocolateySetupScriptUrl = "https://raw.githubusercontent.com/MelloSec/RepeatOffender/main/Choco.ps1"
# Run the Chocolatey setup script
Invoke-Expression (Invoke-WebRequest -Uri $chocolateySetupScriptUrl -UseBasicParsing)
# Function to reload the PowerShell session
function Reload-PowerShellSession {
Start-Process powershell -ArgumentList "-NoExit", "-Command", "$env:PATH = [System.Environment]::GetEnvironmentVariable('Path','Machine')"
exit
}
# Function to check if Chocolatey is in the PATH
function Test-ChocolateyInPath {
return (Get-Command choco -ErrorAction SilentlyContinue) -ne $null
}
# Reload the session
# Reload-PowerShellSession
# After reloading the session, check if Chocolatey is in the PATH and execute another script if it is
# After reloading the session, check if Chocolatey is in the PATH and execute the selected script if it is
if (Test-ChocolateyInPath) {
# Run the selected script
Invoke-Expression (Invoke-WebRequest -Uri $selectedUrl -UseBasicParsing)
} else {
Write-Output "Chocolatey is not in the PATH. Please ensure it is installed correctly."
}