-
Notifications
You must be signed in to change notification settings - Fork 50
/
Malwarebytes-Premium-Reset.ps1
73 lines (60 loc) · 3.46 KB
/
Malwarebytes-Premium-Reset.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
########################################################################################################
# #
# File Name: Malware-Byte-Premium-Reset.ps1 # Output: Schedule a task that resets the #
# Author: Ammar S.A.A # Malwarebytes Premium trial by changing the #
# Version: 2.6 # MachineGuid registry value #
# #
########################################################################################################
# https://github.com/ammarsaa/Malwarebytes-Premium-Reset #
########################################################################################################
# Check if the script is running with elevated privileges
$isAdmin = ([Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544"
if (-not $isAdmin) {
Write-Host "This script requires elevated privileges. Please run it as an administrator."
Read-Host -Prompt "Press Enter to exit..."
Exit
}
# Define the task name, path, and description
$taskName = "Malwarebytes-Premium-Reset"
$taskPath = "\"
$taskDescription = "A task that resets the Malwarebytes Premium trial by changing the MachineGuid registry value"
# Get the current time in HH:mm format
$currentTime = (Get-Date).ToString("HH:mm")
# Define the PowerShell script for the task action
$powerShellScript = {
New-Guid | ForEach-Object {
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Cryptography' -Name 'MachineGuid' -Value $_.Guid
}
}
# Define the task action
$taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-Command $powerShellScript"
# Define the task trigger, which is daily every 13 days at the current system time
$taskTrigger = New-ScheduledTaskTrigger -Daily -DaysInterval 13 -At $currentTime
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
# Define the task settings, which are to run with the highest privileges and start as soon as possible if missed
$taskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
$taskPrincipal = New-ScheduledTaskPrincipal -UserId $currentUser -RunLevel Highest
# Create the task object with the specified action, triggers, settings, and other properties
$task = New-ScheduledTask -Action $taskAction -Principal $taskPrincipal -Trigger $taskTrigger -Settings $taskSettings -Description $taskDescription
# Register the task with the specified name, path, and current user
$result = Register-ScheduledTask -TaskName $taskName -TaskPath $taskPath -InputObject $task
if ($result) {
Write-Host "Yay! Task Scheduled Successfully."
} else {
Write-Host "Oops! Task Failed To Be Scheduled."
}
# Code for checking if the task was completed successfully
$taskRunResult = Get-ScheduledTask -TaskName $taskName | Get-ScheduledTaskInfo
switch ($taskRunResult.LastTaskResult) {
0 {
Write-Host "Last Run Status: Malwarebytes Trial Was Resetted Successfully."
}
267011 {
Write-Host "Status: Task has never ran but exists."
}
default {
Write-Host "Last Run Status: Malwarebytes Trial Reset Failed. Last Result: $($taskRunResult.LastTaskResult)"
}
}
# Keeps the window open
Read-Host -Prompt "Press Enter to exit..."