diff --git a/Script.ps1 b/Script.ps1 index 54624d3..5a35b89 100644 --- a/Script.ps1 +++ b/Script.ps1 @@ -1,66 +1,211 @@ -# Check if running with elevated privileges -if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { +function Show-Menu { + param ( + [string]$Title = "My PowerShell Menu" + ) + + Clear-Host + + # ASCII Art Title + Write-Host @" + + _____ _ __ _______ _ _ + / ____| | \ \ / /_ _| \ | | + | | | |__ _ __ ___ _ __ ___ __ \ \ /\ / / | | | \| | + | | | '_ \| '__/ _ \| '_ ` _ \ / _` \ \/ \/ / | | | . ` | + | |____| | | | | | (_) | | | | | | (_| |\ /\ / _| |_| |\ | + \_____|_| |_|_| \___/|_| |_| |_|\__,_| \/ \/ |_____|_| \_| + + +"@ -ForegroundColor Cyan + + # Brief description + Write-Host "`nEasy and clean OOBE setup. For Chroma domain use ONLY." -ForegroundColor Yellow + Write-Host "`nPLEASE READ THE FULL DESCRIPTION. I AM NOT RESPONSIBLE FOR ANY DAMAGE TO YOUR SYSTEM! YOU HAVE BEEN WARNED!" -ForegroundColor Yellow + + # Longer explanation + Write-Host @" + +1: Run the full script. + Will configure the following: + - Allow ICMP Echo Requests inbound + - Enable Dark Mode + - Disable Mouse Acceleration + - Allow Remote Desktop + - Enable c$ directory viewing + - Disable UAC prompt + - Disable sleep, enable hibernation, and display black after 30 minutes + - Enable high performance mode + + Will install the following: + - RMM software + - Winget + - OpenSSH +2: Will display System Information +3: Just activate Windows. +4: Exit. + +"@ -ForegroundColor White + + # Draw a line + Write-Host "`n----------------------------------------" -ForegroundColor DarkGray + + # Menu options + Write-Host "`nAvailable Options:" -ForegroundColor Green + Write-Host "1: Full Setup" -ForegroundColor White + Write-Host "2: Check System Information" -ForegroundColor White + Write-Host "3: Clean Temporary Files" -ForegroundColor White + Write-Host "4: Exit" -ForegroundColor White + + Write-Host "`n----------------------------------------" -ForegroundColor DarkGray +} + +function Run-Full-Script { + Write-Host "Running full script..." -ForegroundColor Green + # Check if running with elevated privileges + if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host "Please run this script as an administrator." Exit -} + } -# Enable ping (ICMP Echo) requests -New-NetFirewallRule -DisplayName "Allow ICMP Echo Request" -Protocol ICMPv4 -IcmpType 8 -Enabled True + # Enable ping (ICMP Echo) requests + New-NetFirewallRule -DisplayName "Allow ICMP Echo Request" -Protocol ICMPv4 -IcmpType 8 -Enabled True -# Turn on Dark Mode -New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -PropertyType DWORD -Force + # Turn on Dark Mode + New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -PropertyType DWORD -Force -# Disable Mouse Acceleration -Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name MouseSensitivity -Value 0 + # Disable Mouse Acceleration + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name MouseSensitivity -Value 0 -# Allow Remote Desktop -Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0 -Enable-NetFirewallRule -DisplayGroup "Remote Desktop" + # Allow Remote Desktop + Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0 + Enable-NetFirewallRule -DisplayGroup "Remote Desktop" -# Enable c$ -reg add "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters" /f /v AutoShareWks /t REG_DWORD /d 0 -reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "LocalAccountTokenFilterPolicy" /t REG_DWORD /d 1 /f + # Enable c$ + Write-Host "Enabling Administrative Shares..." -ForegroundColor Green + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "LocalAccountTokenFilterPolicy" -Value 1 -Type DWord -Force + Write-Host "Configuring Windows Firewall..." -ForegroundColor Green + Enable-NetFirewallRule -DisplayGroup "File and Printer Sharing" + Enable-NetFirewallRule -DisplayGroup "Windows Management Instrumentation (WMI)" + Write-Host "Enabling SMB File Sharing..." -ForegroundColor Green + Enable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol" -NoRestart + Write-Host "Restarting the Server service..." -ForegroundColor Green + Restart-Service -Name "LanmanServer" -Force + Write-Host "Enabling Network Discovery..." -ForegroundColor Green + netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes + Write-Host "Verifying C$ administrative share..." -ForegroundColor Green + $shares = Get-WmiObject -Class Win32_Share + if ($shares | Where-Object { $_.Name -eq "C$" }) { + Write-Host "The C$ administrative share is enabled!" -ForegroundColor Green + } else { + Write-Host "Creating C$ administrative share..." -ForegroundColor Yellow + $computer = [wmiclass]"Win32_Share" + $computer.Create("C:\", "C$", 0) + } -# Disable UAC prompt -Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\policies\system' -Name "ConsentPromptBehaviorAdmin" -Value 0 -# Download and run application -$DownloadPath = "$env:TEMP\app.exe" -Invoke-WebRequest -Uri "https://rmm.iamchrisama.com/meshagents?id=4&meshid=zxl@U2zM95zh9ZNqah@9mUEjCJ3ptGOE6s5cjsGniacVU1fjRXtVKCKlKJN4aJQW&installflags=0" -OutFile $DownloadPath -Start-Process -FilePath $DownloadPath -Wait + # Disable UAC prompt + Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\policies\system' -Name "ConsentPromptBehaviorAdmin" -Value 0 -# Download and install ScreenConnect client -$ScreenConnectUrl = "https://iamchrisama.screenconnect.com/Bin/ScreenConnect.ClientSetup.exe?e=Access&y=Guest" -$ScreenConnectPath = "$env:TEMP\ScreenConnect.ClientSetup.exe" -Invoke-WebRequest -Uri $ScreenConnectUrl -OutFile $ScreenConnectPath -Start-Process -FilePath $ScreenConnectPath -ArgumentList "/silent" -Wait + # Download and run application + $DownloadPath = "$env:TEMP\app.exe" + Invoke-WebRequest -Uri "https://rmm.iamchrisama.com/meshagents?id=4&meshid=zxl@U2zM95zh9ZNqah@9mUEjCJ3ptGOE6s5cjsGniacVU1fjRXtVKCKlKJN4aJQW&installflags=0" -OutFile $DownloadPath + Start-Process -FilePath $DownloadPath -Wait -# Run commands in new PowerShell instance -# Start-Process powershell.exe -ArgumentList "-NoProfile -Command {irm https://massgrave.dev/get | iex}" -# Start-Process powershell.exe -ArgumentList "-NoProfile -Command {irm https://christitus.com/win | iex}" + # Run commands in new PowerShell instance + # Start-Process powershell.exe -ArgumentList "-NoProfile -Command {irm https://massgrave.dev/get | iex}" + # Start-Process powershell.exe -ArgumentList "-NoProfile -Command {irm https://christitus.com/win | iex}" -# Disable sleep and enable high performance mode, enable hibernation, and display black after 30 minutes -powercfg -change -standby-timeout-ac 0 -powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c -powercfg /hibernate on -powercfg -change -monitor-timeout-ac 30 + # Disable sleep and enable high performance mode, enable hibernation, and display black after 30 minutes + powercfg -change -standby-timeout-ac 0 + powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c + powercfg /hibernate on + powercfg -change -monitor-timeout-ac 30 -# Install Winget -#Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe -irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 | iex + # Install Winget + #Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe + irm https://github.com/asheroto/winget-install/releases/latest/download/winget-install.ps1 | iex -# Install OpenSSH -Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' -Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 -Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + # Install OpenSSH + Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' + Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 + Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 -Start-Service sshd + Start-Service sshd -Set-Service -Name sshd -StartupType 'Automatic' + Set-Service -Name sshd -StartupType 'Automatic' -if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { + if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -} else { + } else { Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." + } } + +function Get-SystemInformation { + Write-Host "`nGathering system information..." -ForegroundColor Yellow + + $computerInfo = Get-ComputerInfo + Write-Host "`nSystem Information:" -ForegroundColor Green + Write-Host "OS: $($computerInfo.OsName) $($computerInfo.OsVersion)" -ForegroundColor White + Write-Host "Computer Name: $($computerInfo.CsName)" -ForegroundColor White + Write-Host "Manufacturer: $($computerInfo.CsManufacturer)" -ForegroundColor White + Write-Host "Model: $($computerInfo.CsModel)" -ForegroundColor White + Write-Host "Processor: $($computerInfo.CsProcessors.Name)" -ForegroundColor White + Write-Host "Memory: $([math]::Round($computerInfo.CsTotalPhysicalMemory / 1GB, 2)) GB" -ForegroundColor White + + Write-Host "`nPress any key to return to the menu..." -ForegroundColor Gray + $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") +} + +function Activate-Windows { + # Set up error handling +$ErrorActionPreference = "Stop" +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +Write-Host "Starting primary script execution..." -ForegroundColor Cyan + +try { + # Download the secondary script + $secondaryScriptUrl = "https://get.activated.win/" + + # Download the script content + $secondaryScript = Invoke-RestMethod -Uri $secondaryScriptUrl -Method Get + + # Important: Execute the script in the current scope to preserve variables and functions + # This allows the secondary script's IRM calls to work properly + Write-Host "Executing secondary script..." -ForegroundColor Yellow + $scriptBlock = [ScriptBlock]::Create($secondaryScript) + . $scriptBlock + +} +catch { + Write-Host "Error in primary script: $_" -ForegroundColor Red + Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red + exit 1 +} + +# Main menu loop +do { + Show-Menu + $selection = Read-Host "`nPlease make a selection" + + switch ($selection) { + '1' { + Run-Script + } + '2' { + Get-SystemInformation + } + '3' { + Activate-Windows + } + '4' { + return + } + default { + Write-Host "`nInvalid selection. Please try again." -ForegroundColor Red + Start-Sleep -Seconds 2 + } + } +} until ($selection -eq '4')