Meltdown and Spectre vulnerabilities — PowerShell Script

Microsoft has released a PowerShell module that lets the average user check if the chip vulnerabilities are enabled on your system or not. Microsoft has already known about this issue since June 2017, but has only started to release the update for Windows OS. To make sure that you pass the checks, you will need to have an updated Windows OS with the January 2018 Security updates, and the BIOS/Firmware update for your PC.

I thought it would be best to provide the average computer user a quick way to test the system and therefore I have created this simple script. This script first turns Admin mode on, but that might require you to confirm the User Account Control (UAC) window. Then it will make sure ExecutionPolicy is set to RemoteSigned. After this, the script will check to see if PSRepository called PSGallery is trusted. Once all of that is done the script will run SpeculationControlSettings and give you an output like this.

You can find the script explained below or download it from my GitHub page.

The image above is full of read and False checks, but take a good look at the suggested actions. Installing/updating BIOS/Firmware and the January 2018 Security Update will fix the False readings to true. I am unable to install the BIOS without Company Admin password, but I have installed the January 2018 Security Update. You can see that image below.

 


### Checks if Administration mode is on ###
Function Test_Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test_Admin) -eq $false) {
if ($elevated)
{
# tried to elevate, did not work, aborting
}
else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}

exit
}

### Runs Meltdown_Spectre Script ###
Function Meltdown_Spectre {
Set-ExecutionPolicy RemoteSigned -Scope Currentuser
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Get-ExecutionPolicy
Install-Module -Name SpeculationControl
Import-Module SpeculationControl
Get-SpeculationControlSettings
}

Function Run {
Test_Admin
Meltdown_Spectre
}

Run

Advertisements

PowerShell: Get-Services Admin GUI

Got a question by a coworker if it was possible to start a service and stop another one. Sure its possible, but lets make a GUI out of it. This is a small PowerShell GUI that will give you three options of services that you can turn on or off.

You will want to change the following to reflect the services you want to turn off.
$Global:Option1 = get-service “*XboxGipSvc*”
$Global:Option2 = get-service “*XboxNetApiSvc*”
$Global:Option3 = get-service “*XblAuthManager*”

You can turn off one, two, or the three services. This all depends on what the user wants to do. The refresh doesn’t work the best, but we have to use the RELOAD button to refresh the GUI.
The GUI looks like this:

The toggel option allows us to turn the three services off at the same time:

Full Code here:

Add-Type -AssemblyName System.Windows.Forms

Function MakeForm{
$Global:Option1 = get-service "*XboxGipSvc*"
$Global:Option2 = get-service "*XboxNetApiSvc*"
$Global:Option3 = get-service "*XblAuthManager*"

$Global:Option1Txt=$Global:Option1.Displayname
$Global:Option2Txt=$Global:Option2.Displayname
$Global:Option3Txt=$Global:Option3.Displayname
}

Function ServiceAdminForm {
	$Form.Close()
	$Form.Dispose()
	MakeForm
}

Function Option1 {
if ($Global:Option1.Status -eq "Running"){ Stop-Service $Global:Option1
}
else {Start-Service $Global:Option1}
}

Function Option2 {
if ($Global:Option2.Status -eq "Running"){ Stop-Service $Global:Option2
}
else {Start-Service $Global:Option2}
}

Function Option3 {
if ($Global:Option3.Status -eq "Running"){ Stop-Service $Global:Option3
}
else {Start-Service $Global:Option3}
}

Function Toggle {
if ($Global:Option1.Status -eq "Running") {$Global:Option1.stop();}Else{$Global:Option1.start();}
if ($Global:Option2.Status -eq "Running") {$Global:Option2.stop();}Else{$Global:Option2.start();}
if ($Global:Option3.Status -eq "Running") {$Global:Option3.stop();}Else{$Global:Option3.start();}
}

Function MakeForm {
Param

	$script:Form = New-Object system.Windows.Forms.Form
	$Form.Text = "Service Administration"
	$Font = New-Object System.Drawing.Font("Times New Roman",12,[System.Drawing.FontStyle]::Bold)
	$Form.Font = $Font

    #Label for Option1
    $Global:Option1lbl = New-Object system.windows.Forms.Label
    $Global:Option1lbl.Text = $Global:Option1.Status
    $Global:Option1lbl.AutoSize = $true
    $Global:Option1lbl.Width = 25
    $Global:Option1lbl.Height = 10
    $Global:Option1lbl.location = new-object system.drawing.point(5,90)

    #Label for Option2
    $Global:Option2lbl = New-Object system.windows.Forms.Label
    $Global:Option2lbl.Text = $Global:Option2.Status
    $Global:Option2lbl.AutoSize = $true
    $Global:Option2lbl.Width = 25
    $Global:Option2lbl.Height = 10
    $Global:Option2lbl.location = new-object system.drawing.point(5,150)

    #Label for Option3
    $Global:Option3lbl = New-Object system.windows.Forms.Label
    $Global:Option3lbl.Text = $Global:Option3.Status
    $Global:Option3lbl.AutoSize = $true
    $Global:Option3lbl.Width = 25
    $Global:Option3lbl.Height = 10
    $Global:Option3lbl.location = new-object system.drawing.point(5,210)

    #Refresh/Reload
	$Reloadbtn = New-Object System.Windows.Forms.Button
	$Reloadbtn.Location = New-Object System.Drawing.Size(5,10)
	$Reloadbtn.AutoSize = $true
	$Reloadbtn.Text = "Reload"
	$Reloadbtn.Add_Click({ServiceAdminForm})
    
    #Toggle
	$Togglebtn = New-Object System.Windows.Forms.Button
	$Togglebtn.Location = New-Object System.Drawing.Size(80,10)
	$Togglebtn.AutoSize = $true
	$Togglebtn.Text = "Toggle"
	$Togglebtn.Add_Click({Toggle})

    #Button Option1
	$Global:Option1btn = New-Object System.Windows.Forms.Button
	$Global:Option1btn.Location = New-Object System.Drawing.Size(5,60)
	$Global:Option1btn.AutoSize = $true
	$Global:Option1btn.Text = "$Global:Option1Txt"
	$Global:Option1btn.Add_Click({Option1})

    #Button Option2
    $Global:Option2btn = New-Object System.Windows.Forms.Button
	$Global:Option2btn.Location = New-Object System.Drawing.Size(5,120)
	$Global:Option2btn.AutoSize = $true
	$Global:Option2btn.Text = "$Global:Option2Txt"
	$Global:Option2btn.Add_Click({Option2})

    #Button Option3
    $Global:Option3btn = New-Object System.Windows.Forms.Button
	$Global:Option3btn.Location = New-Object System.Drawing.Size(5,180)
	$Global:Option3btn.AutoSize = $true
	$Global:Option3btn.Text = "$Global:Option3Txt"
	$Global:Option3btn.Add_Click({Option3})

    #Form Controls
	$Form.Controls.Add($Global:Option1lbl)
	$Form.Controls.Add($Global:Option2lbl)
	$Form.Controls.Add($Global:Option3lbl)
	$Form.Controls.Add($Reloadbtn)
    $Form.Controls.Add($Togglebtn)
	$Form.Controls.Add($Global:Option1btn)
	$Form.Controls.Add($Global:Option2btn)
	$Form.Controls.Add($Global:Option3btn)
	$Form.ShowDialog()
}
MakeForm